Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2008-02-12 14:21:22 +0000
committerMarkus Schorn2008-02-12 14:21:22 +0000
commit5688a0ac9f9482b9d70252275268ed6cd60b1ff5 (patch)
treed9a772748540fc51b65216bdef782a5a319bca6e /core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java
parentb848ef7a4d0e479b4a864b885d6344fbe7f8ec5d (diff)
downloadorg.eclipse.cdt-5688a0ac9f9482b9d70252275268ed6cd60b1ff5.tar.gz
org.eclipse.cdt-5688a0ac9f9482b9d70252275268ed6cd60b1ff5.tar.xz
org.eclipse.cdt-5688a0ac9f9482b9d70252275268ed6cd60b1ff5.zip
Using directives for fast indexer (including namespace composition), bug 200673+216527.
Diffstat (limited to 'core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java48
1 files changed, 32 insertions, 16 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java
index de7ad22c899..65bd878155b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java
@@ -11,7 +11,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
-import java.util.HashMap;
+import java.util.List;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IName;
@@ -58,6 +58,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexFile;
import org.eclipse.cdt.core.index.IIndexFileSet;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
@@ -67,12 +68,14 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider.CPPBuiltinParameter;
import org.eclipse.cdt.internal.core.index.IIndexScope;
import org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver;
+import org.eclipse.cdt.internal.core.parser.scanner.ISkippedIndexedFilesListener;
+import org.eclipse.cdt.internal.core.parser.scanner.IncludeFileContent;
import org.eclipse.core.runtime.CoreException;
/**
* @author jcamelon
*/
-public class CPPASTTranslationUnit extends CPPASTNode implements ICPPASTTranslationUnit, IASTAmbiguityParent {
+public class CPPASTTranslationUnit extends CPPASTNode implements ICPPASTTranslationUnit, IASTAmbiguityParent, ISkippedIndexedFilesListener {
private static final IASTPreprocessorStatement[] EMPTY_PREPROCESSOR_STATEMENT_ARRAY = new IASTPreprocessorStatement[0];
private static final IASTPreprocessorMacroDefinition[] EMPTY_PREPROCESSOR_MACRODEF_ARRAY = new IASTPreprocessorMacroDefinition[0];
@@ -88,8 +91,8 @@ public class CPPASTTranslationUnit extends CPPASTNode implements ICPPASTTranslat
private IIndex index;
private IIndexFileSet fIndexFileSet;
private boolean fIsHeader= true;
- private HashMap<IIndexScope, IScope> fMappedScopes= new HashMap<IIndexScope, IScope>();
-
+ private CPPScopeMapper fScopeMapper= new CPPScopeMapper(this);
+
public CPPASTTranslationUnit() {
}
@@ -535,19 +538,32 @@ public class CPPASTTranslationUnit extends CPPASTNode implements ICPPASTTranslat
fIsHeader= headerUnit;
}
- // bug 217102: namespace scopes from the index have to be mapped back to the AST.
- IScope mapToASTScope(IIndexScope scope) {
- if (scope instanceof ICPPNamespaceScope) {
- IScope result= fMappedScopes.get(scope);
- if (result == null) {
- result= getScope().findNamespaceScope(scope);
- if (result == null) {
- result= scope;
- }
- fMappedScopes.put(scope, result);
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.scanner.ISkippedIndexedFilesListener#skippedFile(org.eclipse.cdt.internal.core.parser.scanner.IncludeFileContent)
+ */
+ public void skippedFile(int offset, IncludeFileContent fileContent) {
+ if (fIndexFileSet != null) {
+ final List<IIndexFile> files= fileContent.getFilesIncluded();
+ for (IIndexFile indexFile : files) {
+ fIndexFileSet.add(indexFile);
}
- return result;
}
- return scope;
+ fScopeMapper.registerAdditionalDirectives(offset, fileContent.getUsingDirectives());
+ }
+
+ // bug 217102: namespace scopes from the index have to be mapped back to the AST.
+ IScope mapToASTScope(IIndexScope scope) {
+ return fScopeMapper.mapToASTScope(scope);
+ }
+
+ /**
+ * Stores directives from the index into this scope.
+ */
+ void handleAdditionalDirectives(ICPPNamespaceScope scope) {
+ fScopeMapper.handleAdditionalDirectives(scope);
+ }
+
+ IIndexFileSet getFileSet() {
+ return fIndexFileSet;
}
}

Back to the top