mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 293385 - Log standalone indexer progress using IParserLogService instead of stdout
This commit is contained in:
parent
3a0a069fb7
commit
5c8a3a78a4
4 changed files with 41 additions and 12 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2007 QNX Software Systems and others.
|
||||
* Copyright (c) 2006, 2009 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -99,7 +99,9 @@ public class StandaloneFastIndexer extends StandaloneIndexer {
|
|||
*/
|
||||
@Override
|
||||
protected StandaloneIndexerTask createTask(List<String> added, List<String> changed, List<String> removed) {
|
||||
return new StandaloneFastIndexerTask(this, added, changed, removed);
|
||||
StandaloneIndexerTask task = new StandaloneFastIndexerTask(this, added, changed, removed);
|
||||
task.setLogService(getParserLog());
|
||||
return task;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2007 QNX Software Systems and others.
|
||||
* Copyright (c) 2006, 2009 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -98,7 +98,9 @@ public class StandaloneFullIndexer extends StandaloneIndexer{
|
|||
*/
|
||||
@Override
|
||||
protected StandaloneIndexerTask createTask(List<String> added, List<String> changed, List<String> removed) {
|
||||
return new StandaloneFullIndexerTask(this, added, changed, removed);
|
||||
StandaloneIndexerTask task = new StandaloneFullIndexerTask(this, added, changed, removed);
|
||||
task.setLogService(getParserLog());
|
||||
return task;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ public abstract class StandaloneIndexer {
|
|||
protected IWritableIndex fIndex;
|
||||
|
||||
/**
|
||||
* A flag that indiciates if all files (sources without config, headers not included)
|
||||
* A flag that indicates if all files (sources without config, headers not included)
|
||||
* should be parsed.
|
||||
*/
|
||||
protected boolean fIndexAllFiles;
|
||||
|
@ -295,6 +295,13 @@ public abstract class StandaloneIndexer {
|
|||
return fLog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the logger.
|
||||
*/
|
||||
public void setParserLog(IParserLogService log) {
|
||||
fLog = log;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if indexing activities should be shown.
|
||||
* Otherwise, this method returns false.
|
||||
|
|
|
@ -20,6 +20,8 @@ import org.eclipse.cdt.core.model.AbstractLanguage;
|
|||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.internal.core.dom.AbstractCodeReaderFactory;
|
||||
import org.eclipse.cdt.internal.core.dom.IIncludeFileResolutionHeuristics;
|
||||
import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
||||
import org.eclipse.cdt.internal.core.pdom.AbstractIndexerTask;
|
||||
import org.eclipse.cdt.internal.core.pdom.IndexerProgress;
|
||||
|
@ -44,6 +46,7 @@ import com.ibm.icu.text.MessageFormat;
|
|||
public abstract class StandaloneIndexerTask extends AbstractIndexerTask {
|
||||
|
||||
protected StandaloneIndexer fIndexer;
|
||||
protected IParserLogService fLogger;
|
||||
|
||||
public static final int[] IDS_FOR_LINKAGES_TO_INDEX = {
|
||||
ILinkage.CPP_LINKAGE_ID, ILinkage.C_LINKAGE_ID, ILinkage.FORTRAN_LINKAGE_ID
|
||||
|
@ -137,20 +140,20 @@ public abstract class StandaloneIndexerTask extends AbstractIndexerTask {
|
|||
String name= getClass().getName();
|
||||
name= name.substring(name.lastIndexOf('.')+1);
|
||||
|
||||
System.out.println(name + " " //$NON-NLS-1$
|
||||
trace(name + " " //$NON-NLS-1$
|
||||
+ " (" + info.fCompletedSources + " sources, " //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ info.fCompletedHeaders + " headers)"); //$NON-NLS-1$
|
||||
|
||||
boolean allFiles= getIndexAllFiles();
|
||||
boolean skipRefs= fIndexer.getSkipReferences() == StandaloneIndexer.SKIP_ALL_REFERENCES;
|
||||
boolean skipTypeRefs= skipRefs || fIndexer.getSkipReferences() == StandaloneIndexer.SKIP_TYPE_REFERENCES;
|
||||
System.out.println(name + " Options: " //$NON-NLS-1$
|
||||
trace(name + " Options: " //$NON-NLS-1$
|
||||
+ "parseAllFiles=" + allFiles //$NON-NLS-1$
|
||||
+ ",skipReferences=" + skipRefs //$NON-NLS-1$
|
||||
+ ", skipTypeReferences=" + skipTypeRefs //$NON-NLS-1$
|
||||
+ "."); //$NON-NLS-1$
|
||||
|
||||
System.out.println(name + " Timings: " //$NON-NLS-1$
|
||||
trace(name + " Timings: " //$NON-NLS-1$
|
||||
+ (System.currentTimeMillis() - start) + " total, " //$NON-NLS-1$
|
||||
+ fStatistics.fParsingTime + " parser, " //$NON-NLS-1$
|
||||
+ fStatistics.fResolutionTime + " resolution, " //$NON-NLS-1$
|
||||
|
@ -160,7 +163,7 @@ public abstract class StandaloneIndexerTask extends AbstractIndexerTask {
|
|||
NumberFormat nf= NumberFormat.getPercentInstance();
|
||||
nf.setMaximumFractionDigits(2);
|
||||
nf.setMinimumFractionDigits(2);
|
||||
System.out.println(name + " Result: " //$NON-NLS-1$
|
||||
trace(name + " Result: " //$NON-NLS-1$
|
||||
+ fStatistics.fDeclarationCount + " declarations, " //$NON-NLS-1$
|
||||
+ fStatistics.fReferenceCount + " references, " //$NON-NLS-1$
|
||||
+ fStatistics.fErrorCount + " errors, " //$NON-NLS-1$
|
||||
|
@ -172,7 +175,7 @@ public abstract class StandaloneIndexerTask extends AbstractIndexerTask {
|
|||
long hits= index.getCacheHits();
|
||||
long tries= misses+hits;
|
||||
double missPct= tries==0 ? 0.0 : (double) misses / (double) tries;
|
||||
System.out.println(name + " Cache: " //$NON-NLS-1$
|
||||
trace(name + " Cache: " //$NON-NLS-1$
|
||||
+ hits + " hits, " //$NON-NLS-1$
|
||||
+ misses + "(" + nf.format(missPct)+ ") misses."); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
@ -224,15 +227,21 @@ public abstract class StandaloneIndexerTask extends AbstractIndexerTask {
|
|||
*/
|
||||
@Override
|
||||
protected IParserLogService getLogService() {
|
||||
if (fLogger != null)
|
||||
return fLogger;
|
||||
return new StdoutLogService();
|
||||
}
|
||||
|
||||
protected void setLogService(IParserLogService logService){
|
||||
fLogger = logService;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.pdom.AbstractIndexerTask#logError(org.eclipse.core.runtime.IStatus)
|
||||
*/
|
||||
@Override
|
||||
protected void logError(IStatus s) {
|
||||
getLogService().traceLog(s.getMessage());
|
||||
trace(s.getMessage());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -240,7 +249,7 @@ public abstract class StandaloneIndexerTask extends AbstractIndexerTask {
|
|||
*/
|
||||
@Override
|
||||
protected void logException(Throwable e) {
|
||||
getLogService().traceLog(e.getMessage());
|
||||
trace(e.getMessage());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
@ -264,4 +273,13 @@ public abstract class StandaloneIndexerTask extends AbstractIndexerTask {
|
|||
protected int[] getLinkagesToParse() {
|
||||
return IDS_FOR_LINKAGES_TO_INDEX;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.pdom.PDOMWriter#trace(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
protected void trace(String message) {
|
||||
getLogService().traceLog(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue