Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2008-02-15 16:33:11 +0000
committerMarkus Schorn2008-02-15 16:33:11 +0000
commitbad35ab17a1b2f4b5e7680f75aa2b64cfbf7d3d0 (patch)
tree9c5bb4e801493cb13672bab87a3eaca61beac3b0 /core/org.eclipse.cdt.core/parser
parent34a4df083218e62f55d626a78b5abbab56fbe155 (diff)
downloadorg.eclipse.cdt-bad35ab17a1b2f4b5e7680f75aa2b64cfbf7d3d0.tar.gz
org.eclipse.cdt-bad35ab17a1b2f4b5e7680f75aa2b64cfbf7d3d0.tar.xz
org.eclipse.cdt-bad35ab17a1b2f4b5e7680f75aa2b64cfbf7d3d0.zip
Improvements for writing to the index (potential NPE, progress reporting, tracing).
Diffstat (limited to 'core/org.eclipse.cdt.core/parser')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java35
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java68
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMIndexerTask.java11
3 files changed, 58 insertions, 56 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java
index 14b8106eae9..761400a2202 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java
@@ -68,9 +68,11 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
fUri= uri;
fLinkageID= linkageID;
}
+ @Override
public int hashCode() {
return fUri.hashCode() * 31 + fLinkageID;
}
+ @Override
public boolean equals(Object obj) {
FileKey other = (FileKey) obj;
return fLinkageID == other.fLinkageID && fUri.equals(other.fUri);
@@ -525,7 +527,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
final IScannerInfo scannerInfo= fResolver.getBuildConfiguration(linkageID, header);
parseFile(header, linkageID, ifl, scannerInfo, monitor);
if (info.fIsUpdated) {
- updateInfo(-1, 1, 0); // a header was parsed without context
+ updateInfo(0, 1, -1); // a header was parsed without context
iter.remove();
}
}
@@ -601,27 +603,25 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
}
private void writeToIndex(final int linkageID, IASTTranslationUnit ast, int configHash, IProgressMonitor pm) throws CoreException, InterruptedException {
- HashSet<String> enteredASTFilePaths= new HashSet<String>();
+ HashSet<IIndexFileLocation> enteredFiles= new HashSet<IIndexFileLocation>();
ArrayList<IIndexFileLocation> orderedIFLs= new ArrayList<IIndexFileLocation>();
- final String astPath = ast.getFilePath();
- enteredASTFilePaths.add(astPath);
+ final IIndexFileLocation topIfl = fResolver.resolveASTPath(ast.getFilePath());
+ enteredFiles.add(topIfl);
IDependencyTree tree= ast.getDependencyTree();
IASTInclusionNode[] inclusions= tree.getInclusions();
for (int i=0; i < inclusions.length; i++) {
- collectOrderedIFLs(linkageID, inclusions[i], enteredASTFilePaths, orderedIFLs);
+ collectOrderedIFLs(linkageID, inclusions[i], enteredFiles, orderedIFLs);
}
- IIndexFileLocation ifl= fResolver.resolveASTPath(astPath);
- FileContent info= getFileInfo(linkageID, ifl);
+ FileContent info= getFileInfo(linkageID, topIfl);
if (info != null && info.fRequestUpdate && !info.fIsUpdated) {
- orderedIFLs.add(fResolver.resolveASTPath(astPath));
+ orderedIFLs.add(topIfl);
}
IIndexFileLocation[] ifls= orderedIFLs.toArray(new IIndexFileLocation[orderedIFLs.size()]);
addSymbols(ast, ifls, fIndex, 1, false, configHash, fTodoTaskUpdater, pm);
- for (int i = 0; i < ifls.length; i++) {
- ifl= ifls[i];
+ for (IIndexFileLocation ifl : ifls) {
info= getFileInfo(linkageID, ifl);
assert info != null;
if (info != null) {
@@ -630,20 +630,17 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
}
}
- private void collectOrderedIFLs(final int linkageID, IASTInclusionNode inclusion, HashSet<String> enteredASTFilePaths, ArrayList<IIndexFileLocation> orderedIFLs) throws CoreException {
+ private void collectOrderedIFLs(final int linkageID, IASTInclusionNode inclusion, HashSet<IIndexFileLocation> enteredFiles, ArrayList<IIndexFileLocation> orderedIFLs) throws CoreException {
final IASTPreprocessorIncludeStatement id= inclusion.getIncludeDirective();
if (id.isActive() && id.isResolved()) {
- final String path= id.getPath();
- final boolean isFirst= enteredASTFilePaths.add(path);
+ final IIndexFileLocation ifl= fResolver.resolveASTPath(id.getPath());
+ final boolean isFirstEntry= enteredFiles.add(ifl);
IASTInclusionNode[] nested= inclusion.getNestedInclusions();
for (int i = 0; i < nested.length; i++) {
- collectOrderedIFLs(linkageID, nested[i], enteredASTFilePaths, orderedIFLs);
+ collectOrderedIFLs(linkageID, nested[i], enteredFiles, orderedIFLs);
}
- if (isFirst) {
- final IIndexFileLocation ifl= fResolver.resolveASTPath(path);
- if (needToUpdateHeader(linkageID, ifl)) {
- orderedIFLs.add(ifl);
- }
+ if (isFirstEntry && needToUpdateHeader(linkageID, ifl)) {
+ orderedIFLs.add(ifl);
}
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java
index 9b66c9ded8e..f9991fca26c 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java
@@ -224,45 +224,47 @@ abstract public class PDOMWriter {
IIndexFileLocation path= ifls[i];
Symbols symbols= symbolMap.get(path);
- ArrayList<IASTName[]> names= symbols.fNames;
+ final ArrayList<IASTName[]> names= symbols.fNames;
boolean reported= false;
for (Iterator<IASTName[]> j = names.iterator(); j.hasNext();) {
final IASTName[] na= j.next();
final IASTName name = na[0];
- try {
- final IBinding binding = name.resolveBinding();
- if (binding instanceof IProblemBinding) {
- fStatistics.fProblemBindingCount++;
- if (fShowProblems) {
- reportProblem((IProblemBinding) binding);
+ if (name != null) { // should not be null, just be defensive.
+ try {
+ final IBinding binding = name.resolveBinding();
+ if (binding instanceof IProblemBinding) {
+ fStatistics.fProblemBindingCount++;
+ if (fShowProblems) {
+ reportProblem((IProblemBinding) binding);
+ }
}
- }
- else if (name.isReference()) {
- if (fSkipReferences == SKIP_TYPE_REFERENCES) {
- if (isTypeReferenceBinding(binding) && !isRequiredReference(name)) {
- na[0]= null;
- fStatistics.fReferenceCount--;
+ else if (name.isReference()) {
+ if (fSkipReferences == SKIP_TYPE_REFERENCES) {
+ if (isTypeReferenceBinding(binding) && !isRequiredReference(name)) {
+ na[0]= null;
+ fStatistics.fReferenceCount--;
+ }
}
+ fStatistics.fReferenceCount++;
}
- fStatistics.fReferenceCount++;
- }
- else {
- fStatistics.fDeclarationCount++;
- }
- } catch (RuntimeException e) {
- if (!reported) {
- stati.add(CCorePlugin.createStatus(
- NLS.bind(Messages.PDOMWriter_errorResolvingName, name.toString(), path.getURI().getPath()), e));
- }
- reported= true;
- j.remove();
- } catch (PDOMNotImplementedError e) {
- if (!reported) {
- stati.add(CCorePlugin.createStatus(
- NLS.bind(Messages.PDOMWriter_errorResolvingName, name.toString(), path.getURI().getPath()), e));
+ else {
+ fStatistics.fDeclarationCount++;
+ }
+ } catch (RuntimeException e) {
+ if (!reported) {
+ stati.add(CCorePlugin.createStatus(
+ NLS.bind(Messages.PDOMWriter_errorResolvingName, name.toString(), path.getURI().getPath()), e));
+ }
+ reported= true;
+ j.remove();
+ } catch (PDOMNotImplementedError e) {
+ if (!reported) {
+ stati.add(CCorePlugin.createStatus(
+ NLS.bind(Messages.PDOMWriter_errorResolvingName, name.toString(), path.getURI().getPath()), e));
+ }
+ reported= true;
+ j.remove();
}
- reported= true;
- j.remove();
}
}
}
@@ -337,8 +339,8 @@ abstract public class PDOMWriter {
fStatistics.fUnresolvedIncludesCount += unresolvedIncludes;
fStatistics.fPreprocessorProblemCount+= ast.getPreprocessorProblemsCount() - unresolvedIncludes;
- if (fShowScannerProblems || fShowSyntaxProblems) {
- final boolean reportAll= fShowScannerProblems && fShowSyntaxProblems;
+ if (fShowScannerProblems || fShowInclusionProblems) {
+ final boolean reportAll= fShowScannerProblems && fShowInclusionProblems;
IASTProblem[] scannerProblems= ast.getPreprocessorProblems();
for (IASTProblem problem : scannerProblems) {
if (reportAll || (problem.getID() == IASTProblem.PREPROCESSOR_INCLUSION_NOT_FOUND) == fShowInclusionProblems) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMIndexerTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMIndexerTask.java
index ad7a4c439ad..fc12591c8f2 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMIndexerTask.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMIndexerTask.java
@@ -152,6 +152,9 @@ public abstract class PDOMIndexerTask extends AbstractIndexerTask implements IPD
String filename= linkageID == ILinkage.C_LINKAGE_ID ? "__cdt__.c" : "__cdt__.cpp"; //$NON-NLS-1$//$NON-NLS-2$
IFile file= project.getFile(filename);
scanInfo= provider.getScannerInformation(file);
+ if (scanInfo == null || scanInfo.getDefinedSymbols().isEmpty()) {
+ scanInfo= provider.getScannerInformation(project);
+ }
}
else {
scanInfo= new ScannerInfo();
@@ -203,10 +206,10 @@ public abstract class PDOMIndexerTask extends AbstractIndexerTask implements IPD
+ fStatistics.fResolutionTime + " resolution, " //$NON-NLS-1$
+ fStatistics.fAddToIndexTime + " index update."); //$NON-NLS-1$
System.out.println(name + " Errors: " //$NON-NLS-1$
- + fStatistics.fUnresolvedIncludesCount + " include, " //$NON-NLS-1$
- + fStatistics.fPreprocessorProblemCount + " scanner, " //$NON-NLS-1$
- + fStatistics.fSyntaxProblemsCount + " syntax, " //$NON-NLS-1$
- + fStatistics.fErrorCount + " internal errors."); //$NON-NLS-1$
+ + fStatistics.fErrorCount + " internal, " //$NON-NLS-1$
+ + fStatistics.fUnresolvedIncludesCount + " include, " //$NON-NLS-1$
+ + fStatistics.fPreprocessorProblemCount + " scanner, " //$NON-NLS-1$
+ + fStatistics.fSyntaxProblemsCount + " syntax errors."); //$NON-NLS-1$
int sum= fStatistics.fDeclarationCount+fStatistics.fReferenceCount+fStatistics.fProblemBindingCount;
double problemPct= sum==0 ? 0.0 : (double) fStatistics.fProblemBindingCount / (double) sum;

Back to the top