mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-28 19:35:36 +02:00
Add tracing for unresolved includes
This commit is contained in:
parent
49724e630c
commit
1152d73794
3 changed files with 21 additions and 2 deletions
|
@ -217,6 +217,9 @@ abstract public class PDOMWriter {
|
||||||
stack.add(currentPath);
|
stack.add(currentPath);
|
||||||
currentPath= findLocation(include.getPath());
|
currentPath= findLocation(include.getPath());
|
||||||
}
|
}
|
||||||
|
else if (include.isActive()) {
|
||||||
|
reportProblem(include);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
stack.add(currentPath);
|
stack.add(currentPath);
|
||||||
while (!stack.isEmpty()) {
|
while (!stack.isEmpty()) {
|
||||||
|
@ -286,10 +289,22 @@ abstract public class PDOMWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void reportProblem(IASTPreprocessorIncludeStatement problem) {
|
||||||
|
fStatistics.fUnresolvedIncludes++;
|
||||||
|
if (fShowProblems) {
|
||||||
|
String msg= "Indexer: unresolved include"; //$NON-NLS-1$
|
||||||
|
IASTFileLocation loc= problem.getFileLocation();
|
||||||
|
if (loc != null && loc.getFileName() != null) {
|
||||||
|
msg += " at " + loc.getFileName() + ": " + loc.getStartingLineNumber(); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
}
|
||||||
|
System.out.println(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void reportProblem(IProblemBinding problem) {
|
private void reportProblem(IProblemBinding problem) {
|
||||||
fStatistics.fProblemBindingCount++;
|
fStatistics.fProblemBindingCount++;
|
||||||
if (fShowProblems) {
|
if (fShowProblems) {
|
||||||
String msg= "Indexer problem at "+ problem.getFileName() + ": " + problem.getLineNumber(); //$NON-NLS-1$//$NON-NLS-2$
|
String msg= "Indexer: problem at "+ problem.getFileName() + ": " + problem.getLineNumber(); //$NON-NLS-1$//$NON-NLS-2$
|
||||||
String pmsg= problem.getMessage();
|
String pmsg= problem.getMessage();
|
||||||
if (pmsg != null && pmsg.length() > 0)
|
if (pmsg != null && pmsg.length() > 0)
|
||||||
msg+= "; " + problem.getMessage(); //$NON-NLS-1$
|
msg+= "; " + problem.getMessage(); //$NON-NLS-1$
|
||||||
|
|
|
@ -19,4 +19,5 @@ public class IndexerStatistics {
|
||||||
public int fReferenceCount= 0;
|
public int fReferenceCount= 0;
|
||||||
public int fDeclarationCount= 0;
|
public int fDeclarationCount= 0;
|
||||||
public int fProblemBindingCount= 0;
|
public int fProblemBindingCount= 0;
|
||||||
|
public int fUnresolvedIncludes= 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -430,6 +430,10 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
|
||||||
+ fStatistics.fParsingTime + " parser, " //$NON-NLS-1$
|
+ fStatistics.fParsingTime + " parser, " //$NON-NLS-1$
|
||||||
+ fStatistics.fResolutionTime + " resolution, " //$NON-NLS-1$
|
+ fStatistics.fResolutionTime + " resolution, " //$NON-NLS-1$
|
||||||
+ fStatistics.fAddToIndexTime + " index update."); //$NON-NLS-1$
|
+ fStatistics.fAddToIndexTime + " index update."); //$NON-NLS-1$
|
||||||
|
System.out.println(name + " Errors: " //$NON-NLS-1$
|
||||||
|
+ fStatistics.fUnresolvedIncludes + " unresolved includes, " //$NON-NLS-1$
|
||||||
|
+ fStatistics.fErrorCount + " unexpected errors."); //$NON-NLS-1$
|
||||||
|
|
||||||
int sum= fStatistics.fDeclarationCount+fStatistics.fReferenceCount+fStatistics.fProblemBindingCount;
|
int sum= fStatistics.fDeclarationCount+fStatistics.fReferenceCount+fStatistics.fProblemBindingCount;
|
||||||
double problemPct= sum==0 ? 0.0 : (double) fStatistics.fProblemBindingCount / (double) sum;
|
double problemPct= sum==0 ? 0.0 : (double) fStatistics.fProblemBindingCount / (double) sum;
|
||||||
NumberFormat nf= NumberFormat.getPercentInstance();
|
NumberFormat nf= NumberFormat.getPercentInstance();
|
||||||
|
@ -438,7 +442,6 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
|
||||||
System.out.println(name + " Result: " //$NON-NLS-1$
|
System.out.println(name + " Result: " //$NON-NLS-1$
|
||||||
+ fStatistics.fDeclarationCount + " declarations, " //$NON-NLS-1$
|
+ fStatistics.fDeclarationCount + " declarations, " //$NON-NLS-1$
|
||||||
+ fStatistics.fReferenceCount + " references, " //$NON-NLS-1$
|
+ fStatistics.fReferenceCount + " references, " //$NON-NLS-1$
|
||||||
+ fStatistics.fErrorCount + " errors, " //$NON-NLS-1$
|
|
||||||
+ fStatistics.fProblemBindingCount + "(" + nf.format(problemPct) + ") problems."); //$NON-NLS-1$ //$NON-NLS-2$
|
+ fStatistics.fProblemBindingCount + "(" + nf.format(problemPct) + ") problems."); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
|
||||||
if (index != null) {
|
if (index != null) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue