Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java2
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IIncludeTests.java4
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IStructureTests.java6
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IntegratedCModelTest.java6
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralCModelElementsTests.java5
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralStructureTests.java6
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSearchUtil.java4
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseBaseTest.java3
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ClassTests.java16
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/EnumerationTests.java18
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/IncludesTests.java13
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/TypesTests.java14
-rw-r--r--core/org.eclipse.cdt.core/.settings/org.eclipse.core.resources.prefs4
-rw-r--r--core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.core.prefs2
-rw-r--r--core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.ui.prefs3
-rw-r--r--core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/AllTypesCache.java21
-rw-r--r--core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/PDOMTypeInfo.java8
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/AbstractLanguage.java33
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java10
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ILanguage.java43
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ITranslationUnit.java70
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/LanguageManager.java144
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ContentTypeProcessor.java12
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java220
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ILinkage.java31
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IName.java20
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOM.java78
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOMResolver.java35
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTName.java13
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBinding.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IScope.java29
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java65
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/GPPLanguage.java66
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndex.java278
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexBinding.java39
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexFile.java53
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexInclude.java53
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexLinkage.java31
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexMacro.java32
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexManager.java70
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexName.java18
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IndexFilter.java37
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/Linkage.java29
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTInternal.java60
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java15
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalScope.java47
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguity.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTName.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java26
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CEnumeration.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CEnumerator.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CExternalVariable.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunction.java12
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CKnRParameter.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CLabel.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CParameter.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CScope.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CStructure.java20
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CTypedef.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariable.java11
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java24
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguity.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTName.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNode.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java26
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstanceScope.java19
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java1
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java15
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPCompositeBinding.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDelegate.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumeration.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumerator.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPField.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java12
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPLabel.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplate.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespace.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespaceAlias.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScope.java20
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java33
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSpecialization.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateParameter.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedef.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownBinding.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUsingDeclaration.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java311
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/EmptyCIndex.java100
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragment.java137
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentBinding.java18
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentFile.java (renamed from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOMWriter.java)23
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentInclude.java29
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentName.java30
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexProxyBinding.java28
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IWritableIndex.java65
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IWritableIndexFragment.java62
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IWritableIndexManager.java22
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedCodeReaderFactory.java (renamed from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMCodeReaderFactory.java)112
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/Messages.java26
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/WritableCIndex.java135
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/messages.properties1
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/LocationMap.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/MacroBinding.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/Messages.java26
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java418
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java157
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/WritablePDOM.java65
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMBinding.java18
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMBindingAdapterFactory.java67
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMFile.java95
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMInclude.java25
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java61
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMMacro.java56
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMName.java16
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMNode.java13
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMPointerType.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMQualifierType.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCLinkage.java39
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCStructure.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCTypedef.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java21
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java100
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespace.java19
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameter.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTypedef.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPVariable.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/fast/PDOMFastHandleDelta.java47
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/fast/PDOMFastIndexerJob.java85
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/fast/PDOMFastReindex.java12
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/full/PDOMFullHandleDelta.java50
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/full/PDOMFullIndexerJob.java92
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/full/PDOMFullReindex.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/nulli/PDOMNullIndexer.java47
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/messages.properties1
-rw-r--r--core/org.eclipse.cdt.core/plugin.xml6
-rw-r--r--core/org.eclipse.cdt.core/schema/language.exsd33
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java20
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseTestCase.java18
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java14
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCppCallHierarchyTest.java16
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java16
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CppCallHierarchyTest.java106
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/InitializersInCallHierarchyTest.java2
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java4
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java4
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java4
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/ResolveBindingTests.java96
158 files changed, 3916 insertions, 1375 deletions
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java
index cdc8a5510dc..06aea0f77ce 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java
@@ -98,7 +98,7 @@ public class CModelElementsTests extends TestCase {
//ITranslationUnit included = (ITranslationUnit)CoreModel.getDefault().create(includedFile);
// parse the translation unit to get the elements tree
- tu.parse();
+// tu.parse();
// tu ---> include
checkInclude(tu);
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IIncludeTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IIncludeTests.java
index 517b7589559..ed979e83c7a 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IIncludeTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IIncludeTests.java
@@ -57,7 +57,7 @@ public class IIncludeTests extends IntegratedCModelTest {
return suite;
}
- public void testGetIncludeName()
+ public void testGetIncludeName() throws CModelException
{
ITranslationUnit tu = getTU();
IInclude[] theIncludes = null;
@@ -100,7 +100,7 @@ public class IIncludeTests extends IntegratedCModelTest {
}
- public void testIsStandard()
+ public void testIsStandard() throws CModelException
{
ITranslationUnit tu = getTU();
IInclude[] theIncludes = null;
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IStructureTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IStructureTests.java
index 8478243f494..244c8596fef 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IStructureTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IStructureTests.java
@@ -318,7 +318,7 @@ public class IStructureTests extends IntegratedCModelTest {
}
// IInheritance
- public void testGetBaseTypes() {
+ public void testGetBaseTypes() throws CModelException {
ITranslationUnit tu = getTU();
ICElement myElementDerived = null;
String[] myBaseTypes = null;
@@ -345,7 +345,7 @@ public class IStructureTests extends IntegratedCModelTest {
}
// IInheritance
- public void testGetAccessControl() {
+ public void testGetAccessControl() throws CModelException {
ITranslationUnit tu = getTU();
ICElement myElementDerived = null;
String[] myBaseTypes = null;
@@ -390,7 +390,7 @@ public class IStructureTests extends IntegratedCModelTest {
// Language Specification Tests
//
- public void testAnonymousStructObject() {
+ public void testAnonymousStructObject() throws CModelException {
ITranslationUnit tu = getTU();
ICElement myElement = null;
try {
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IntegratedCModelTest.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IntegratedCModelTest.java
index 362678c8aa5..c58672f6f37 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IntegratedCModelTest.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IntegratedCModelTest.java
@@ -20,6 +20,7 @@ import java.io.FileNotFoundException;
import junit.framework.TestCase;
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ITranslationUnit;
@@ -87,7 +88,7 @@ public abstract class IntegratedCModelTest extends TestCase {
CProjectHelper.delete(fCProject);
}
- protected ITranslationUnit getTU() {
+ protected ITranslationUnit getTU() throws CModelException {
ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create(sourceFile);
if(isStructuralParse()) {
CCorePlugin.getDefault().setStructuralParseMode(true);
@@ -96,7 +97,8 @@ public abstract class IntegratedCModelTest extends TestCase {
}
// parse the translation unit to get the elements tree
// Force the parsing now to do this in the right ParseMode.
- tu.parse();
+ tu.close();
+ tu.open(new NullProgressMonitor());
CCorePlugin.getDefault().setStructuralParseMode(false);
return tu;
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralCModelElementsTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralCModelElementsTests.java
index 80fd8e20091..c89eef71179 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralCModelElementsTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralCModelElementsTests.java
@@ -96,13 +96,10 @@ public class StructuralCModelElementsTests extends TestCase {
public void testCModelElements() throws CModelException{
ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create(headerFile);
- //ITranslationUnit included = (ITranslationUnit)CoreModel.getDefault().create(includedFile);
// turn on the structural parse mode
+ tu.close();
CCorePlugin.getDefault().setStructuralParseMode(true);
- // parse the translation unit to get the elements tree
- tu.parse();
-
// tu ---> include
checkInclude(tu);
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralStructureTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralStructureTests.java
index e05617808ba..205bf85bab6 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralStructureTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralStructureTests.java
@@ -54,21 +54,21 @@ public class StructuralStructureTests extends IStructureTests {
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.tests.IStructureTests#testAnonymousStructObject()
*/
- public void testAnonymousStructObject() {
+ public void testAnonymousStructObject() throws CModelException {
setStructuralParse(true);
super.testAnonymousStructObject();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.tests.IStructureTests#testGetAccessControl()
*/
- public void testGetAccessControl() {
+ public void testGetAccessControl() throws CModelException {
setStructuralParse(true);
super.testGetAccessControl();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.tests.IStructureTests#testGetBaseTypes()
*/
- public void testGetBaseTypes() {
+ public void testGetBaseTypes() throws CModelException {
setStructuralParse(true);
super.testGetBaseTypes();
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSearchUtil.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSearchUtil.java
index 7eda50efc02..4f1f64bbb56 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSearchUtil.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSearchUtil.java
@@ -27,9 +27,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
-import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
@@ -162,7 +162,7 @@ public class DOMSearchUtil {
}
IBinding binding = searchName.resolveBinding();
- if (binding instanceof PDOMBinding) {
+ if (binding instanceof IIndexBinding) {
Assert.fail("Not implemented");
// try {
// ArrayList pdomNames = new ArrayList();
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseBaseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseBaseTest.java
index 155017cba32..d39ce83ff50 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseBaseTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseBaseTest.java
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Rational Software - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.ast2;
@@ -39,7 +40,7 @@ public class DOMSelectionParseBaseTest extends DOMFileBasePluginTest {
protected IASTNode parse(IFile file, int offset1, int offset2, boolean expectedToPass) throws Exception {
ITranslationUnit tu = (ITranslationUnit)CCorePlugin.getDefault().getCoreModel().create(file);
- IASTTranslationUnit ast = tu.getLanguage().getASTTranslationUnit(tu, 0);
+ IASTTranslationUnit ast = tu.getAST();
IASTName[] names = tu.getLanguage().getSelectedNames(ast, offset1, offset2 - offset1);
if (!expectedToPass) return null;
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ClassTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ClassTests.java
index c87e55a0ee9..483745e404d 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ClassTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ClassTests.java
@@ -22,6 +22,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
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.IndexFilter;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -47,21 +49,21 @@ public class ClassTests extends PDOMTestBase {
}
public void test1() throws Exception {
- IBinding[] Bs = pdom.findBindings(Pattern.compile("B"), new NullProgressMonitor());
+ IBinding[] Bs = pdom.findBindings(Pattern.compile("B"), false, new IndexFilter(), new NullProgressMonitor());
assertEquals(1, Bs.length);
ICPPClassType B = (ICPPClassType)Bs[0];
ICPPMethod[] Bmethods = B.getAllDeclaredMethods();
assertEquals(1, Bmethods.length);
ICPPMethod Bf = Bmethods[0];
assertEquals("f", Bf.getName());
- IName [] Bf_refs = pdom.getReferences(Bf);
+ IName [] Bf_refs = pdom.findNames(Bf, IIndex.FIND_REFERENCES);
assertEquals(1, Bf_refs.length);
IASTFileLocation loc = Bf_refs[0].getFileLocation();
assertEquals(offset("class.cpp", "b.f()") + 2, loc.getNodeOffset());
}
public void testNested() throws Exception {
- IBinding[] bindings = pdom.findBindings(Pattern.compile("NestedA"), new NullProgressMonitor());
+ IBinding[] bindings = pdom.findBindings(Pattern.compile("NestedA"), false, new IndexFilter(), new NullProgressMonitor());
assertEquals(1, bindings.length);
ICPPClassType NestedA = (ICPPClassType)bindings[0];
ICPPClassType[] nested = NestedA.getNestedClasses();
@@ -72,24 +74,24 @@ public class ClassTests extends PDOMTestBase {
assertEquals(1, fields.length);
IField NestedB_x = fields[0];
- IName[] refs = pdom.getReferences(NestedB);
+ IName[] refs = pdom.findNames(NestedB, IIndex.FIND_REFERENCES);
assertEquals(1, refs.length);
IASTFileLocation loc = refs[0].getFileLocation();
assertEquals(offset("nested.cpp", "::NestedB") + 2, loc.getNodeOffset());
- refs = pdom.getReferences(NestedB_x);
+ refs = pdom.findNames(NestedB_x, IIndex.FIND_REFERENCES);
assertEquals(1, refs.length);
loc = refs[0].getFileLocation();
assertEquals(offset("nested.cpp", "x.x") + 2, loc.getNodeOffset());
}
public void failedTest147903() throws Exception {
- IBinding[] bindings = pdom.findBindings(Pattern.compile("pr147903"), new NullProgressMonitor());
+ IBinding[] bindings = pdom.findBindings(Pattern.compile("pr147903"), false, new IndexFilter(), new NullProgressMonitor());
assertEquals(1, bindings.length);
ICPPNamespaceScope ns = ((ICPPNamespace)bindings[0]).getNamespaceScope();
bindings = ns.find("testRef");
assertEquals(1, bindings.length);
- IName[] refs = pdom.getReferences(bindings[0]);
+ IName[] refs = pdom.findNames(bindings[0], IIndex.FIND_REFERENCES);
for (int i = 0; i < refs.length; ++i)
System.out.println(refs[i].getFileLocation().getNodeOffset());
assertEquals(5, refs.length);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/EnumerationTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/EnumerationTests.java
index a9bb4f2f979..35744e3b886 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/EnumerationTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/EnumerationTests.java
@@ -19,6 +19,8 @@ import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IEnumeration;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IndexFilter;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -46,7 +48,7 @@ public class EnumerationTests extends PDOMTestBase {
public void testC() throws Exception {
// Check bindings
Pattern pattern = Pattern.compile("TestCEnum");
- IBinding[] bindings = pdom.findBindings(pattern, new NullProgressMonitor());
+ IBinding[] bindings = pdom.findBindings(pattern, false, new IndexFilter(), new NullProgressMonitor());
assertEquals(1, bindings.length);
IEnumeration enumeration = (IEnumeration)bindings[0];
assertEquals("TestCEnum", enumeration.getName());
@@ -57,19 +59,19 @@ public class EnumerationTests extends PDOMTestBase {
assertEquals("cc", enumerators[2].getName());
// Declaration of TestEnum
- IName[] enumDecls = pdom.getDeclarations(enumeration);
+ IName[] enumDecls = pdom.findNames(enumeration, IIndex.FIND_DECLARATIONS_DEFINITIONS);
assertEquals(1, enumDecls.length);
IASTFileLocation loc = enumDecls[0].getFileLocation();
assertEquals(5, loc.getNodeOffset());
// Reference to TestEnum
- IName[] enumRefs = pdom.getReferences(enumeration);
+ IName[] enumRefs = pdom.findNames(enumeration, IIndex.FIND_REFERENCES);
assertEquals(1, enumRefs.length);
loc = enumRefs[0].getFileLocation();
assertEquals(offset("enumTest.c", "TestCEnum test"), loc.getNodeOffset());
// Reference to a
- IName[] aRefs = pdom.getReferences(enumerators[0]);
+ IName[] aRefs = pdom.findNames(enumerators[0], IIndex.FIND_REFERENCES);
assertEquals(1, aRefs.length);
loc = aRefs[0].getFileLocation();
assertEquals(offset("enumTest.c", "ca;"), loc.getNodeOffset());
@@ -78,7 +80,7 @@ public class EnumerationTests extends PDOMTestBase {
public void testCPP() throws Exception {
// Check bindings
Pattern pattern = Pattern.compile("TestCPPEnum");
- IBinding[] bindings = pdom.findBindings(pattern, new NullProgressMonitor());
+ IBinding[] bindings = pdom.findBindings(pattern, false, new IndexFilter(), new NullProgressMonitor());
assertEquals(1, bindings.length);
IEnumeration enumeration = (IEnumeration)bindings[0];
assertEquals("TestCPPEnum", enumeration.getName());
@@ -89,19 +91,19 @@ public class EnumerationTests extends PDOMTestBase {
assertEquals("cppc", enumerators[2].getName());
// Declaration of TestEnum
- IName[] enumDecls = pdom.getDeclarations(enumeration);
+ IName[] enumDecls = pdom.findNames(enumeration, IIndex.FIND_DECLARATIONS_DEFINITIONS);
assertEquals(1, enumDecls.length);
IASTFileLocation loc = enumDecls[0].getFileLocation();
assertEquals(5, loc.getNodeOffset());
// Reference to TestEnum
- IName[] enumRefs = pdom.getReferences(enumeration);
+ IName[] enumRefs = pdom.findNames(enumeration, IIndex.FIND_REFERENCES);
assertEquals(1, enumRefs.length);
loc = enumRefs[0].getFileLocation();
assertEquals(offset("enumTest.cpp", "TestCPPEnum test"), loc.getNodeOffset());
// Reference to a
- IName[] aRefs = pdom.getReferences(enumerators[0]);
+ IName[] aRefs = pdom.findNames(enumerators[0], IIndex.FIND_REFERENCES);
assertEquals(1, aRefs.length);
loc = aRefs[0].getFileLocation();
assertEquals(offset("enumTest.cpp", "cppa;"), loc.getNodeOffset());
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/IncludesTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/IncludesTests.java
index 129cdccdbfa..6c46037a8a6 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/IncludesTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/IncludesTests.java
@@ -11,9 +11,10 @@
package org.eclipse.cdt.internal.pdom.tests;
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexFile;
+import org.eclipse.cdt.core.index.IIndexInclude;
import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.internal.core.pdom.PDOM;
-import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
import org.eclipse.core.runtime.IPath;
/**
@@ -23,12 +24,12 @@ import org.eclipse.core.runtime.IPath;
public class IncludesTests extends PDOMTestBase {
protected ICProject project;
- protected PDOM pdom;
+ protected IIndex pdom;
protected void setUp() throws Exception {
if (pdom == null) {
project = createProject("includesTests");
- pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(project);
+ pdom = CCorePlugin.getIndexManager().getIndex(project);
}
pdom.acquireReadLock();
}
@@ -39,9 +40,9 @@ public class IncludesTests extends PDOMTestBase {
public void test1() throws Exception {
IPath loc = project.getProject().getLocation().append("I2.h");
- PDOMFile file = pdom.getFile(loc.toOSString());
+ IIndexFile file = pdom.getFile(loc);
assertNotNull(file);
- PDOMFile[] allIncludedBy = file.getAllIncludedBy();
+ IIndexInclude[] allIncludedBy = pdom.findIncludedBy(file, -1);
assertEquals(9, allIncludedBy.length); // i.e. all of them
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/TypesTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/TypesTests.java
index 73bdb6ea212..c902d4af982 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/TypesTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/TypesTests.java
@@ -22,6 +22,8 @@ import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IndexFilter;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -48,7 +50,7 @@ public class TypesTests extends PDOMTestBase {
public void testC() throws Exception {
// Get the binding for A::f
- IBinding [] CAs = pdom.findBindings(Pattern.compile("CA"), new NullProgressMonitor());
+ IBinding [] CAs = pdom.findBindings(Pattern.compile("CA"), false, new IndexFilter(), new NullProgressMonitor());
assertEquals(1, CAs.length);
ICompositeType CA = (ICompositeType)CAs[0];
IField [] CAfields = CA.getFields();
@@ -57,7 +59,7 @@ public class TypesTests extends PDOMTestBase {
assertEquals("x", x.getName());
// Make sure that there is a reference in g();
- IName[] xRefs = pdom.getReferences(x);
+ IName[] xRefs = pdom.findNames(x, IIndex.FIND_REFERENCES);
assertEquals(1, xRefs.length);
IASTFileLocation loc = xRefs[0].getFileLocation();
assertEquals(offset("typedef.c", "x->x") + 3, loc.getNodeOffset());
@@ -65,7 +67,7 @@ public class TypesTests extends PDOMTestBase {
public void testCPP() throws Exception {
// Get the binding for A::f
- IBinding [] As = pdom.findBindings(Pattern.compile("A"), new NullProgressMonitor());
+ IBinding [] As = pdom.findBindings(Pattern.compile("A"), false, new IndexFilter(), new NullProgressMonitor());
assertEquals(1, As.length);
ICPPClassType A = (ICPPClassType)As[0];
ICPPMethod[] Amethods = A.getMethods();
@@ -74,17 +76,17 @@ public class TypesTests extends PDOMTestBase {
assertEquals("f", f.getName());
// Make sure that there is a reference in g();
- IName[] fRefs = pdom.getReferences(f);
+ IName[] fRefs = pdom.findNames(f, IIndex.FIND_REFERENCES);
assertEquals(1, fRefs.length);
IASTFileLocation loc = fRefs[0].getFileLocation();
assertEquals(offset("typedef.cpp", "x->f") + 3, loc.getNodeOffset());
}
public void test145351() throws Exception {
- IBinding [] bindings = pdom.findBindings(Pattern.compile("spinlock_t"), new NullProgressMonitor());
+ IBinding [] bindings = pdom.findBindings(Pattern.compile("spinlock_t"), false, new IndexFilter(), new NullProgressMonitor());
assertEquals(1, bindings.length);
ITypedef spinlock_t = (ITypedef)bindings[0];
- IName [] refs = pdom.getReferences(spinlock_t);
+ IName [] refs = pdom.findNames(spinlock_t, IIndex.FIND_REFERENCES);
assertEquals(1, refs.length);
IASTFileLocation loc = refs[0].getFileLocation();
assertEquals(offset("bug145351.c", "spinlock_t global_bh_lock"), loc.getNodeOffset());
diff --git a/core/org.eclipse.cdt.core/.settings/org.eclipse.core.resources.prefs b/core/org.eclipse.cdt.core/.settings/org.eclipse.core.resources.prefs
index 280c26f4231..6661dc065ec 100644
--- a/core/org.eclipse.cdt.core/.settings/org.eclipse.core.resources.prefs
+++ b/core/org.eclipse.cdt.core/.settings/org.eclipse.core.resources.prefs
@@ -1,3 +1,5 @@
-#Mon Oct 09 11:18:42 BST 2006
+#Tue Oct 10 16:32:29 CEST 2006
eclipse.preferences.version=1
+encoding//parser/org/eclipse/cdt/internal/core/index/messages.properties=8859_1
encoding//parser/org/eclipse/cdt/internal/core/pdom/db/messages.properties=8859_1
+encoding//parser/org/eclipse/cdt/internal/core/pdom/messages.properties=8859_1
diff --git a/core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.core.prefs b/core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.core.prefs
index 3d903cccc77..c67af907127 100644
--- a/core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.core.prefs
+++ b/core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Mon Jul 03 19:51:10 CEST 2006
+#Thu Oct 05 16:52:57 CEST 2006
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
diff --git a/core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.ui.prefs b/core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 00000000000..90e5beb6a4b
--- /dev/null
+++ b/core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,3 @@
+#Thu Oct 05 16:52:57 CEST 2006
+eclipse.preferences.version=1
+internal.default.compliance=user
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/AllTypesCache.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/AllTypesCache.java
index 7c8d9d8eb72..fb219474e54 100644
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/AllTypesCache.java
+++ b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/AllTypesCache.java
@@ -14,17 +14,17 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.IPDOMManager;
import org.eclipse.cdt.core.dom.IPDOMNode;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IEnumeration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
-import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage;
-import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
@@ -120,12 +120,12 @@ public class AllTypesCache {
return;
case ICElement.C_STRUCT:
if (node instanceof ICPPClassType
- && ((ICPPClassType)node).getKey() == ICPPClassType.k_struct)
+ && ((ICPPClassType)node).getKey() == ICompositeType.k_struct)
types.add(new PDOMTypeInfo((PDOMBinding)node, kind, project));
return;
case ICElement.C_UNION:
if (node instanceof ICPPClassType
- && ((ICPPClassType)node).getKey() == ICPPClassType.k_union)
+ && ((ICPPClassType)node).getKey() == ICompositeType.k_union)
types.add(new PDOMTypeInfo((PDOMBinding)node, kind, project));
return;
case ICElement.C_ENUMERATION:
@@ -152,10 +152,15 @@ public class AllTypesCache {
CPPTypesCollector cppCollector = new CPPTypesCollector(kinds, types, project);
PDOM pdom = (PDOM)pdomManager.getPDOM(project);
- PDOMLinkage cLinkage = pdom.getLinkage(GCCLanguage.getDefault());
- cLinkage.accept(cCollector);
- PDOMLinkage cppLinkage = pdom.getLinkage(GPPLanguage.getDefault());
- cppLinkage.accept(cppCollector);
+ PDOMLinkage linkage= pdom.getLinkage(ILinkage.C_LINKAGE_ID);
+ if (linkage != null) {
+ linkage.accept(cCollector);
+ }
+
+ linkage= pdom.getLinkage(ILinkage.CPP_LINKAGE_ID);
+ if (linkage != null) {
+ linkage.accept(cppCollector);
+ }
}
return (ITypeInfo[])types.toArray(new ITypeInfo[types.size()]);
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/PDOMTypeInfo.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/PDOMTypeInfo.java
index 43bb79df5bb..4f92ab2aefd 100644
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/PDOMTypeInfo.java
+++ b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/PDOMTypeInfo.java
@@ -15,13 +15,14 @@ package org.eclipse.cdt.core.browser;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.IPDOM;
-import org.eclipse.cdt.core.dom.IPDOMResolver;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
+import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
+import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
import org.eclipse.core.runtime.CoreException;
@@ -120,9 +121,8 @@ public class PDOMTypeInfo implements ITypeInfo {
public ITypeReference getResolvedReference() {
try {
- IPDOM pdom = CCorePlugin.getPDOMManager().getPDOM(project);
- IPDOMResolver resolver = (IPDOMResolver) pdom.getAdapter(IPDOMResolver.class);
- IName[] names= resolver.getDefinitions(binding);
+ PDOM pdom = (PDOM) CCorePlugin.getPDOMManager().getPDOM(project);
+ IName[] names= pdom.findNames(binding, IIndex.FIND_DEFINITIONS);
return names != null && names.length > 0 ? new PDOMTypeReference(names[0], project) : null;
} catch (CoreException e) {
CCorePlugin.log(e);
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/AbstractLanguage.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/AbstractLanguage.java
new file mode 100644
index 00000000000..c6bba004cb2
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/AbstractLanguage.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.core.model;
+
+import org.eclipse.cdt.core.dom.ICodeReaderFactory;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.PlatformObject;
+
+/**
+ * Models the differences between various languages.
+ * @since 4.0
+ */
+public abstract class AbstractLanguage extends PlatformObject implements ILanguage {
+
+ final public IASTTranslationUnit getASTTranslationUnit(ITranslationUnit file, int style) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ final public IASTTranslationUnit getASTTranslationUnit(ITranslationUnit file, ICodeReaderFactory codeReaderFactory,
+ int style) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java
index 7c3713ec083..17fae237536 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java
@@ -326,14 +326,8 @@ public class CoreModel {
*/
public static String getRegistedContentTypeId(IProject project, String name) {
IContentType contentType = CCorePlugin.getContentType(project, name);
- if (contentType != null) {
- String id = contentType.getId();
- String[] ids = getRegistedContentTypeIds();
- for (int i = 0; i < ids.length; i++) {
- if (ids[i].equals(id)) {
- return id;
- }
- }
+ if (contentType != null && LanguageManager.getInstance().getLanguage(contentType) != null) {
+ return contentType.getId();
}
return null;
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ILanguage.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ILanguage.java
index 2a6f2ebac03..2d3a1042c6f 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ILanguage.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ILanguage.java
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.model;
@@ -15,12 +16,16 @@ import org.eclipse.cdt.core.dom.ICodeReaderFactory;
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.parser.CodeReader;
+import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
/**
+ * Models differences between languages. The interace is not supposed to be implemented directly.
+ * Rather than that clients may subclass {@link AbstractLanguage}.
* @author Doug Schaefer
- *
*/
public interface ILanguage extends IAdaptable {
@@ -28,31 +33,27 @@ public interface ILanguage extends IAdaptable {
public static final String KEY = "language"; //$NON-NLS-1$
/**
- * Style for getTranslationUnit. Use the index for resolving bindings that aren't
- * found in the AST.
+ * @deprecated has no effect.
*/
public static final int AST_USE_INDEX = 1;
/**
- * Style for getTranslationUnit. Don't parse header files. It's a good idea to
- * turn on AST_USE_INDEX when you do this.
+ * @deprecated use {@link ITranslationUnit#AST_SKIP_ALL_HEADERS}
*/
- public static final int AST_SKIP_ALL_HEADERS = 2;
+ public static final int AST_SKIP_ALL_HEADERS = ITranslationUnit.AST_SKIP_ALL_HEADERS;
/**
- * Style for getTranslationUnit. Used by the indexer to skip over headers it
- * already has indexed.
+ * @deprecated use {@link ITranslationUnit#AST_SKIP_INDEXED_HEADERS}
*/
- public static final int AST_SKIP_INDEXED_HEADERS = 4;
+ public static final int AST_SKIP_INDEXED_HEADERS = ITranslationUnit.AST_SKIP_INDEXED_HEADERS;
/**
- * Style for getTranslationUnit. Don't parse the file if there is no build
- * information for it.
+ * @deprecated use {@link ITranslationUnit#AST_SKIP_IF_NO_BUILD_INFO}
*/
- public static final int AST_SKIP_IF_NO_BUILD_INFO = 8;
+ public static final int AST_SKIP_IF_NO_BUILD_INFO = ITranslationUnit.AST_SKIP_IF_NO_BUILD_INFO;
/**
- * Return the language id for this language in the given PDOM.
+ * Return the language id for this language.
* This is to differentiate languages from eachother.
*
* @return language id
@@ -60,23 +61,14 @@ public interface ILanguage extends IAdaptable {
public String getId();
/**
- * Create the AST for the given file with the given style.
- *
- * @param file
- * @param style
- * @return
+ * @deprecated use {@link ITranslationUnit#getAST()}.
*/
public IASTTranslationUnit getASTTranslationUnit(
ITranslationUnit file,
int style) throws CoreException;
/**
- * Create the AST for the given file with the given style with a given
- * code reader factory.
- *
- * @param file
- * @param style
- * @return
+ * @deprecated use {@link ITranslationUnit#getAST(...)}.
*/
public IASTTranslationUnit getASTTranslationUnit(
ITranslationUnit file,
@@ -114,4 +106,7 @@ public interface ILanguage extends IAdaptable {
* to parse using the default CDT model builder
*/
public IContributedModelBuilder createModelBuilder(ITranslationUnit tu);
+
+ // mstodo javadoc
+ public IASTTranslationUnit getASTTranslationUnit(CodeReader reader, IScannerInfo scanInfo, ICodeReaderFactory fileCreator, IIndex index) throws CoreException;
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ITranslationUnit.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ITranslationUnit.java
index 78e914b1b01..95d06778e53 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ITranslationUnit.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ITranslationUnit.java
@@ -7,13 +7,19 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.model;
import java.util.Map;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.parser.CodeReader;
+import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.internal.core.model.IBufferFactory;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
/**
* Represents an entire C translation unit (<code>.c</code> source file).
@@ -25,6 +31,23 @@ import org.eclipse.core.runtime.IProgressMonitor;
* the case.
*/
public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISourceReference, ISourceManipulation {
+
+ /**
+ * Style for {@link #getAST(IIndex, int)}. Don't parse header files.
+ */
+ public static final int AST_SKIP_ALL_HEADERS = 2;
+
+ /**
+ * Style for {@link #getAST(IIndex, int)}. Skips over headers that are found in the index.
+ */
+ public static final int AST_SKIP_INDEXED_HEADERS = 4;
+
+ /**
+ * Style for {@link #getAST(IIndex, int)}. Don't parse the file if there is no build
+ * information for it.
+ */
+ public static final int AST_SKIP_IF_NO_BUILD_INFO = 8;
+
/**
* Creates and returns an include declaration in this translation unit
* with the given name.
@@ -386,4 +409,51 @@ public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISource
*
*/
public void setIsStructureKnown(boolean wasSuccessful);
+
+ /**
+ * Returns the absolute path of the location of the translation unit. May be <code>null</code>, in
+ * case the location does not exist.
+ * @return an absolute path to the location, or <code>null</code>
+ * @since 4.0
+ */
+ public IPath getLocation();
+
+ /**
+ * Returns the code reader that can be used to parse the translation unit. If the translation unit is a
+ * working copy the reader will read from the buffer.
+ * @return a code reader for parsing the translation unit
+ * @since 4.0
+ */
+ public CodeReader getCodeReader();
+
+ /**
+ * Returns the scanner info associated with this translation unit. May return <code>null</code> if no
+ * configuration is available.
+ * @param force if <code>true</code> a default info is returned, even if nothing is configured for this
+ * translation unit
+ * @return a scanner info for parsing the translation unit or <code>null</code> if none is configured
+ * @since 4.0
+ */
+ public IScannerInfo getScannerInfo(boolean force);
+
+ /**
+ * Creates the full AST for this translation unit. May return <code>null</code> if the language of this
+ * translation unit does not support ASTs.
+ * @return the AST for the translation unit or <code>null</code>
+ * @throws CoreException
+ * @since 4.0
+ */
+ public IASTTranslationUnit getAST() throws CoreException;
+
+ /**
+ * Creates an AST based on the requested style. May return <code>null</code> if the language of this
+ * translation unit does not support ASTs.
+ * @param index index to back up the parsing of the AST, may be <code>null</code>
+ * @param style <code>0</code> or a combination of {@link #AST_SKIP_ALL_HEADERS},
+ * {@link #AST_SKIP_IF_NO_BUILD_INFO} and {@link #AST_SKIP_INDEXED_HEADERS}
+ * @return the AST requested or <code>null</code>
+ * @throws CoreException
+ * @since 4.0
+ */
+ public IASTTranslationUnit getAST(IIndex index, int style) throws CoreException;
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/LanguageManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/LanguageManager.java
index 92581df6216..182ede2c1ca 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/LanguageManager.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/LanguageManager.java
@@ -19,12 +19,16 @@ import java.util.Map;
import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.internal.core.model.TranslationUnit;
+import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.core.runtime.content.IContentTypeManager;
@@ -33,9 +37,18 @@ import org.eclipse.core.runtime.content.IContentTypeManager;
*
*/
public class LanguageManager {
-
+ private static final String NAMESPACE_SEPARATOR = "."; //$NON-NLS-1$
+ private static final String LANGUAGE_EXTENSION_POINT_ID = "org.eclipse.cdt.core.language"; //$NON-NLS-1$
+ private static final String ELEMENT_LANGUAGE = "language"; //$NON-NLS-1$
+ private static final String ELEMENT_CONTENT_TYPE = "contentType"; //$NON-NLS-1$
+ private static final String ELEMENT_PDOM_LINKAGE_FACTORY = "pdomLinkageFactory"; //$NON-NLS-1$
+ private static final String ATTRIBUTE_CLASS = "class"; //$NON-NLS-1$
+ private static final String ATTRIBUTE_ID = "id"; //$NON-NLS-1$
+
private static LanguageManager instance;
- private Map cache = new HashMap();
+ private Map fLanguageCache = new HashMap();
+ private Map fPDOMLinkageFactoryCache= new HashMap();
+ private Map fContentTypeToLanguageCache= new HashMap();
public static LanguageManager getInstance() {
if (instance == null)
@@ -43,46 +56,67 @@ public class LanguageManager {
return instance;
}
- public ILanguage getLanguage(String id) throws CoreException {
- ILanguage language = (ILanguage)cache.get(id);
+ public ILanguage getLanguage(String id) {
+ ILanguage language = (ILanguage)fLanguageCache.get(id);
if (language != null)
return language;
- IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, ILanguage.KEY);
- IExtension[] extensions = point.getExtensions();
- for (int i = 0; i < extensions.length; ++i) {
- IExtension extension = extensions[i];
- IConfigurationElement[] languages = extension.getConfigurationElements();
- for (int j = 0; j < languages.length; ++j) {
- IConfigurationElement languageElem = languages[j];
- String langId = extension.getNamespaceIdentifier() + "." + languageElem.getAttribute("id"); //$NON-NLS-1$ //$NON-NLS-2$ $NON-NLS-2$
+ IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID);
+ for (int j = 0; j < configs.length; ++j) {
+ final IConfigurationElement languageElem = configs[j];
+ if (ELEMENT_LANGUAGE.equals(languageElem.getName())) {
+ String langId = getLanguageID(languageElem);
if (langId.equals(id)) {
- language = (ILanguage)languageElem.createExecutableExtension("class"); //$NON-NLS-1$
- cache.put(id, language);
- return language;
+ final ILanguage[] result= new ILanguage[]{null};
+ SafeRunner.run(new ISafeRunnable(){
+ public void handleException(Throwable exception) {
+ CCorePlugin.log(exception);
+ }
+
+ public void run() throws Exception {
+ result[0]= (ILanguage)languageElem.createExecutableExtension(ATTRIBUTE_CLASS);
+ }
+ });
+ if (result[0] != null) {
+ fLanguageCache.put(id, result[0]);
+ return result[0];
+ }
}
}
}
-
return null;
}
+
+ private String getLanguageID(final IConfigurationElement languageElem) {
+ return languageElem.getNamespaceIdentifier() + NAMESPACE_SEPARATOR + languageElem.getAttribute(ATTRIBUTE_ID);
+ }
- public ILanguage getLanguage(IContentType contentType) throws CoreException {
- String contentTypeId= contentType.getId();
- IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, ILanguage.KEY);
- IExtension[] extensions = point.getExtensions();
- for (int i = 0; i < extensions.length; ++i) {
- IConfigurationElement[] languages = extensions[i].getConfigurationElements();
- for (int j = 0; j < languages.length; ++j) {
- IConfigurationElement language = languages[j];
- IConfigurationElement[] assocContentTypes = language.getChildren("contentType"); //$NON-NLS-1$
+ public ILanguage getLanguage(IContentType contentType) {
+ String contentTypeID= contentType.getId();
+ return getLanguageForContentTypeID(contentTypeID);
+ }
+
+ private ILanguage getLanguageForContentTypeID(String contentTypeID) {
+ ILanguage language = (ILanguage)fContentTypeToLanguageCache.get(contentTypeID);
+ if (language != null || fContentTypeToLanguageCache.containsKey(contentTypeID))
+ return language;
+
+ IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID);
+ for (int j = 0; j < configs.length; ++j) {
+ final IConfigurationElement languageElem = configs[j];
+ if (ELEMENT_LANGUAGE.equals(languageElem.getName())) {
+ IConfigurationElement[] assocContentTypes = languageElem.getChildren(ELEMENT_CONTENT_TYPE);
for (int k = 0; k < assocContentTypes.length; ++k) {
- if (contentTypeId.equals(assocContentTypes[k].getAttribute("id"))) { //$NON-NLS-1$
- return (ILanguage)language.createExecutableExtension("class"); //$NON-NLS-1$
+ if (contentTypeID.equals(assocContentTypes[k].getAttribute(ATTRIBUTE_ID))) {
+ String id= getLanguageID(languageElem);
+ ILanguage lang= getLanguage(id);
+ fContentTypeToLanguageCache.put(contentTypeID, lang);
+ return lang;
}
}
}
}
+ fContentTypeToLanguageCache.put(contentTypeID, null);
return null;
}
@@ -98,15 +132,13 @@ public class LanguageManager {
allTypes.add(CCorePlugin.CONTENT_TYPE_CXXSOURCE);
IContentTypeManager manager = Platform.getContentTypeManager();
- IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, ILanguage.KEY);
- IExtension[] extensions = point.getExtensions();
- for (int i = 0; i < extensions.length; ++i) {
- IConfigurationElement[] languages = extensions[i].getConfigurationElements();
- for (int j = 0; j < languages.length; ++j) {
- IConfigurationElement language = languages[j];
- IConfigurationElement[] contentTypes = language.getChildren("contentType"); //$NON-NLS-1$
+ IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID);
+ for (int j = 0; j < configs.length; ++j) {
+ final IConfigurationElement languageElem = configs[j];
+ if (ELEMENT_LANGUAGE.equals(languageElem.getName())) {
+ IConfigurationElement[] contentTypes = languageElem.getChildren(ELEMENT_CONTENT_TYPE);
for (int k = 0; k < contentTypes.length; ++k) {
- IContentType langContType = manager.getContentType(contentTypes[k].getAttribute("id")); //$NON-NLS-1$
+ IContentType langContType = manager.getContentType(contentTypes[k].getAttribute(ATTRIBUTE_ID));
allTypes.add(langContType.getId());
}
}
@@ -133,15 +165,15 @@ public class LanguageManager {
allTypes.add(CCorePlugin.CONTENT_TYPE_CXXSOURCE);
IContentTypeManager manager = Platform.getContentTypeManager();
- IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, ILanguage.KEY);
+ IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, LANGUAGE_EXTENSION_POINT_ID);
IExtension[] extensions = point.getExtensions();
for (int i = 0; i < extensions.length; ++i) {
IConfigurationElement[] languages = extensions[i].getConfigurationElements();
for (int j = 0; j < languages.length; ++j) {
IConfigurationElement language = languages[j];
- IConfigurationElement[] contentTypes = language.getChildren("contentType"); //$NON-NLS-1$
+ IConfigurationElement[] contentTypes = language.getChildren(ELEMENT_CONTENT_TYPE);
for (int k = 0; k < contentTypes.length; ++k) {
- IContentType langContType = manager.getContentType(contentTypes[k].getAttribute("id")); //$NON-NLS-1$
+ IContentType langContType = manager.getContentType(contentTypes[k].getAttribute(ATTRIBUTE_ID));
allTypes.add(langContType.getId());
}
}
@@ -151,7 +183,7 @@ public class LanguageManager {
}
public boolean isContributedContentType(String contentTypeId) {
- return collectContentTypeIds().contains(contentTypeId);
+ return contentTypeId != null && getLanguageForContentTypeID(contentTypeId) != null;
}
public IContributedModelBuilder getContributedModelBuilderFor(TranslationUnit tu) {
@@ -162,4 +194,38 @@ public class LanguageManager {
return null;
}
}
+
+ /**
+ * Returns a factory for the given linkage ID. The IDs are defined in {@link ILinkage}.
+ * @param linkageID an ID for a linkage.
+ * @return a factory or <code>null</code>.
+ * @since 4.0
+ */
+ public IPDOMLinkageFactory getPDOMLinkageFactory(String linkageID) {
+ final IPDOMLinkageFactory[] result= new IPDOMLinkageFactory[] {null};
+ result[0]= (IPDOMLinkageFactory) fPDOMLinkageFactoryCache.get(linkageID);
+
+ if (result[0] == null) {
+ // read configuration
+ IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID);
+ for (int i = 0; result[0] == null && i < configs.length; i++) {
+ final IConfigurationElement element = configs[i];
+ if (ELEMENT_PDOM_LINKAGE_FACTORY.equals(element.getName())) {
+ if (linkageID.equals(element.getAttribute(ATTRIBUTE_ID))) {
+ SafeRunner.run(new ISafeRunnable(){
+ public void handleException(Throwable exception) {
+ CCorePlugin.log(exception);
+ }
+
+ public void run() throws Exception {
+ result[0]= (IPDOMLinkageFactory) element.createExecutableExtension(ATTRIBUTE_CLASS);
+ }}
+ );
+ }
+ }
+ }
+ fPDOMLinkageFactoryCache.put(linkageID, result[0]);
+ }
+ return result[0];
+ }
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ContentTypeProcessor.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ContentTypeProcessor.java
index 380502066cb..bb0ed29c80a 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ContentTypeProcessor.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ContentTypeProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2005 QNX Software Systems and others.
+ * Copyright (c) 2002, 2006 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
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.model;
@@ -24,6 +25,7 @@ import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IOpenable;
import org.eclipse.cdt.core.model.ISourceRoot;
import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.LanguageManager;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -89,13 +91,7 @@ public class ContentTypeProcessor extends CModelOperation {
if (id == null || id.length() == 0) {
return false;
}
- String[] ids = CoreModel.getRegistedContentTypeIds();
- for (int i = 0; i < ids.length; i++) {
- if (ids[i].equals(id)) {
- return true;
- }
- }
- return false;
+ return LanguageManager.getInstance().isContributedContentType(id);
}
protected void processContentType(ICElement celement, IContentType contentType, IScopeContext context) {
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java
index bf95096134a..7984d3fb930 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java
@@ -17,9 +17,13 @@ import java.util.HashMap;
import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.dom.ICodeReaderFactory;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.IBuffer;
import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IContributedModelBuilder;
import org.eclipse.cdt.core.model.IInclude;
import org.eclipse.cdt.core.model.ILanguage;
@@ -32,7 +36,15 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IUsing;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.core.model.LanguageManager;
+import org.eclipse.cdt.core.parser.CodeReader;
+import org.eclipse.cdt.core.parser.IScannerInfo;
+import org.eclipse.cdt.core.parser.IScannerInfoProvider;
+import org.eclipse.cdt.core.parser.ParserUtil;
+import org.eclipse.cdt.core.parser.ScannerInfo;
+import org.eclipse.cdt.internal.core.dom.SavedCodeReaderFactory;
+import org.eclipse.cdt.internal.core.index.IndexBasedCodeReaderFactory;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -56,7 +68,6 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
*/
protected IProblemRequestor problemRequestor;
-
SourceManipulationInfo sourceManipulationInfo = null;
public TranslationUnit(ICElement parent, IFile file, String idType) {
@@ -74,7 +85,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
setContentTypeID(idType);
}
- public ITranslationUnit getTranslationUnit () {
+ public ITranslationUnit getTranslationUnit() {
return this;
}
@@ -120,7 +131,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
}
public ICElement getElementAtOffset(int pos) throws CModelException {
- ICElement e= getSourceElementAtOffset(pos);
+ ICElement e = getSourceElementAtOffset(pos);
if (e == this) {
return null;
}
@@ -128,14 +139,14 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
}
public ICElement[] getElementsAtOffset(int pos) throws CModelException {
- ICElement[] e= getSourceElementsAtOffset(pos);
+ ICElement[] e = getSourceElementsAtOffset(pos);
if (e.length == 1 && e[0] == this) {
return CElement.NO_ELEMENTS;
}
- return e;
+ return e;
}
- public ICElement getElement(String name ) {
+ public ICElement getElement(String name) {
if (name == null || name.length() == 0) {
return null;
}
@@ -155,7 +166,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
for (int j = 0; j < names.length; ++j) {
if (current instanceof IParent) {
try {
- ICElement[] celements = ((IParent)current).getChildren();
+ ICElement[] celements = ((IParent) current).getChildren();
current = null;
for (int i = 0; i < celements.length; i++) {
if (names[j].equals(celements[i].getElementName())) {
@@ -163,7 +174,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
break;
}
}
- } catch (CModelException e) {
+ } catch (CModelException e) {
current = null;
}
} else {
@@ -179,11 +190,11 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
for (int i = 0; i < celements.length; i++) {
if (celements[i].getElementType() == ICElement.C_INCLUDE) {
if (name.equals(celements[i].getElementName())) {
- return (IInclude)celements[i];
+ return (IInclude) celements[i];
}
}
}
- } catch (CModelException e) {
+ } catch (CModelException e) {
}
return null;
}
@@ -196,7 +207,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
aList.add(celements[i]);
}
}
- return (IInclude[])aList.toArray(new IInclude[0]);
+ return (IInclude[]) aList.toArray(new IInclude[0]);
}
public IUsing getUsing(String name) {
@@ -205,12 +216,12 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
for (int i = 0; i < celements.length; i++) {
if (celements[i].getElementType() == ICElement.C_USING) {
if (name.equals(celements[i].getElementName())) {
- return (IUsing)celements[i];
+ return (IUsing) celements[i];
}
}
}
- } catch (CModelException e) {
- }
+ } catch (CModelException e) {
+ }
return null;
}
@@ -222,7 +233,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
aList.add(celements[i]);
}
}
- return (IUsing[])aList.toArray(new IUsing[0]);
+ return (IUsing[]) aList.toArray(new IUsing[0]);
}
public INamespace getNamespace(String name) {
@@ -231,7 +242,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
ICElement current = this;
for (int j = 0; j < names.length; ++j) {
if (current instanceof IParent) {
- ICElement[] celements = ((IParent)current).getChildren();
+ ICElement[] celements = ((IParent) current).getChildren();
current = null;
for (int i = 0; i < celements.length; i++) {
if (celements[i].getElementType() == ICElement.C_NAMESPACE) {
@@ -246,10 +257,10 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
}
}
if (current instanceof INamespace) {
- return (INamespace)current;
+ return (INamespace) current;
}
- } catch (CModelException e) {
- }
+ } catch (CModelException e) {
+ }
return null;
}
@@ -261,7 +272,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
aList.add(celements[i]);
}
}
- return (INamespace[])aList.toArray(new INamespace[0]);
+ return (INamespace[]) aList.toArray(new INamespace[0]);
}
public void setLocation(IPath loc) {
@@ -283,7 +294,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
public IFile getFile() {
IResource res = getResource();
if (res instanceof IFile) {
- return (IFile)res;
+ return (IFile) res;
}
return null;
}
@@ -315,7 +326,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
* @see org.eclipse.cdt.core.model.ISourceManipulation#rename(java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor)
*/
public void rename(String name, boolean force, IProgressMonitor monitor)
- throws CModelException {
+ throws CModelException {
getSourceManipulationInfo().rename(name, force, monitor);
}
@@ -334,7 +345,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
}
protected TranslationUnitInfo getTranslationUnitInfo() throws CModelException {
- return (TranslationUnitInfo)getElementInfo();
+ return (TranslationUnitInfo) getElementInfo();
}
protected SourceManipulationInfo getSourceManipulationInfo() {
@@ -344,21 +355,21 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
return sourceManipulationInfo;
}
- protected CElementInfo createElementInfo () {
+ protected CElementInfo createElementInfo() {
return new TranslationUnitInfo(this);
}
/**
* Returns true if this handle represents the same Java element
* as the given handle.
- *
+ *
* <p>Compilation units must also check working copy state;
- *
+ *
* @see Object#equals(java.lang.Object)
*/
public boolean equals(Object o) {
if (!(o instanceof ITranslationUnit)) return false;
- return super.equals(o) && !((ITranslationUnit)o).isWorkingCopy();
+ return super.equals(o) && !((ITranslationUnit) o).isWorkingCopy();
}
/* (non-Javadoc)
@@ -373,10 +384,10 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
// AND use the same buffer factory.
// Assuming there is a little set of buffer factories, then use a 2 level Map cache.
Map sharedWorkingCopies = CModelManager.getDefault().sharedWorkingCopies;
-
+
Map perFactoryWorkingCopies = (Map) sharedWorkingCopies.get(factory);
if (perFactoryWorkingCopies == null) return null;
- return (WorkingCopy)perFactoryWorkingCopies.get(this);
+ return (WorkingCopy) perFactoryWorkingCopies.get(this);
}
/**
@@ -384,25 +395,25 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
* @param newElements
* @param element
*/
- private void getNewElements(Map mapping, CElement element){
+ private void getNewElements(Map mapping, CElement element) {
Object info = null;
try {
info = element.getElementInfo();
} catch (CModelException e) {
}
- if(info != null){
- if(element instanceof IParent){
- ICElement[] children = ((CElementInfo)info).getChildren();
+ if (info != null) {
+ if (element instanceof IParent) {
+ ICElement[] children = ((CElementInfo) info).getChildren();
int size = children.length;
for (int i = 0; i < size; ++i) {
CElement child = (CElement) children[i];
- getNewElements(mapping, child);
- }
+ getNewElements(mapping, child);
+ }
}
}
- mapping.put(element, info);
+ mapping.put(element, info);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.model.Openable#buildStructure(org.eclipse.cdt.internal.core.model.OpenableInfo, org.eclipse.core.runtime.IProgressMonitor, java.util.Map, org.eclipse.core.resources.IResource)
*/
@@ -415,19 +426,19 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
CModelManager.getDefault().removeChildrenInfo(this);
// generate structure
- this.parse(newElements);
-
- ///////////////////////////////////////////////////////////////
-
+ this.parse(newElements);
+
+ // /////////////////////////////////////////////////////////////
+
if (isWorkingCopy()) {
ITranslationUnit original = ((IWorkingCopy)this).getOriginalElement();
// might be IResource.NULL_STAMP if original does not exist
IResource r = original.getResource();
- if (r != null && r instanceof IFile) {
+ if (r != null && r instanceof IFile) {
unitInfo.fTimestamp = ((IFile) r).getModificationStamp();
}
}
-
+
return unitInfo.isStructureKnown();
}
@@ -450,25 +461,25 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
throws CModelException {
return getSharedWorkingCopy(monitor, factory, null);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ITranslationUnit#getSharedWorkingCopy(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.cdt.internal.core.model.IBufferFactory, org.eclipse.cdt.core.model.IProblemRequestor)
*/
public IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor,IBufferFactory factory, IProblemRequestor requestor)
- throws CModelException {
-
+ throws CModelException {
+
// if factory is null, default factory must be used
if (factory == null) factory = BufferManager.getDefaultBufferManager();
CModelManager manager = CModelManager.getDefault();
-
+
// In order to be shared, working copies have to denote the same translation unit
// AND use the same buffer factory.
// Assuming there is a little set of buffer factories, then use a 2 level Map cache.
Map sharedWorkingCopies = manager.sharedWorkingCopies;
-
+
Map perFactoryWorkingCopies = (Map) sharedWorkingCopies.get(factory);
- if (perFactoryWorkingCopies == null){
+ if (perFactoryWorkingCopies == null) {
perFactoryWorkingCopies = new HashMap();
sharedWorkingCopies.put(factory, perFactoryWorkingCopies);
}
@@ -479,13 +490,13 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
}
CreateWorkingCopyOperation op = new CreateWorkingCopyOperation(this, perFactoryWorkingCopies, factory, requestor);
op.runOperation(monitor);
- return (IWorkingCopy)op.getResultElements()[0];
+ return (IWorkingCopy) op.getResultElements()[0];
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ITranslationUnit#getWorkingCopy()
*/
- public IWorkingCopy getWorkingCopy()throws CModelException{
+ public IWorkingCopy getWorkingCopy() throws CModelException {
return this.getWorkingCopy(null, null);
}
@@ -512,9 +523,9 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
protected void openParent(Object childInfo, Map newElements, IProgressMonitor pm) throws CModelException {
try {
super.openParent(childInfo, newElements, pm);
- } catch(CModelException e){
+ } catch (CModelException e) {
// allow parent to not exist for working copies defined outside
- if (!isWorkingCopy()){
+ if (!isWorkingCopy()) {
throw e;
}
}
@@ -546,14 +557,14 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
*/
protected IBuffer openBuffer(IProgressMonitor pm) throws CModelException {
- // create buffer - translation units only use default buffer factory
- BufferManager bufManager = getBufferManager();
+ // create buffer - translation units only use default buffer factory
+ BufferManager bufManager = getBufferManager();
IBuffer buffer = getBufferFactory().createBuffer(this);
- if (buffer == null)
+ if (buffer == null)
return null;
-
+
// set the buffer source
- if (buffer.getCharacters() == null){
+ if (buffer.getCharacters() == null) {
IResource file = this.getResource();
if (file != null && file.getType() == IResource.FILE) {
buffer.setContents(Util.getResourceContentsAsCharArray((IFile)file));
@@ -562,10 +573,10 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
// add buffer to buffer cache
bufManager.addBuffer(buffer);
-
+
// listen to buffer changes
buffer.addBufferChangedListener(this);
-
+
return buffer;
}
@@ -601,9 +612,9 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
} catch (Exception e) {
// use the debug log for this exception.
Util.debugLog( "Exception in CModelBuilder", IDebugLogConstants.MODEL); //$NON-NLS-1$
- }
+ }
}
-
+
private void parseUsingContributedModelBuilder(IContributedModelBuilder mb, boolean quickParseMode) {
try {
mb.parse(quickParseMode);
@@ -612,7 +623,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
Util.debugLog( "Exception in contributed model builder", IDebugLogConstants.MODEL); //$NON-NLS-1$
}
}
-
+
public IProblemRequestor getProblemRequestor() {
return problemRequestor;
}
@@ -633,7 +644,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
public boolean isSourceUnit() {
if (isHeaderUnit())
return false;
-
+
return (
CCorePlugin.CONTENT_TYPE_CSOURCE.equals(contentTypeId)
|| CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(contentTypeId)
@@ -668,7 +679,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
public boolean isASMLanguage() {
return CCorePlugin.CONTENT_TYPE_ASMSOURCE.equals(contentTypeId);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ICElement#exists()
@@ -682,26 +693,26 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
public ILanguage getLanguage() throws CoreException {
if (language == null) {
- language= computeLanguage(contentTypeId);
-
+ language = computeLanguage(contentTypeId);
+
// Special magic for C/C++ header files
if (language == null && isHeaderUnit()) {
if (CCorePlugin.CONTENT_TYPE_CHEADER.equals(contentTypeId)) {
- language= computeLanguage(CCorePlugin.CONTENT_TYPE_CSOURCE);
+ language = computeLanguage(CCorePlugin.CONTENT_TYPE_CSOURCE);
}
else if (CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(contentTypeId)) {
- language= computeLanguage(CCorePlugin.CONTENT_TYPE_CXXSOURCE);
+ language = computeLanguage(CCorePlugin.CONTENT_TYPE_CXXSOURCE);
}
}
}
-
+
return language;
}
-
+
private ILanguage computeLanguage(String contentTypeId) throws CoreException {
// Look for the language extension registered against the
// content type string
- IContentTypeManager manager = Platform.getContentTypeManager();
+ IContentTypeManager manager = Platform.getContentTypeManager();
IContentType contentType = manager.getContentType(contentTypeId);
if (contentType != null) {
return LanguageManager.getInstance().getLanguage(contentType);
@@ -744,4 +755,69 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
} catch (CModelException e) {
}
}
+
+ public IASTTranslationUnit getAST() throws CoreException {
+ return getAST(null, 0);
+ }
+
+ public IASTTranslationUnit getAST(IIndex index, int style) throws CoreException {
+ ICodeReaderFactory codeReaderFactory;
+ if (index != null && (style & (ITranslationUnit.AST_SKIP_INDEXED_HEADERS | ITranslationUnit.AST_SKIP_ALL_HEADERS)) != 0) {
+ codeReaderFactory= new IndexBasedCodeReaderFactory(index);
+ }
+ else {
+ codeReaderFactory = SavedCodeReaderFactory.getInstance();
+ }
+
+ IScannerInfo scanInfo = getScannerInfo( (style & ITranslationUnit.AST_SKIP_IF_NO_BUILD_INFO) == 0);
+ if (scanInfo == null) {
+ return null;
+ }
+
+ CodeReader reader;
+ reader = getCodeReader();
+
+ ILanguage language= getLanguage();
+ if (language != null) {
+ return language.getASTTranslationUnit(reader, scanInfo, codeReaderFactory, index);
+ }
+ return null;
+ }
+
+ public CodeReader getCodeReader() {
+ CodeReader reader;
+ IPath location= getLocation();
+ if (isWorkingCopy() || location == null) {
+ if (location == null) {
+ reader= new CodeReader(getContents());
+ }
+ else {
+ reader= new CodeReader(location.toOSString(), getContents());
+ }
+ }
+ else {
+ reader= ParserUtil.createReader(location.toOSString(), null);
+ }
+ return reader;
+ }
+
+ public IScannerInfo getScannerInfo(boolean force) {
+ IResource resource = getResource();
+ ICProject project = getCProject();
+ IProject rproject = project.getProject();
+
+ IScannerInfoProvider provider = CCorePlugin.getDefault()
+ .getScannerInfoProvider(rproject);
+ if (provider != null) {
+ IResource infoResource = resource != null ? resource : rproject;
+ IScannerInfo scanInfo = provider
+ .getScannerInformation(infoResource);
+ if (scanInfo != null)
+ return scanInfo;
+ }
+ if (force) {
+ return new ScannerInfo();
+ }
+ return null;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ILinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ILinkage.java
new file mode 100644
index 00000000000..5312756e578
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ILinkage.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.core.dom;
+
+/**
+ * Represents a linkage in the AST or the index.
+ * <p>
+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
+ * part of a work in progress. There is no guarantee that this API will
+ * work or that it will remain the same. Please do not use this API without
+ * consulting with the CDT team.
+ * </p>
+ * @since 4.0
+ */
+public interface ILinkage {
+ final static String NO_LINKAGE_ID= "none"; //$NON-NLS-1$
+ final static String C_LINKAGE_ID= "C"; //$NON-NLS-1$
+ final static String CPP_LINKAGE_ID= "C++"; //$NON-NLS-1$
+ final static String FORTRAN_LINKAGE_ID= "Fortran"; //$NON-NLS-1$
+
+ String getID();
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IName.java
index 3b340233244..60de3bccb78 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IName.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IName.java
@@ -13,16 +13,19 @@ package org.eclipse.cdt.core.dom;
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
import org.eclipse.cdt.core.dom.ast.IASTNode;
-import org.eclipse.cdt.core.dom.ast.IBinding;
/**
- * Common interface for names in the index and the AST
+ * Common interface for names in the index and the AST.
+ * <p> This interface is not intended to be implemented by clients. </p>
+ * <p>
+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
+ * part of a work in progress. There is no guarantee that this API will
+ * work or that it will remain the same. Please do not use this API without
+ * consulting with the CDT team.
+ * </p>
* @since 4.0
*/
public interface IName {
-
- public static final IName[] EMPTY_NAME_ARRAY = new IName[0];
-
/**
* Return a char array representation of the name.
*
@@ -31,13 +34,6 @@ public interface IName {
public char[] toCharArray();
/**
- * Resolve the semantic object this name is referring to.
- *
- * @return <code>IBinding</code> binding
- */
- public IBinding resolveBinding();
-
- /**
* Is this name being used in the AST as the introduction of a declaration?
* @return boolean
*/
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOM.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOM.java
index 50b3e4af308..6adfc229efb 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOM.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOM.java
@@ -11,13 +11,7 @@
*******************************************************************************/
package org.eclipse.cdt.core.dom;
-import java.util.regex.Pattern;
-
-import org.eclipse.cdt.core.dom.ast.IBinding;
-import org.eclipse.cdt.core.model.IWorkingCopy;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
/**
* This is the reader interface to the PDOM. It is used by general
@@ -25,74 +19,4 @@ import org.eclipse.core.runtime.IProgressMonitor;
*
* @author Doug Schaefer
*/
-public interface IPDOM extends IAdaptable {
-
- /**
- * Find all the bindings whose names that match the pattern.
- *
- * @param pattern
- * @return
- * @throws CoreException
- */
- public IBinding[] findBindings(Pattern pattern, IProgressMonitor monitor) throws CoreException;
-
- /**
- * Find all bindings whose qualified names match the array of patterns.
- *
- * @param pattern
- * @return
- * @throws CoreException
- */
- public IBinding[] findBindings(Pattern[] pattern, IProgressMonitor monitor) throws CoreException;
-
- /**
- * Recursively visit the nodes in this PDOM using the given visitor.
- *
- * @param visitor
- * @throws CoreException
- */
- public void accept(IPDOMVisitor visitor) throws CoreException;
-
- /**
- * Clear all the contents of this PDOM.
- *
- * @throws CoreException
- */
- public void clear() throws CoreException;
-
- /**
- * Looks to see if anything has been stored in this PDOM.
- *
- * @return is the PDOM empty
- * @throws CoreException
- */
- public boolean isEmpty() throws CoreException;
-
- public ICodeReaderFactory getCodeReaderFactory();
-
- public ICodeReaderFactory getCodeReaderFactory(IWorkingCopy root);
-
- /**
- * When accessing a PDOM and working with its objects it's neccessary to hold
- * a read-lock on the PDOM. Make sure to release it: <pre>
- * pdom.acquireReadLock();
- * try {
- * // do what you have to do.
- * }
- * finally {
- * pdom.releaseReadLock();
- * } </pre>
- * @throws InterruptedException
- * @since 4.0
- */
- public void acquireReadLock() throws InterruptedException;
- public void releaseReadLock();
-
- /**
- * You must not hold any other lock on any PDOM when acquiring a write lock.
- * Failing to do so may lead to dead-locks.
- */
- public void acquireWriteLock() throws InterruptedException;
- public void releaseWriteLock();
-
-}
+public interface IPDOM extends IAdaptable {}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOMResolver.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOMResolver.java
deleted file mode 100644
index 66ab7f92ca7..00000000000
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOMResolver.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.core.dom;
-
-import org.eclipse.cdt.core.dom.ast.IASTName;
-import org.eclipse.cdt.core.dom.ast.IBinding;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-
-/**
- * This is the interface used by the DOM to help with resolving
- * bindings amongst other things.
- *
- * @author Doug Schaefer
- */
-public interface IPDOMResolver extends IAdaptable {
-
- public IBinding resolveBinding(IASTName name);
-
- public IName[] getDeclarations(IBinding binding) throws CoreException;
-
- public IName[] getDefinitions(IBinding binding) throws CoreException;
-
- public IName[] getReferences(IBinding binding) throws CoreException;
-
-}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTName.java
index 48b46b4054d..4e727d13934 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTName.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTName.java
@@ -11,6 +11,7 @@
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.IName;
/**
@@ -43,10 +44,22 @@ public interface IASTName extends IASTNode, IName {
public void setBinding( IBinding binding );
/**
+ * Resolve the semantic object this name is referring to.
+ *
+ * @return <code>IBinding</code> binding
+ */
+ public IBinding resolveBinding();
+
+ /**
* Return a list of bindings in the scope of the name that have the name as
* a prefix.
*
* @return <code>IBinding []</code> bindings that start with this name
*/
public IBinding[] resolvePrefix();
+
+ /**
+ * Determines the current linkage in which the name has to be resolved.
+ */
+ public ILinkage getLinkage();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java
index 3582f16abe8..bee233fde39 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java
@@ -12,7 +12,7 @@
package org.eclipse.cdt.core.dom.ast;
import org.eclipse.cdt.core.dom.IName;
-import org.eclipse.cdt.core.dom.IPDOM;
+import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.parser.ParserLanguage;
@@ -219,14 +219,14 @@ public interface IASTTranslationUnit extends IASTNode {
*
* @return the Index for this translation unit
*/
- public IPDOM getIndex();
+ public IIndex getIndex();
/**
* Set the Index to be used for this translation unit.
*
* @param index
*/
- public void setIndex(IPDOM index);
+ public void setIndex(IIndex index);
/**
* Returns the language for this translation unit.
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBinding.java
index 5baf4fc1e18..be176e1b0cb 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBinding.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBinding.java
@@ -7,12 +7,16 @@
*
* Contributors:
* IBM - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
+import org.eclipse.cdt.core.dom.ILinkage;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
/**
+ * Represents the semantics of a name found in the AST or the index.
* @author Doug Schaefer
*/
public interface IBinding extends IAdaptable {
@@ -37,5 +41,10 @@ public interface IBinding extends IAdaptable {
* @return the scope of this name
*/
public IScope getScope() throws DOMException;
+
+ /**
+ * Every binding has a linkage.
+ */
+ public ILinkage getLinkage() throws CoreException;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IScope.java
index 1120d9dc010..7e78b9825c4 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IScope.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IScope.java
@@ -45,16 +45,11 @@ public interface IScope {
* @return List of IBinding
*/
public IBinding[] find(String name) throws DOMException;
-
- /**
- * Return the physical IASTNode that this scope was created for
- * @return
- */
- public IASTNode getPhysicalNode() throws DOMException;
-
+
/**
* The IScope serves as a mechanism for caching IASTNames and bindings to
* speed up resolution.
+ * mstodo more work: remove the ast-specific methods.
*/
/**
@@ -97,24 +92,4 @@ public interface IScope {
* @throws DOMException
*/
public void addBinding(IBinding binding) throws DOMException;
-
- /**
- * Set whether or not all the names in this scope have been cached
- *
- * @param b
- */
- public void setFullyCached(boolean b) throws DOMException;
-
- /**
- * whether or not this scope's cache contains all the names
- *
- * @return
- */
- public boolean isFullyCached() throws DOMException;
-
- /**
- * clear the name cache in this scope
- * @throws DOMException
- */
- public void flushCache() throws DOMException;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java
index 4a705e97420..9f34a1864af 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.gnu.c;
@@ -22,9 +23,10 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.model.AbstractLanguage;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IContributedModelBuilder;
-import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.core.parser.CodeReader;
@@ -36,28 +38,23 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ParserMode;
import org.eclipse.cdt.core.parser.ParserUtil;
import org.eclipse.cdt.core.parser.ScannerInfo;
-import org.eclipse.cdt.internal.core.dom.SavedCodeReaderFactory;
import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser;
import org.eclipse.cdt.internal.core.dom.parser.c.GCCParserExtensionConfiguration;
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
import org.eclipse.cdt.internal.core.parser.scanner2.GCCScannerExtensionConfiguration;
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
-import org.eclipse.cdt.internal.core.pdom.PDOM;
-import org.eclipse.cdt.internal.core.pdom.PDOMCodeReaderFactory;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCLinkageFactory;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.PlatformObject;
/**
* @author Doug Schaefer
*
*/
-public class GCCLanguage extends PlatformObject implements ILanguage {
+public class GCCLanguage extends AbstractLanguage {
protected static final GCCScannerExtensionConfiguration C_GNU_SCANNER_EXTENSION = new GCCScannerExtensionConfiguration();
// Must match the id in the extension
@@ -80,53 +77,9 @@ public class GCCLanguage extends PlatformObject implements ILanguage {
return super.getAdapter(adapter);
}
- public IASTTranslationUnit getASTTranslationUnit(ITranslationUnit file, int style) throws CoreException {
- ICodeReaderFactory fileCreator;
- if ((style & (ILanguage.AST_SKIP_INDEXED_HEADERS | ILanguage.AST_SKIP_ALL_HEADERS)) != 0) {
- PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(file.getCProject()).getAdapter(PDOM.class);
- fileCreator = new PDOMCodeReaderFactory(pdom);
- } else
- fileCreator = SavedCodeReaderFactory.getInstance();
-
- return getASTTranslationUnit(file, fileCreator, style);
- }
-
- public IASTTranslationUnit getASTTranslationUnit(
- ITranslationUnit file,
- ICodeReaderFactory codeReaderFactory,
- int style) throws CoreException {
- IResource resource = file.getResource();
- ICProject project = file.getCProject();
- IProject rproject = project.getProject();
-
- IScannerInfo scanInfo = null;
- IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(rproject);
- if (provider != null){
- IResource infoResource = resource != null ? resource : rproject;
- IScannerInfo buildScanInfo = provider.getScannerInformation(infoResource);
- if (buildScanInfo != null)
- scanInfo = buildScanInfo;
- else if ((style & ILanguage.AST_SKIP_IF_NO_BUILD_INFO) != 0)
- return null;
- else
- scanInfo = new ScannerInfo();
- }
-
- CodeReader reader;
- IFile rfile = (IFile)file.getResource();
- String path = rfile != null ? rfile.getLocation().toOSString() : file.getPath().toOSString();
- if (file instanceof IWorkingCopy) {
- // get the working copy contents
- reader = new CodeReader(path, file.getContents());
- } else {
- reader = codeReaderFactory.createCodeReaderForTranslationUnit(path);
- if (reader == null)
- return null;
- }
-
- IScannerExtensionConfiguration scannerExtensionConfiguration
- = C_GNU_SCANNER_EXTENSION;
-
+ public IASTTranslationUnit getASTTranslationUnit(CodeReader reader,
+ IScannerInfo scanInfo, ICodeReaderFactory codeReaderFactory, IIndex index) throws CoreException {
+ IScannerExtensionConfiguration scannerExtensionConfiguration= C_GNU_SCANNER_EXTENSION;
IScanner scanner = new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE,
ParserLanguage.C, ParserFactory.createDefaultLogService(), scannerExtensionConfiguration, codeReaderFactory);
//assume GCC
@@ -135,8 +88,8 @@ public class GCCLanguage extends PlatformObject implements ILanguage {
// Parse
IASTTranslationUnit ast = parser.parse();
- if ((style & AST_USE_INDEX) != 0)
- ast.setIndex(CCorePlugin.getPDOMManager().getPDOM(file.getCProject()));
+ // mstodo isn't that too late to set the index?
+ ast.setIndex(index);
return ast;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/GPPLanguage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/GPPLanguage.java
index b011274c143..6f6bcdb81a6 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/GPPLanguage.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/GPPLanguage.java
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.gnu.cpp;
@@ -22,9 +23,10 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.model.AbstractLanguage;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IContributedModelBuilder;
-import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.core.parser.CodeReader;
@@ -36,28 +38,23 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ParserMode;
import org.eclipse.cdt.core.parser.ParserUtil;
import org.eclipse.cdt.core.parser.ScannerInfo;
-import org.eclipse.cdt.internal.core.dom.SavedCodeReaderFactory;
import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser;
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPParserExtensionConfiguration;
import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
import org.eclipse.cdt.internal.core.parser.scanner2.GPPScannerExtensionConfiguration;
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
-import org.eclipse.cdt.internal.core.pdom.PDOM;
-import org.eclipse.cdt.internal.core.pdom.PDOMCodeReaderFactory;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPLinkageFactory;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.PlatformObject;
/**
* @author Doug Schaefer
*
*/
-public class GPPLanguage extends PlatformObject implements ILanguage {
+public class GPPLanguage extends AbstractLanguage {
protected static final GPPScannerExtensionConfiguration CPP_GNU_SCANNER_EXTENSION = new GPPScannerExtensionConfiguration();
public static final String ID = CCorePlugin.PLUGIN_ID + ".g++"; //$NON-NLS-1$
@@ -79,53 +76,10 @@ public class GPPLanguage extends PlatformObject implements ILanguage {
return super.getAdapter(adapter);
}
- public IASTTranslationUnit getASTTranslationUnit(ITranslationUnit file, int style) throws CoreException {
- ICodeReaderFactory fileCreator;
- if ((style & (ILanguage.AST_SKIP_INDEXED_HEADERS | ILanguage.AST_SKIP_ALL_HEADERS)) != 0) {
- PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(file.getCProject()).getAdapter(PDOM.class);
- fileCreator = new PDOMCodeReaderFactory(pdom);
- } else
- fileCreator = SavedCodeReaderFactory.getInstance();
-
- return getASTTranslationUnit(file, fileCreator, style);
- }
- public IASTTranslationUnit getASTTranslationUnit(
- ITranslationUnit file,
- ICodeReaderFactory codeReaderFactory,
- int style) throws CoreException {
- IResource resource = file.getResource();
- ICProject project = file.getCProject();
- IProject rproject = project.getProject();
-
- IScannerInfo scanInfo = null;
- IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(rproject);
- if (provider != null){
- IResource infoResource = resource != null ? resource : rproject;
- IScannerInfo buildScanInfo = provider.getScannerInformation(infoResource);
- if (buildScanInfo != null)
- scanInfo = buildScanInfo;
- else if ((style & ILanguage.AST_SKIP_IF_NO_BUILD_INFO) != 0)
- return null;
- else
- scanInfo = new ScannerInfo();
- }
-
- CodeReader reader;
- IFile rfile = (IFile)file.getResource();
- String path = rfile != null ? rfile.getLocation().toOSString() : file.getPath().toOSString();
- if (file instanceof IWorkingCopy) {
- // get the working copy contents
- reader = new CodeReader(path, file.getContents());
- } else {
- reader = codeReaderFactory.createCodeReaderForTranslationUnit(path);
- if (reader == null)
- return null;
- }
-
- IScannerExtensionConfiguration scannerExtensionConfiguration
- = CPP_GNU_SCANNER_EXTENSION;
-
+ public IASTTranslationUnit getASTTranslationUnit(CodeReader reader, IScannerInfo scanInfo,
+ ICodeReaderFactory codeReaderFactory, IIndex index) throws CoreException {
+ IScannerExtensionConfiguration scannerExtensionConfiguration= CPP_GNU_SCANNER_EXTENSION;
IScanner scanner = new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE,
ParserLanguage.CPP, ParserFactory.createDefaultLogService(), scannerExtensionConfiguration, codeReaderFactory);
//assume GCC
@@ -133,9 +87,9 @@ public class GPPLanguage extends PlatformObject implements ILanguage {
new GPPParserExtensionConfiguration() );
// Parse
- IASTTranslationUnit ast = parser.parse();
- if ((style & AST_USE_INDEX) != 0)
- ast.setIndex(CCorePlugin.getPDOMManager().getPDOM(file.getCProject()));
+ IASTTranslationUnit ast= parser.parse();
+ // mstodo isn't that too late to set the index?
+ ast.setIndex(index);
return ast;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndex.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndex.java
new file mode 100644
index 00000000000..22bab17a2b2
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndex.java
@@ -0,0 +1,278 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.core.index;
+
+import java.util.regex.Pattern;
+
+import org.eclipse.cdt.core.dom.IName;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * Interface for accessing the index for one or more projects.
+ *
+ * <p>
+ * This interface is not intended to be implemented by clients.
+ * </p>
+ * <p>
+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
+ * part of a work in progress. There is no guarantee that this API will work or
+ * that it will remain the same. Please do not use this API without consulting
+ * with the CDT team.
+ * </p>
+ *
+ * @since 4.0
+ */
+public interface IIndex {
+ /**
+ * Constant to specify infinite depth.
+ * @see #findIncludedBy(IIndexFile, int)
+ * @see #findIncludes(IIndexFile, int)
+ */
+ final int DEPTH_INFINITE = -1;
+
+ /**
+ * Constant to find direct includes, only.
+ * @see #findIncludedBy(IIndexFile, int)
+ * @see #findIncludes(IIndexFile, int)
+ */
+ final int DEPTH_ZERO = 0;
+
+ /**
+ * Constant to search for declarations. This does not include definitions.
+ */
+ final int FIND_DECLARATIONS = 0x1;
+ /**
+ * Constant to search for definitions. This does not include declarations.
+ */
+ final int FIND_DEFINITIONS = 0x2;
+ /**
+ * Constant to search for all declarations including definitons.
+ */
+ final int FIND_REFERENCES = 0x4;
+ /**
+ * Constant to search for references. This does not include declarations or definitions.
+ */
+ final int FIND_DECLARATIONS_DEFINITIONS = FIND_DECLARATIONS | FIND_DEFINITIONS;
+ /**
+ * Constant to search for all occurrences of a binding. This includes declarations, definitons and references.
+ */
+ final int FIND_ALL_OCCURENCES = FIND_DECLARATIONS | FIND_DEFINITIONS | FIND_REFERENCES;
+
+ /**
+ * Before making calls to an index you have to obtain a lock. The objects
+ * returned by an index become invalid as soon as the indexer writes to the
+ * index. You may obtain nested read locks. Make sure you release the lock.
+ * @see #getLastWriteAccess()
+ * <pre>
+ * index.acquireReadLock();
+ * try {
+ * ....
+ * }
+ * finally {
+ * index.releaseReadLock();
+ * }
+ * </pre>
+ */
+ public void acquireReadLock() throws InterruptedException;
+
+ /**
+ * Any lock obtained by {@link #acquireReadLock()} must be released.
+ */
+ public void releaseReadLock();
+
+ /**
+ * Returns a timestamp of when the index was last written to. This can
+ * be used to figure out whether information read from the index is
+ * still reliable or not.
+ *
+ * <pre>
+ * long timestamp;
+ * IBinding binding= null;
+ * index.acquireReadLock();
+ * try {
+ * timestamp= index.getLastWriteAccess();
+ * binding= index.findBinding(...);
+ * }
+ * finally {
+ * index.releaseReadLock();
+ * }
+ * ...
+ * index.acqureReadLock();
+ * try {
+ * if (index.getLastWriteAccess() != timestamp) {
+ * // don't use binding, it's not valid anymore
+ * binding= index.findBinding(...);
+ * }
+ * String name= binding.getName();
+ * ...
+ * }
+ * finally {
+ * index.releaseReadLock();
+ * }
+ */
+ public long getLastWriteAccess();
+
+ /**
+ * Looks for a file with the given location. May return <code>null</code>.
+ * @param location absolute path of the file location
+ * @return the file in the index or <code>null</code>
+ * @throws CoreException
+ */
+ public IIndexFile getFile(IPath location) throws CoreException;
+
+ /**
+ * Looks for include relations originated by the given file.
+ * This is the same as <pre> findIncludes(file, DEPTH_ZERO); </pre>
+ * @param file the file containing the include directives
+ * @return an array of include relations
+ * @throws CoreException
+ */
+ public IIndexInclude[] findIncludes(IIndexFile file) throws CoreException;
+
+ /**
+ * Looks for include relations pointing to the given file.
+ * This is the same as <pre> findIncludedBy(file, DEPTH_ZERO); </pre>
+ * @param file the file included by the directives to be found
+ * @return an array of include relations
+ * @throws CoreException
+ */
+ public IIndexInclude[] findIncludedBy(IIndexFile file) throws CoreException;
+
+ /**
+ * Looks recursively for include relations originated by the given file.
+ * @param file the file containing the include directives
+ * @param depth depth to which includes are followed, should be one of
+ * {@link #DEPTH_ZERO} or {@link #DEPTH_INFINITE}
+ * @return an array of include relations
+ * @throws CoreException
+ */
+ public IIndexInclude[] findIncludes(IIndexFile file, int depth) throws CoreException;
+
+ /**
+ * Looks recursively for include relations pointing to the given file.
+ * @param file the file the include directives point to
+ * @param depth depth to which includes are followed, should be one of
+ * {@link #DEPTH_ZERO} or {@link #DEPTH_INFINITE}
+ * @return an array of include relations
+ * @throws CoreException
+ */
+ public IIndexInclude[] findIncludedBy(IIndexFile file, int depth) throws CoreException;
+
+ /**
+ * Resolves the file that is included by the given include directive. May return <code>null</code>
+ * in case the file cannot be found. This is usually more efficient than using:
+ * <pre>
+ * getFile(include.getIncludesLocation())
+ * </pre>
+ * @param include
+ * @return the file included or <code>null</code>.
+ * @throws CoreException
+ * @since 4.0
+ */
+ public IIndexFile resolveInclude(IIndexInclude include) throws CoreException;
+
+ /**
+ * Looks for a binding for the given ICElement. May return <code>null</code>.
+ * @param element an element a binding is searched for
+ * @return a binding for the element or <code>null</code>
+ * @throws CoreException
+ */
+ public IIndexBinding findBinding(ICElement element) throws CoreException;
+
+ /**
+ * Searches for the binding of a name. The name may be originated by
+ * an AST or by a search in an index. May return <code>null</code>.
+ * @param name a name to find the binding for
+ * @return the binding or <code>null</code>
+ * @throws CoreException
+ */
+ public IIndexBinding findBinding(IName name) throws CoreException;
+
+ /**
+ * Searches for all bindings with simple names that match the given pattern. In case a binding exists
+ * in multiple projects, no duplicate bindings are returned.
+ * This is fully equivalent to
+ * <pre>
+ * findBindings(new Pattern[]{pattern}, isFullyQualified, filter, monitor);
+ * </pre>
+ * @param pattern the pattern the name of the binding has to match.
+ * @param isFullyQualified if <code>true</code>, binding must be in global scope
+ * @param filter a filter that allows for skipping parts of the index
+ * @param monitor a monitor to report progress
+ * @return an array of bindings matching the pattern
+ * @throws CoreException
+ */
+ public IIndexBinding[] findBindings(Pattern pattern, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException;
+
+ /**
+ * Searches for all bindings with qualified names that seen as an array of simple names match the given array
+ * of patterns. In case a binding exists in multiple projects, no duplicate bindings are returned.
+ * You can search with an array of patterns that specifies a partial qualification only.
+ * @param patterns an array of patterns the names of the qualified name of the bindings have to match.
+ * @param isFullyQualified if <code>true</code>, the array of pattern specifies the fully qualified name
+ * @param filter a filter that allows for skipping parts of the index
+ * @param monitor a monitor to report progress
+ * @return an array of bindings matching the pattern
+ * @throws CoreException
+ */
+ public IIndexBinding[] findBindings(Pattern[] patterns, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException;
+
+ /**
+ * Searches for all names that resolve to the given binding. You can limit the result to references, declarations
+ * or definitions, or a combination of those.
+ * @param binding a binding for which names are searched for
+ * @param flags a combination of {@link #FIND_DECLARATIONS}, {@link #FIND_DEFINITIONS} and {@link #FIND_REFERENCES}
+ * @return an array of names
+ * @throws CoreException
+ */
+ public IIndexName[] findNames(IBinding binding, int flags) throws CoreException;
+
+ /**
+ * Searches for all references that resolve to the given binding.
+ * This is fully equivalent to
+ * <pre>
+ * findNames(binding, IIndex.FIND_REFERENCES);
+ * </pre>
+ * @param binding a binding for which references are searched for
+ * @return an array of names
+ * @throws CoreException
+ */
+ public IIndexName[] findReferences(IBinding binding) throws CoreException;
+
+ /**
+ * Searches for all declarations and definitions that resolve to the given binding.
+ * This is fully equivalent to
+ * <pre>
+ * findNames(binding, IIndex.FIND_DECLARATIONS_DEFINITIONS);
+ * </pre>
+ * @param binding a binding for which declarations are searched for
+ * @return an array of names
+ * @throws CoreException
+ */
+ public IIndexName[] findDeclarations(IBinding binding) throws CoreException;
+
+ /**
+ * Searches for all definitions that resolve to the given binding.
+ * This is fully equivalent to
+ * <pre>
+ * findNames(binding, IIndex.FIND_DEFINITIONS);
+ * </pre>
+ * @param binding a binding for which declarations are searched for
+ * @return an array of names
+ * @throws CoreException
+ */
+ public IIndexName[] findDefinitions(IBinding binding) throws CoreException;
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexBinding.java
new file mode 100644
index 00000000000..dabbbef505a
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexBinding.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.core.index;
+
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * Represents the semantics of a name in the index.
+ *
+ * <p>
+ * This interface is not intended to be implemented by clients.
+ * </p>
+ * <p>
+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
+ * part of a work in progress. There is no guarantee that this API will work or
+ * that it will remain the same. Please do not use this API without consulting
+ * with the CDT team.
+ * </p>
+ *
+ * @since 4.0
+ */
+public interface IIndexBinding extends IBinding {
+ /**
+ * Returns the enclosing binding. May return <code>null</code>. To give an example, for a member function
+ * the parent binding would be the class defining the member.
+ * @throws CoreException
+ */
+ IIndexBinding getParentBinding() throws CoreException;
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexFile.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexFile.java
new file mode 100644
index 00000000000..925a0ff6f96
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexFile.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.core.index;
+
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * Represents a file that has been indexed.
+ *
+ * <p>
+ * This interface is not intended to be implemented by clients.
+ * </p>
+ * <p>
+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
+ * part of a work in progress. There is no guarantee that this API will work or
+ * that it will remain the same. Please do not use this API without consulting
+ * with the CDT team.
+ * </p>
+ *
+ * @since 4.0
+ */
+public interface IIndexFile {
+
+ /**
+ * Returns the absolute path of the location of the file.
+ * @return the absolute path of the location of the file
+ * @throws CoreException
+ */
+ String getLocation() throws CoreException;
+
+ /**
+ * Returns all includes found in this file.
+ * @return an array of all includes found in this file
+ * @throws CoreException
+ */
+ IIndexInclude[] getIncludes() throws CoreException;
+
+ /**
+ * Returns all macros defined in this file.
+ * @return an array of macros found in this file
+ * @throws CoreException
+ */
+ IIndexMacro[] getMacros() throws CoreException;
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexInclude.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexInclude.java
new file mode 100644
index 00000000000..6b1381c5fca
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexInclude.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.core.index;
+
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * Interface for an include directive stored in the index.
+ * <p>
+ * This interface is not intended to be implemented by clients.
+ * </p>
+ * <p>
+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
+ * part of a work in progress. There is no guarantee that this API will work or
+ * that it will remain the same. Please do not use this API without consulting
+ * with the CDT team.
+ * </p>
+ *
+ * @since 4.0
+ */
+public interface IIndexInclude {
+ IIndexInclude[] EMPTY_INCLUDES_ARRAY = new IIndexInclude[0];
+
+ /**
+ * Returns the file that contains this directive.
+ * @return the file performing the include
+ * @throws CoreException
+ */
+ IIndexFile getIncludedBy() throws CoreException;
+
+ /**
+ * Returns the absolute path of the location of the file that contains this directive.
+ * @return the absolute path of the location of the file performing the include
+ * @throws CoreException
+ */
+ String getIncludedByLocation() throws CoreException;
+
+ /**
+ * Returns the absolute path of the location of the file that is included by this directive.
+ * @return the absolute path of the location of the file that is included by this directive
+ * @throws CoreException
+ */
+ String getIncludesLocation() throws CoreException;
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexLinkage.java
new file mode 100644
index 00000000000..b12cfad2d32
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexLinkage.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.core.index;
+
+import org.eclipse.cdt.core.dom.ILinkage;
+
+/**
+ * Represents the linkage of a name in the index.
+ * <p>
+ * This interface is not intended to be implemented by clients.
+ * </p>
+ * <p>
+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
+ * part of a work in progress. There is no guarantee that this API will work or
+ * that it will remain the same. Please do not use this API without consulting
+ * with the CDT team.
+ * </p>
+ *
+ * @since 4.0
+ */
+public interface IIndexLinkage extends ILinkage {
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexMacro.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexMacro.java
new file mode 100644
index 00000000000..fc1f7336468
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexMacro.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.core.index;
+
+import org.eclipse.cdt.core.parser.IMacro;
+
+/**
+ * Represents a macro stored in the index.
+ * <p>
+ * This interface is not intended to be implemented by clients.
+ * </p>
+ * <p>
+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
+ * part of a work in progress. There is no guarantee that this API will work or
+ * that it will remain the same. Please do not use this API without consulting
+ * with the CDT team.
+ * </p>
+ *
+ * @since 4.0
+ */
+public interface IIndexMacro extends IMacro {
+
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexManager.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexManager.java
new file mode 100644
index 00000000000..1b9558a0e2a
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexManager.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.core.index;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * Starting point for working with the index. The manager can be obtained via
+ * {@link CCorePlugin#getIndexManager()}.
+ * <p>
+ * This interface is not intended to be implemented by clients.
+ * </p>
+ * <p>
+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
+ * part of a work in progress. There is no guarantee that this API will work or
+ * that it will remain the same. Please do not use this API without consulting
+ * with the CDT team.
+ * </p>
+ *
+ * @since 4.0
+ */
+public interface IIndexManager {
+ public final static int ADD_DEPENDENCIES = 0x1;
+ public final static int ADD_DEPENDENT = 0x2;
+
+ /**
+ * Returns the index for the given project.
+ * @param project the project to get the index for
+ * @return an index for the project
+ * @throws CoreException
+ */
+ IIndex getIndex(ICProject project) throws CoreException;
+
+ /**
+ * Returns the index for the given projects.
+ * @param projects the projects to get the index for
+ * @return an index for the projects
+ * @throws CoreException
+ */
+ IIndex getIndex(ICProject[] projects) throws CoreException;
+
+ /**
+ * Returns the index for the given project. You can specify to add dependencies or dependent projects.
+ * @param project the project to get the index for
+ * @param options <code>0</code> or a combination of {@link #ADD_DEPENDENCIES} and {@link #ADD_DEPENDENT}.
+ * @return an index for the project
+ * @throws CoreException
+ */
+ IIndex getIndex(ICProject project, int options) throws CoreException;
+
+ /**
+ * Returns the index for the given projects. You can specify to add dependencies or dependent projects.
+ * @param projects the projects to get the index for
+ * @param options <code>0</code> or a combination of {@link #ADD_DEPENDENCIES} and {@link #ADD_DEPENDENT}.
+ * @return an index for the projects
+ * @throws CoreException
+ */
+ IIndex getIndex(ICProject[] projects, int options) throws CoreException;
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexName.java
index 6bfd93afb12..c73a8a70ad2 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexName.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexName.java
@@ -15,29 +15,33 @@ import org.eclipse.cdt.core.dom.IName;
/**
- * Interface for all the names in the index. These constitute either a
+ * Interface for all the names in the index. These constitute either a
* declaration or a reference.
+ * <p>
+ * This interface is not intended to be implemented by clients.
+ * </p>
+ * <p>
+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
+ * part of a work in progress. There is no guarantee that this API will work or
+ * that it will remain the same. Please do not use this API without consulting
+ * with the CDT team.
+ * </p>
+ *
* @since 4.0
*/
public interface IIndexName extends IName {
-
- public static final IIndexName[] EMPTY_NAME_ARRAY = new IIndexName[0];
-
/**
* Returns the location of the file the name resides in.
- * @since 4.0
*/
public String getFileName();
/**
* Returns the character offset of the location of the name.
- * @since 4.0
*/
public int getNodeOffset();
/**
* Returns the length of the name.
- * @since 4.0
*/
public int getNodeLength();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IndexFilter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IndexFilter.java
new file mode 100644
index 00000000000..8a234f63a0b
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IndexFilter.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.core.index;
+
+import org.eclipse.cdt.core.dom.ILinkage;
+
+/**
+ * Can be subclassed and used for queries in the index.
+ * @since 4.0
+ * <p>
+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
+ * part of a work in progress. There is no guarantee that this API will
+ * work or that it will remain the same. Please do not use this API without
+ * consulting with the CDT team.
+ * </p>
+ */
+
+public class IndexFilter {
+ /**
+ * Returns whether or not to include objects of the given linkage in the query.
+ * @see IIndex#findBindings(java.util.regex.Pattern, boolean, IndexFilter, org.eclipse.core.runtime.IProgressMonitor)
+ * @param linkage a linkage to be tested
+ * @return whether to include objects of the given linkage in the query.
+ */
+ public boolean acceptLinkage(ILinkage linkage) {
+ return true;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/Linkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/Linkage.java
new file mode 100644
index 00000000000..8e0cd3da130
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/Linkage.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.core.dom;
+
+import org.eclipse.cdt.core.dom.ILinkage;
+
+public class Linkage implements ILinkage {
+
+ public static final ILinkage NO_LINKAGE = new Linkage(NO_LINKAGE_ID);
+ public static final ILinkage C_LINKAGE = new Linkage(C_LINKAGE_ID);
+ public static final ILinkage CPP_LINKAGE = new Linkage(CPP_LINKAGE_ID);
+
+ private String fID;
+ private Linkage(String id) {
+ fID= id;
+ }
+ public String getID() {
+ return fID;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTInternal.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTInternal.java
new file mode 100644
index 00000000000..30b9d849e3e
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTInternal.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.core.dom.parser;
+
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
+
+/**
+ * Access to methods on scopes and bindings internal to the parser.
+ * @since 4.0
+ */
+public class ASTInternal {
+
+ public static IASTNode[] getDeclarationsOfBinding(IBinding binding) {
+ if( binding instanceof ICPPInternalBinding ) {
+ return ((ICPPInternalBinding)binding).getDeclarations();
+ }
+ assert false;
+ return IASTNode.EMPTY_NODE_ARRAY;
+ }
+
+ public static IASTNode getPhysicalNodeOfScope(IScope scope) throws DOMException {
+ if (scope instanceof IASTInternalScope) {
+ return ((IASTInternalScope) scope).getPhysicalNode();
+ }
+ assert false;
+ return null;
+ }
+
+ public static void flushCache(IScope scope) throws DOMException {
+ if (scope instanceof IASTInternalScope) {
+ ((IASTInternalScope) scope).flushCache();
+ }
+ }
+
+ public static boolean isFullyCached(IScope scope) throws DOMException {
+ if (scope instanceof IASTInternalScope) {
+ return ((IASTInternalScope) scope).isFullyCached();
+ }
+ return true;
+ }
+
+ public static void setFullyCached(IScope scope, boolean val) throws DOMException {
+ if (scope instanceof IASTInternalScope) {
+ ((IASTInternalScope) scope).setFullyCached(val);
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java
index 3fe89f409b0..04cced1fc2e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation 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
@@ -7,9 +7,11 @@
*
* Contributors:
* IBM - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTBuiltinSymbolProvider;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
@@ -22,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
+import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.c.CBasicType;
import org.eclipse.cdt.internal.core.dom.parser.c.CFunctionType;
import org.eclipse.cdt.internal.core.dom.parser.c.CImplicitFunction;
@@ -2351,7 +2354,10 @@ public class GCCBuiltinSymbolProvider implements IASTBuiltinSymbolProvider {
public IScope getScope() {
return null;
}
-
+
+ public ILinkage getLinkage() {
+ return Linkage.C_LINKAGE;
+ }
}
static public class CPPBuiltinParameter extends PlatformObject implements ICPPParameter {
@@ -2435,6 +2441,9 @@ public class GCCBuiltinSymbolProvider implements IASTBuiltinSymbolProvider {
public boolean isGloballyQualified() {
return false;
}
-
+
+ public ILinkage getLinkage() {
+ return Linkage.CPP_LINKAGE;
+ }
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalScope.java
new file mode 100644
index 00000000000..d54aef351f0
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalScope.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.core.dom.parser;
+
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+
+/**
+ * Interface for methods on scopes that are internal to the AST.
+ * @since 4.0
+ */
+public interface IASTInternalScope {
+ /**
+ * Return the physical IASTNode that this scope was created for
+ * @return
+ */
+ public IASTNode getPhysicalNode() throws DOMException;
+
+ /**
+ * Set whether or not all the names in this scope have been cached
+ *
+ * @param b
+ */
+ public void setFullyCached(boolean b) throws DOMException;
+
+ /**
+ * whether or not this scope's cache contains all the names
+ *
+ * @return
+ */
+ public boolean isFullyCached() throws DOMException;
+
+ /**
+ * clear the name cache in this scope
+ * @throws DOMException
+ */
+ public void flushCache() throws DOMException;
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java
index 33ad9fa35e6..25b689d047f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java
@@ -17,6 +17,7 @@ package org.eclipse.cdt.internal.core.dom.parser;
import java.text.MessageFormat;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
@@ -26,6 +27,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics;
import org.eclipse.cdt.internal.core.parser.ParserMessages;
import org.eclipse.core.runtime.PlatformObject;
@@ -33,7 +35,7 @@ import org.eclipse.core.runtime.PlatformObject;
/**
* @author aniefer
*/
-public class ProblemBinding extends PlatformObject implements IProblemBinding, IType, IScope {
+public class ProblemBinding extends PlatformObject implements IProblemBinding, IType, IScope, IASTInternalScope {
protected final int id;
protected final char [] arg;
protected IASTNode node;
@@ -208,4 +210,8 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I
public void addBinding(IBinding binding) throws DOMException {
throw new DOMException( this );
}
+
+ public ILinkage getLinkage() {
+ return Linkage.NO_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguity.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguity.java
index a361f547d7f..6499fb1f48c 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguity.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguity.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2006 IBM Corporation 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
@@ -21,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
+import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
@@ -75,7 +77,7 @@ public abstract class CASTAmbiguity extends CASTNode {
if( scope != null )
{
try {
- scope.flushCache();
+ ASTInternal.flushCache(scope);
} catch (DOMException e) {
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTName.java
index 4f3ae2e52cb..688586564e3 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTName.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTName.java
@@ -7,14 +7,17 @@
*
* Contributors:
* IBM Rational Software - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.internal.core.dom.Linkage;
/**
* @author jcamelon
@@ -141,4 +144,7 @@ public class CASTName extends CASTNode implements IASTName {
return false;
}
+ public ILinkage getLinkage() {
+ return Linkage.C_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java
index c3deaafebe8..706f8331db4 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java
@@ -13,8 +13,6 @@ package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IName;
-import org.eclipse.cdt.core.dom.IPDOM;
-import org.eclipse.cdt.core.dom.IPDOMResolver;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
@@ -42,6 +40,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage;
+import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
@@ -51,7 +50,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTPreprocessorSelectionResult;
import org.eclipse.cdt.internal.core.dom.parser.IRequiresLocationInformation;
import org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver;
import org.eclipse.cdt.internal.core.parser.scanner2.InvalidPreprocessorNodeException;
-import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.core.runtime.CoreException;
/**
@@ -68,7 +66,7 @@ public class CASTTranslationUnit extends CASTNode implements
private ILocationResolver resolver;
- private IPDOM pdom;
+ private IIndex index;
private static final IASTPreprocessorStatement[] EMPTY_PREPROCESSOR_STATEMENT_ARRAY = new IASTPreprocessorStatement[0];
@@ -125,11 +123,9 @@ public class CASTTranslationUnit extends CASTNode implements
*/
public IName[] getDeclarations(IBinding binding) {
IName[] names= getDeclarationsInAST(binding);
- if (names.length == 0 && pdom != null) {
+ if (names.length == 0 && index != null) {
try {
- binding = ((PDOM)pdom).getLinkage(getLanguage()).adaptBinding(binding);
- if (binding != null)
- names = ((IPDOMResolver)pdom.getAdapter(IPDOMResolver.class)).getDeclarations(binding);
+ names = index.findDeclarations(binding);
} catch (CoreException e) {
CCorePlugin.log(e);
return names;
@@ -156,11 +152,9 @@ public class CASTTranslationUnit extends CASTNode implements
*/
public IName[] getDefinitions(IBinding binding) {
IName[] names= getDefinitionsInAST(binding);
- if (names.length == 0 && pdom != null) {
+ if (names.length == 0 && index != null) {
try {
- binding = ((PDOM)pdom).getLinkage(getLanguage()).adaptBinding(binding);
- if (binding != null)
- names = ((IPDOMResolver)pdom.getAdapter(IPDOMResolver.class)).getDefinitions(binding);
+ names= index.findDefinitions(binding);
} catch (CoreException e) {
CCorePlugin.log(e);
return names;
@@ -566,12 +560,12 @@ public class CASTTranslationUnit extends CASTNode implements
return new GCCLanguage();
}
- public IPDOM getIndex() {
- return pdom;
+ public IIndex getIndex() {
+ return index;
}
- public void setIndex(IPDOM pdom) {
- this.pdom = pdom;
+ public void setIndex(IIndex index) {
+ this.index = index;
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CEnumeration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CEnumeration.java
index 461f68b46cc..e78d089590f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CEnumeration.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CEnumeration.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2006 IBM Corporation 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
@@ -14,6 +15,7 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.c;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
@@ -28,6 +30,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.c.ICASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTEnumerationSpecifier;
+import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.core.runtime.PlatformObject;
/**
@@ -156,4 +159,8 @@ public class CEnumeration extends PlatformObject implements IEnumeration {
return false;
}
+
+ public ILinkage getLinkage() {
+ return Linkage.C_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CEnumerator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CEnumerator.java
index eb8b79c31e0..b8f7b8924dc 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CEnumerator.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CEnumerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2006 IBM Corporation 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
@@ -14,6 +15,7 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.c;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTName;
@@ -23,6 +25,7 @@ import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
+import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.core.runtime.PlatformObject;
@@ -76,4 +79,7 @@ public class CEnumerator extends PlatformObject implements IEnumerator {
return enumeration;
}
+ public ILinkage getLinkage() {
+ return Linkage.C_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CExternalVariable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CExternalVariable.java
index 878a17188e8..846b251706a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CExternalVariable.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CExternalVariable.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2006 IBM Corporation 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
@@ -14,12 +15,15 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.c;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.dom.ast.c.ICExternalBinding;
+import org.eclipse.cdt.internal.core.dom.Linkage;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.PlatformObject;
/**
@@ -91,4 +95,8 @@ public class CExternalVariable extends PlatformObject implements ICExternalBindi
public boolean isRegister() {
return false;
}
+
+ public ILinkage getLinkage() throws CoreException {
+ return Linkage.C_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunction.java
index 82d1a364b64..bcd5c857a67 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunction.java
@@ -1,15 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2006 IBM Corporation 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM Rational Software - Initial API and implementation
+ * IBM Rational Software - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
@@ -31,7 +33,9 @@ import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
+import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.PlatformObject;
/**
@@ -431,4 +435,8 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
else
bits &= ~FULLY_RESOLVED;
}
+
+ public ILinkage getLinkage() throws CoreException {
+ return Linkage.C_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CKnRParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CKnRParameter.java
index b0e4f834e77..bdc3b120366 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CKnRParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CKnRParameter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation 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
@@ -7,9 +7,11 @@
*
* Contributors:
* IBM Rational Software - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
@@ -20,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.c.ICASTTypedefNameSpecifier;
+import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.core.runtime.PlatformObject;
/**
@@ -114,4 +117,8 @@ public class CKnRParameter extends PlatformObject implements IParameter {
return ((IASTSimpleDeclaration)declaration).getDeclSpecifier().getStorageClass() == IASTDeclSpecifier.sc_register;
return false;
}
+
+ public ILinkage getLinkage() {
+ return Linkage.C_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CLabel.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CLabel.java
index f0a10031fdf..5ffed13875b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CLabel.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CLabel.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2006 IBM Corporation 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
@@ -14,12 +15,14 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.c;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.ILabel;
import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.core.runtime.PlatformObject;
@@ -71,4 +74,7 @@ public class CLabel extends PlatformObject implements ILabel {
return CVisitor.getContainingScope( labelStatement.getParent() );
}
+ public ILinkage getLinkage() {
+ return Linkage.C_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CParameter.java
index 498e3d8ca3c..e0d87ac47e2 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CParameter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2006 IBM Corporation 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
@@ -7,10 +7,12 @@
*
* Contributors:
* IBM Rational Software - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
@@ -26,6 +28,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
+import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.core.runtime.PlatformObject;
@@ -184,4 +187,8 @@ public class CParameter extends PlatformObject implements IParameter {
}
return false;
}
+
+ public ILinkage getLinkage() {
+ return Linkage.C_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CScope.java
index ba9e991c07d..6127b582bc8 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CScope.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CScope.java
@@ -35,11 +35,12 @@ import org.eclipse.cdt.core.dom.ast.c.ICScope;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
+import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
/**
* @author aniefer
*/
-public class CScope implements ICScope {
+public class CScope implements ICScope, IASTInternalScope {
/**
* ISO C:99 6.2.3 there are seperate namespaces for various categories of
* identifiers: - label names ( labels have ICFunctionScope ) - tags of
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CStructure.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CStructure.java
index 126ff6537c6..0765f4b79ed 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CStructure.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CStructure.java
@@ -1,16 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM Rational Software - Initial API and implementation
+ * IBM Rational Software - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
@@ -31,6 +33,8 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICCompositeTypeScope;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
+import org.eclipse.cdt.internal.core.dom.Linkage;
+import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.core.runtime.PlatformObject;
/**
@@ -107,7 +111,7 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
IField[] fields = new IField[ size ];
if( size > 0 ){
ICCompositeTypeScope scope = (ICCompositeTypeScope) getCompositeScope();
- if( scope.isFullyCached() )
+ if( ASTInternal.isFullyCached(scope) )
scope = null;
for( int i = 0; i < size; i++ ){
IASTNode node = members[i];
@@ -125,7 +129,7 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
}
}
if( scope != null )
- scope.setFullyCached( true );
+ ASTInternal.setFullyCached(scope, true);
}
return (IField[]) ArrayUtil.trim( IField.class, fields );
}
@@ -142,7 +146,7 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
}
ICCompositeTypeScope scope = (ICCompositeTypeScope) getCompositeScope();
- if( scope != null && scope.isFullyCached() ){
+ if( scope != null && ASTInternal.isFullyCached(scope) ){
IBinding binding = scope.getBinding( name.toCharArray() );
if( binding instanceof IField )
return (IField) binding;
@@ -186,7 +190,7 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
}
}
if( scope != null )
- scope.setFullyCached( true );
+ ASTInternal.setFullyCached(scope, true);
if( found != null )
return found;
}
@@ -237,4 +241,8 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
return type.isSameType( this );
return false;
}
+
+ public ILinkage getLinkage() {
+ return Linkage.C_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CTypedef.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CTypedef.java
index 90c50c1341e..e60ed5c9418 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CTypedef.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CTypedef.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation 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
@@ -7,10 +7,12 @@
*
* Contributors:
* IBM Rational Software - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTName;
@@ -18,6 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
+import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.core.runtime.PlatformObject;
@@ -98,4 +101,8 @@ public class CTypedef extends PlatformObject implements ITypedef, ITypeContainer
return temp.isSameType( t );
return false;
}
+
+ public ILinkage getLinkage() {
+ return Linkage.C_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariable.java
index 6ddcc3425e4..bcdda3c0134 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariable.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariable.java
@@ -1,16 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM Rational Software - Initial API and implementation
+ * IBM Rational Software - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
@@ -22,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
+import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.core.runtime.PlatformObject;
@@ -131,4 +134,8 @@ public class CVariable extends PlatformObject implements IVariable, ICInternalBi
public boolean isRegister() {
return hasStorageClass( IASTDeclSpecifier.sc_register );
}
+
+ public ILinkage getLinkage() {
+ return Linkage.C_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java
index 40872602422..35fce23eb05 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java
@@ -7,12 +7,12 @@
*
* Contributors:
* IBM Rational Software - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
-import org.eclipse.cdt.core.dom.IPDOM;
-import org.eclipse.cdt.core.dom.IPDOMResolver;
+import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
@@ -89,10 +89,12 @@ import org.eclipse.cdt.core.dom.ast.c.ICScope;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier;
+import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.core.parser.util.ObjectSet;
+import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.core.runtime.CoreException;
@@ -851,7 +853,7 @@ public class CVisitor {
binding = new CParameter( name );
}
try {
- if( scope != null && scope.getPhysicalNode() instanceof IASTTranslationUnit ){
+ if( scope != null && ASTInternal.getPhysicalNodeOfScope(scope) instanceof IASTTranslationUnit ){
return binding;
}
} catch (DOMException e) {
@@ -1205,7 +1207,7 @@ public class CVisitor {
if( prefix )
scope = null;
- if( scope != null && scope.isFullyCached() ){
+ if( scope != null && ASTInternal.isFullyCached(scope) ){
try {
binding = scope.getBinding( name, true );
} catch ( DOMException e ) {
@@ -1278,7 +1280,7 @@ public class CVisitor {
}
if( scope != null ) {
try {
- scope.setFullyCached( true );
+ ASTInternal.setFullyCached(scope, true);
} catch ( DOMException e ) {
}
}
@@ -1305,9 +1307,13 @@ public class CVisitor {
if( blockItem != null) {
// We're at the end of our rope, check the PDOM if we can
IASTTranslationUnit tu = (IASTTranslationUnit)blockItem;
- IPDOM pdom = tu.getIndex();
- if (pdom != null) {
- binding = ((IPDOMResolver)pdom.getAdapter(IPDOMResolver.class)).resolveBinding(name);
+ IIndex index = tu.getIndex();
+ if (index != null) {
+ try {
+ binding = index.findBinding(name);
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ }
}
if (binding == null)
@@ -1915,7 +1921,7 @@ public class CVisitor {
}
public static IBinding[] findBindings( IScope scope, String name ) throws DOMException{
- IASTNode node = scope.getPhysicalNode();
+ IASTNode node = ASTInternal.getPhysicalNodeOfScope(scope);
if( node instanceof IASTFunctionDefinition )
node = ((IASTFunctionDefinition)node).getBody();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguity.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguity.java
index dad275c104a..7ccf8cd9958 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguity.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguity.java
@@ -21,6 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
+import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
public abstract class CPPASTAmbiguity extends CPPASTNode {
@@ -76,7 +77,7 @@ public abstract class CPPASTAmbiguity extends CPPASTNode {
if( scope != null )
{
try {
- scope.flushCache();
+ ASTInternal.flushCache(scope);
} catch (DOMException de) {}
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTName.java
index 099b331bdf8..4ac189ee10c 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTName.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTName.java
@@ -10,11 +10,13 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.internal.core.dom.Linkage;
/**
* @author jcamelon
@@ -151,5 +153,4 @@ public class CPPASTName extends CPPASTNode implements IASTName {
}
return false;
}
-
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNode.java
index 0446db8cbc6..07921e082e2 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNode.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNode.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
+import org.eclipse.cdt.core.dom.ILinkage;
+import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
/**
@@ -17,6 +19,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
*/
public abstract class CPPASTNode extends ASTNode {
- // A little empty isn't it...
-
+ public ILinkage getLinkage() {
+ return Linkage.CPP_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java
index f9fdd8c7557..d7059bfd525 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
@@ -20,6 +21,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
+import org.eclipse.cdt.internal.core.dom.Linkage;
/**
* @author jcamelon
@@ -276,6 +278,4 @@ public class CPPASTQualifiedName extends CPPASTNode implements
}
return false;
}
-
-
}
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 11cc8a73541..841623d0895 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
@@ -13,8 +13,6 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IName;
-import org.eclipse.cdt.core.dom.IPDOM;
-import org.eclipse.cdt.core.dom.IPDOMResolver;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
@@ -56,6 +54,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
+import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
@@ -67,7 +66,6 @@ import org.eclipse.cdt.internal.core.dom.parser.IRequiresLocationInformation;
import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider.CPPBuiltinParameter;
import org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver;
import org.eclipse.cdt.internal.core.parser.scanner2.InvalidPreprocessorNodeException;
-import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.core.runtime.CoreException;
/**
@@ -83,7 +81,7 @@ public class CPPASTTranslationUnit extends CPPASTNode implements
private ILocationResolver resolver;
- private IPDOM pdom;
+ private IIndex index;
private static final IASTPreprocessorStatement[] EMPTY_PREPROCESSOR_STATEMENT_ARRAY = new IASTPreprocessorStatement[0];
@@ -189,11 +187,9 @@ public class CPPASTTranslationUnit extends CPPASTNode implements
public IName[] getDeclarations(IBinding b) {
IName[] names = getDeclarationsInAST(b);
- if (names.length == 0 && pdom != null) {
+ if (names.length == 0 && index != null) {
try {
- b = ((PDOM)pdom).getLinkage(getLanguage()).adaptBinding(b);
- if (binding != null)
- names = ((IPDOMResolver)pdom.getAdapter(IPDOMResolver.class)).getDeclarations(b);
+ names = index.findDeclarations(b);
} catch (CoreException e) {
CCorePlugin.log(e);
return names;
@@ -220,11 +216,9 @@ public class CPPASTTranslationUnit extends CPPASTNode implements
public IName[] getDefinitions(IBinding binding) {
IName[] names = getDefinitionsInAST(binding);
- if (names.length == 0 && pdom != null) {
+ if (names.length == 0 && index != null) {
try {
- binding = ((PDOM)pdom).getLinkage(getLanguage()).adaptBinding(binding);
- if (binding != null)
- names = ((IPDOMResolver)pdom.getAdapter(IPDOMResolver.class)).getDefinitions(binding);
+ names = index.findDefinitions(binding);
} catch (CoreException e) {
CCorePlugin.log(e);
return names;
@@ -609,12 +603,12 @@ public class CPPASTTranslationUnit extends CPPASTNode implements
return new GPPLanguage();
}
- public IPDOM getIndex() {
- return pdom;
+ public IIndex getIndex() {
+ return index;
}
- public void setIndex(IPDOM pdom) {
- this.pdom = pdom;
+ public void setIndex(IIndex pdom) {
+ this.index = pdom;
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java
index 760f98d3162..2f98b772b14 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java
@@ -13,6 +13,7 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
@@ -30,6 +31,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
import org.eclipse.cdt.core.parser.util.ObjectMap;
+import org.eclipse.cdt.internal.core.dom.Linkage;
+import org.eclipse.core.runtime.CoreException;
/**
* @author aniefer
@@ -197,5 +200,4 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
public ICPPClassType[] getNestedClasses() throws DOMException {
return ICPPClassType.EMPTY_CLASS_ARRAY;
}
-
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstanceScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstanceScope.java
index a01eaa67d0e..70d5da7e411 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstanceScope.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstanceScope.java
@@ -33,11 +33,13 @@ import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.core.parser.util.ObjectSet;
+import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
+import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
/**
* @author aniefer
*/
-public class CPPClassInstanceScope implements ICPPClassScope {
+public class CPPClassInstanceScope implements ICPPClassScope, IASTInternalScope {
private static final char[] CONSTRUCTOR_KEY = "!!!CTOR!!!".toCharArray(); //$NON-NLS-1$
private CharArrayObjectMap bindings;
@@ -251,14 +253,17 @@ public class CPPClassInstanceScope implements ICPPClassScope {
public IASTNode getPhysicalNode() throws DOMException {
ICPPClassType cls = getOriginalClass();
ICPPClassScope scope = (ICPPClassScope)cls.getCompositeScope();
- if( scope != null )
- return scope.getPhysicalNode();
- if( cls instanceof ICPPInternalBinding ){
- IASTNode [] nds = ((ICPPInternalBinding)cls).getDeclarations();
- if( nds != null && nds.length > 0 )
- return nds[0];
+ IASTNode node= ASTInternal.getPhysicalNodeOfScope(scope);
+ if (node != null) {
+ return node;
}
+
+ IASTNode[] nds= ASTInternal.getDeclarationsOfBinding(cls);
+
+ if( nds != null && nds.length > 0 )
+ return nds[0];
+
return null;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java
index 376f25ac9b4..60441c3a2fe 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java
@@ -181,5 +181,4 @@ public class CPPClassSpecialization extends CPPSpecialization implements
public ICPPClassType[] getNestedClasses() throws DOMException {
return ICPPClassType.EMPTY_CLASS_ARRAY;
}
-
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java
index 3e5bffe8f92..a3fce21fa1f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java
@@ -50,6 +50,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBas
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.core.parser.util.ObjectSet;
+import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassType.CPPClassTypeProblem;
/**
@@ -389,7 +390,7 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements
}
ICPPClassScope scope = (ICPPClassScope) getCompositeScope();
- if( scope.isFullyCached() )
+ if( ASTInternal.isFullyCached(scope))
return ((CPPClassScope)scope).getConstructors( true );
IASTDeclaration [] members = getCompositeTypeSpecifier().getMembers();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java
index a3ab17601e1..9970496865d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2006 IBM Corporation 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
@@ -7,12 +7,14 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Nov 29, 2004
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
@@ -47,12 +49,13 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.core.parser.util.ObjectSet;
+import org.eclipse.cdt.internal.core.dom.Linkage;
+import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.core.runtime.PlatformObject;
@@ -373,7 +376,7 @@ public class CPPClassType extends PlatformObject implements ICPPClassType, ICPPI
{
while( scope instanceof ICPPClassScope || scope instanceof ICPPFunctionScope ){
try {
- scope = (ICPPScope) scope.getParent();
+ scope = scope.getParent();
} catch (DOMException e1) {
}
}
@@ -678,7 +681,7 @@ public class CPPClassType extends PlatformObject implements ICPPClassType, ICPPI
}
ICPPClassScope scope = (ICPPClassScope) getCompositeScope();
- if( scope.isFullyCached() )
+ if( ASTInternal.isFullyCached(scope) )
return ((CPPClassScope)scope).getConstructors( true );
IASTDeclaration [] members = getCompositeTypeSpecifier().getMembers();
@@ -821,4 +824,8 @@ public class CPPClassType extends PlatformObject implements ICPPClassType, ICPPI
}
return (ICPPClassType[]) ArrayUtil.trim( ICPPClassType.class, result );
}
+
+ public ILinkage getLinkage() {
+ return Linkage.CPP_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPCompositeBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPCompositeBinding.java
index 3d48a67e6de..6dc7d956ef9 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPCompositeBinding.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPCompositeBinding.java
@@ -13,11 +13,14 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
+import org.eclipse.cdt.internal.core.dom.Linkage;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.PlatformObject;
/**
@@ -66,4 +69,8 @@ public class CPPCompositeBinding extends PlatformObject implements IBinding {
return bindings;
}
+ public ILinkage getLinkage() throws CoreException {
+ return Linkage.CPP_LINKAGE;
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDelegate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDelegate.java
index 0b8125a0467..630fc95ae78 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDelegate.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDelegate.java
@@ -14,6 +14,7 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
@@ -21,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
+import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.core.runtime.PlatformObject;
/**
@@ -154,5 +156,8 @@ public class CPPDelegate extends PlatformObject implements ICPPDelegate, ICPPInt
public void removeDeclaration(IASTNode node) {
}
-
+
+ public ILinkage getLinkage() {
+ return Linkage.CPP_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumeration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumeration.java
index a26373c7027..1d6bd3256b5 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumeration.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumeration.java
@@ -14,6 +14,7 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTName;
@@ -25,6 +26,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
+import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.core.runtime.PlatformObject;
/**
@@ -188,4 +190,8 @@ public class CPPEnumeration extends PlatformObject implements IEnumeration, ICPP
return ((ITypedef)type).isSameType( this );
return false;
}
+
+ public ILinkage getLinkage() {
+ return Linkage.CPP_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumerator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumerator.java
index 10937f69972..fa57723d427 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumerator.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumerator.java
@@ -14,6 +14,7 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTName;
@@ -25,6 +26,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
+import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.core.runtime.PlatformObject;
/**
@@ -152,4 +154,7 @@ public class CPPEnumerator extends PlatformObject implements IEnumerator, ICPPIn
}
+ public ILinkage getLinkage() {
+ return Linkage.CPP_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPField.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPField.java
index bd894d6aaa1..d9603f062ed 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPField.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPField.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2006 IBM Corporation 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Nov 29, 2004
@@ -28,6 +29,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
+import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
/**
* @author aniefer
@@ -87,7 +89,7 @@ public class CPPField extends CPPVariable implements ICPPField, ICPPInternalBind
char [] myName = getNameCharArray();
ICPPClassScope scope = (ICPPClassScope) getScope();
- ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) scope.getPhysicalNode();
+ ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) ASTInternal.getPhysicalNodeOfScope(scope);
IASTDeclaration [] members = compSpec.getMembers();
for( int i = 0; i < members.length; i++ ){
if( members[i] instanceof IASTSimpleDeclaration ){
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java
index 895ae85faee..22b7efd35a0 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2006 IBM Corporation 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
@@ -7,12 +7,14 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Dec 1, 2004
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
@@ -36,6 +38,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
+import org.eclipse.cdt.internal.core.dom.Linkage;
+import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.core.runtime.PlatformObject;
@@ -172,7 +176,7 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
//implicit binding
IScope scope = getScope();
try {
- IASTNode node = scope.getPhysicalNode();
+ IASTNode node = ASTInternal.getPhysicalNodeOfScope(scope);
tu = node.getTranslationUnit();
} catch ( DOMException e ) {
}
@@ -592,4 +596,8 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
}
return false;
}
+
+ public ILinkage getLinkage() {
+ return Linkage.CPP_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java
index a47cfc9e9a3..711ea946898 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2006 IBM Corporation 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
@@ -32,6 +33,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
+import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
/**
* @author aniefer
@@ -84,7 +86,7 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod
IFunctionType ftype = getType();
IType [] params = ftype.getParameterTypes();
- ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) getScope().getPhysicalNode();
+ ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) ASTInternal.getPhysicalNodeOfScope(getScope());
IASTDeclaration [] members = compSpec.getMembers();
for( int i = 0; i < members.length; i++ ){
IASTDeclarator dtor = null;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPLabel.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPLabel.java
index ec5258ed295..fb4851e07ac 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPLabel.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPLabel.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2006 IBM Corporation 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
@@ -14,12 +15,14 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.ILabel;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
+import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.core.runtime.PlatformObject;
/**
@@ -143,5 +146,8 @@ public class CPPLabel extends PlatformObject implements ILabel, ICPPInternalBind
}
+ public ILinkage getLinkage() {
+ return Linkage.CPP_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java
index 0e3a7e51f7d..fe66a070476 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2006 IBM Corporation 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Dec 1, 2004
@@ -33,6 +34,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
+import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
/**
* @author aniefer
@@ -118,7 +120,7 @@ public class CPPMethod extends CPPFunction implements ICPPMethod {
char [] myName = getNameCharArray();
ICPPClassScope scope = (ICPPClassScope) getScope();
- ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) scope.getPhysicalNode();
+ ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) ASTInternal.getPhysicalNodeOfScope(scope);
IASTDeclaration [] members = compSpec.getMembers();
for( int i = 0; i < members.length; i++ ){
if( members[i] instanceof IASTSimpleDeclaration ){
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplate.java
index d14a751cf82..acaca8a1de2 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplate.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplate.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Mar 31, 2005
@@ -30,6 +31,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
+import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
/**
* @author aniefer
@@ -64,7 +66,7 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements
if( scope instanceof ICPPTemplateScope )
scope = scope.getParent();
ICPPClassScope clsScope = (ICPPClassScope) scope;
- ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) clsScope.getPhysicalNode();
+ ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) ASTInternal.getPhysicalNodeOfScope(clsScope);
IASTDeclaration [] members = compSpec.getMembers();
for( int i = 0; i < members.length; i++ ){
if( members[i] instanceof ICPPASTTemplateDeclaration ){
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespace.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespace.java
index 2ccdd298d30..52dd05764a0 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespace.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespace.java
@@ -7,12 +7,14 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Dec 1, 2004
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
@@ -37,6 +39,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.core.parser.util.ObjectSet;
+import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.core.runtime.PlatformObject;
@@ -240,7 +243,7 @@ public class CPPNamespace extends PlatformObject implements ICPPNamespace, ICPPI
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
*/
public String getName() {
- return tu != null ? null : namespaceDefinitions[0].toString(); //$NON-NLS-1$
+ return tu != null ? null : namespaceDefinitions[0].toString();
}
/* (non-Javadoc)
@@ -363,4 +366,7 @@ public class CPPNamespace extends PlatformObject implements ICPPNamespace, ICPPI
return IBinding.EMPTY_BINDING_ARRAY;
}
+ public ILinkage getLinkage() {
+ return Linkage.CPP_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespaceAlias.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespaceAlias.java
index 654cf40118c..36c252f7811 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespaceAlias.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespaceAlias.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
@@ -14,6 +15,7 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
@@ -24,6 +26,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
+import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.core.runtime.PlatformObject;
/**
@@ -151,4 +154,8 @@ public class CPPNamespaceAlias extends PlatformObject implements ICPPNamespaceAl
public IBinding[] getMemberBindings() throws DOMException {
return namespace.getMemberBindings();
}
+
+ public ILinkage getLinkage() {
+ return Linkage.CPP_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java
index 5fcc21c1d60..62083daa2cc 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2006 IBM Corporation 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
@@ -7,12 +7,14 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Dec 10, 2004
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
@@ -28,6 +30,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
+import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.core.runtime.PlatformObject;
@@ -280,4 +283,8 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI
}
return null;
}
+
+ public ILinkage getLinkage() {
+ return Linkage.CPP_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScope.java
index 0757984a436..46baf7aaaa6 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScope.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScope.java
@@ -7,13 +7,14 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Nov 29, 2004
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
-import org.eclipse.cdt.core.dom.IPDOM;
+import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
@@ -23,16 +24,18 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
+import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
import org.eclipse.cdt.core.parser.util.ObjectSet;
+import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
-import org.eclipse.cdt.internal.core.pdom.PDOM;
+import org.eclipse.core.runtime.CoreException;
/**
* @author aniefer
*/
-abstract public class CPPScope implements ICPPScope{
+abstract public class CPPScope implements ICPPScope, IASTInternalScope {
public static class CPPScopeProblem extends ProblemBinding implements ICPPScope {
public CPPScopeProblem( IASTNode node, int id, char[] arg ) {
super( node, id, arg );
@@ -125,13 +128,18 @@ abstract public class CPPScope implements ICPPScope{
}
return (IBinding) obj;
} else {
- IPDOM pdom = name.getTranslationUnit().getIndex();
- if (pdom != null) {
+ IIndex index = name.getTranslationUnit().getIndex();
+ if (index != null) {
// Try looking this up in the PDOM
if (physicalNode instanceof ICPPASTNamespaceDefinition) {
ICPPASTNamespaceDefinition nsdef = (ICPPASTNamespaceDefinition)physicalNode;
IASTName nsname = nsdef.getName();
- IBinding nsbinding = ((PDOM)pdom).resolveBinding(nsname);
+ IBinding nsbinding= null;
+ try {
+ nsbinding = index.findBinding(nsname);
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ }
if (nsbinding instanceof ICPPScope)
return ((ICPPScope)nsbinding).getBinding(name, forceResolve);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java
index 053678f75f6..b8f123a87cd 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java
@@ -7,14 +7,14 @@
*
* Contributors:
* IBM - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Dec 8, 2004
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
-import org.eclipse.cdt.core.dom.IPDOM;
-import org.eclipse.cdt.core.dom.IPDOMResolver;
+import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
@@ -117,16 +117,19 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
+import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.core.parser.util.ObjectSet;
import org.eclipse.cdt.core.parser.util.ArrayUtil.ArrayWrapper;
+import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
+import org.eclipse.core.runtime.CoreException;
/**
* @author aniefer
@@ -136,7 +139,7 @@ public class CPPSemantics {
protected static final ASTNodeProperty STRING_LOOKUP_PROPERTY = new ASTNodeProperty("CPPSemantics.STRING_LOOKUP_PROPERTY - STRING_LOOKUP"); //$NON-NLS-1$
public static final char[] EMPTY_NAME_ARRAY = new char[0];
public static final String EMPTY_NAME = ""; //$NON-NLS-1$
- public static final char[] OPERATOR_ = new char[] {'o','p','e','r','a','t','o','r',' '}; //$NON-NLS-1$
+ public static final char[] OPERATOR_ = new char[] {'o','p','e','r','a','t','o','r',' '};
public static final IType VOID_TYPE = new CPPBasicType( IBasicType.t_void, 0 );
static protected class LookupData
@@ -749,9 +752,13 @@ public class CPPSemantics {
}
if( binding == null || binding instanceof IProblemBinding ){
// Let's try the pdom
- IPDOM pdom = name.getTranslationUnit().getIndex();
- if (pdom != null) {
- binding = ((IPDOMResolver)pdom.getAdapter(IPDOMResolver.class)).resolveBinding(name);
+ IIndex index = name.getTranslationUnit().getIndex();
+ if (index != null) {
+ try {
+ binding = index.findBinding(name);
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ }
}
// If we're still null...
@@ -1015,7 +1022,7 @@ public class CPPSemantics {
ArrayWrapper directives = null;
if( !data.usingDirectivesOnly ){
- if( scope.isFullyCached() && !data.prefixLookup && data.astName != null ){
+ if( ASTInternal.isFullyCached(scope) && !data.prefixLookup && data.astName != null ){
IBinding binding = data.prefixLookup ? null : scope.getBinding( data.astName, true );
if( binding != null &&
( CPPSemantics.declaredBefore( binding, data.astName ) ||
@@ -1156,7 +1163,7 @@ public class CPPSemantics {
//is circular inheritance
if( ! data.inheritanceChain.containsKey( parent ) ){
//is this name define in this scope?
- if( data.astName != null && !data.prefixLookup && parent.isFullyCached() )
+ if( data.astName != null && !data.prefixLookup && ASTInternal.isFullyCached(parent) )
inherited = parent.getBinding( data.astName, true );
else
inherited = lookupInScope( data, parent, null );
@@ -1363,7 +1370,7 @@ public class CPPSemantics {
static protected IASTName[] lookupInScope( CPPSemantics.LookupData data, ICPPScope scope, IASTNode blockItem ) throws DOMException {
Object possible = null;
IASTNode [] nodes = null;
- IASTNode parent = scope.getPhysicalNode();
+ IASTNode parent = ASTInternal.getPhysicalNodeOfScope(scope);
IASTName [] namespaceDefs = null;
int namespaceIdx = -1;
@@ -1521,7 +1528,7 @@ public class CPPSemantics {
}
- scope.setFullyCached( true );
+ ASTInternal.setFullyCached(scope, true);
return found;
}
@@ -1546,7 +1553,7 @@ public class CPPSemantics {
ArrayWrapper usings = new ArrayWrapper();
boolean found = false;
- if( temp.isFullyCached() && !data.prefixLookup ){
+ if( ASTInternal.isFullyCached(temp) && !data.prefixLookup ){
IBinding binding = temp.getBinding( data.astName, true );
if( binding != null &&
( CPPSemantics.declaredBefore( binding, data.astName ) ||
@@ -2155,7 +2162,7 @@ public class CPPSemantics {
if( scope instanceof ICPPClassScope ){
cls = ((ICPPClassScope)scope).getClassType();
} else {
- cls = new CPPClassType.CPPClassTypeProblem( scope.getPhysicalNode(), IProblemBinding.SEMANTIC_BAD_SCOPE, fn.getNameCharArray() );
+ cls = new CPPClassType.CPPClassTypeProblem(ASTInternal.getPhysicalNodeOfScope(scope), IProblemBinding.SEMANTIC_BAD_SCOPE, fn.getNameCharArray() );
}
if( cls instanceof ICPPClassTemplate ){
IBinding within = CPPTemplates.instantiateWithinClassTemplate( (ICPPClassTemplate) cls );
@@ -3211,7 +3218,7 @@ public class CPPSemantics {
public static IBinding[] findBindings( IScope scope, char []name, boolean qualified ) throws DOMException{
CPPASTName astName = new CPPASTName();
astName.setName( name );
- astName.setParent( scope.getPhysicalNode() );
+ astName.setParent( ASTInternal.getPhysicalNodeOfScope(scope));
astName.setPropertyInParent( STRING_LOOKUP_PROPERTY );
LookupData data = new LookupData( astName );
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSpecialization.java
index 30a6662978a..cc8bd66e0ca 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSpecialization.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
* /
*******************************************************************************/
/*
@@ -14,6 +15,7 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
@@ -22,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.ObjectMap;
+import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.core.runtime.PlatformObject;
@@ -114,5 +117,7 @@ public abstract class CPPSpecialization extends PlatformObject implements ICPPSp
public boolean isGloballyQualified() throws DOMException {
return ((ICPPInternalBinding)specialized).isGloballyQualified();
}
-
+ public ILinkage getLinkage() {
+ return Linkage.CPP_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java
index c49bb7aee6b..23c8e6b0846 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java
@@ -7,12 +7,14 @@
*
* Contributors:
* IBM - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Mar 14, 2005
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
@@ -41,6 +43,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.ObjectMap;
+import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.core.runtime.PlatformObject;
@@ -387,4 +390,8 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
public IASTNode getDefinition() {
return definition;
}
+
+ public ILinkage getLinkage() {
+ return Linkage.CPP_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateParameter.java
index 0506617ec1a..e8f3574ea61 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateParameter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation 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
@@ -7,12 +7,14 @@
*
* Contributors:
* IBM - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Mar 11, 2005
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IScope;
@@ -20,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
+import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.core.runtime.PlatformObject;
@@ -153,4 +156,8 @@ public class CPPTemplateParameter extends PlatformObject implements ICPPTemplate
}
}
}
+
+ public ILinkage getLinkage() {
+ return Linkage.CPP_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedef.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedef.java
index 4f532ea3195..ddc7437e66f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedef.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedef.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2006 IBM Corporation 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
@@ -7,12 +7,14 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Dec 11, 2004
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTName;
@@ -23,6 +25,7 @@ import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
+import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.core.runtime.PlatformObject;
@@ -215,4 +218,8 @@ public class CPPTypedef extends PlatformObject implements ITypedef, ITypeContain
}
}
}
+
+ public ILinkage getLinkage() {
+ return Linkage.CPP_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownBinding.java
index d1df35e0560..ef0d4bcc4fa 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownBinding.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownBinding.java
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
@@ -14,6 +15,7 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
@@ -24,6 +26,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.parser.util.ObjectMap;
+import org.eclipse.cdt.internal.core.dom.Linkage;
+import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.core.runtime.PlatformObject;
/**
@@ -146,7 +150,7 @@ public class CPPUnknownBinding extends PlatformObject implements ICPPInternalUnk
if( t instanceof ICPPClassType ){
IScope s = ((ICPPClassType)t).getCompositeScope();
- if( s != null && s.isFullyCached() )
+ if( s != null && ASTInternal.isFullyCached(s) )
result = s.getBinding( name, true );
// CPPSemantics.LookupData data = CPPSemantics.createLookupData( name, false );
// CPPSemantics.lookup( data, s );
@@ -156,4 +160,8 @@ public class CPPUnknownBinding extends PlatformObject implements ICPPInternalUnk
}
return result;
}
+
+ public ILinkage getLinkage() {
+ return Linkage.CPP_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java
index 79a065ee061..5160517562b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java
@@ -23,11 +23,12 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
+import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
/**
* @author aniefer
*/
-public class CPPUnknownScope implements ICPPScope {
+public class CPPUnknownScope implements ICPPScope, IASTInternalScope {
private IBinding binding = null;
private IASTName scopeName = null;
private CharArrayObjectMap map = null;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUsingDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUsingDeclaration.java
index a00a2aa44ce..e4cb82fb173 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUsingDeclaration.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUsingDeclaration.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2006 IBM Corporation 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
@@ -14,6 +15,7 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
@@ -25,6 +27,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
+import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.core.runtime.PlatformObject;
/**
@@ -152,4 +155,7 @@ public class CPPUsingDeclaration extends PlatformObject implements ICPPUsingDecl
public void removeDeclaration( IASTNode node ) {
}
+ public ILinkage getLinkage() {
+ return Linkage.CPP_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java
index 7ba986016b0..df30af7fba5 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2006 IBM Corporation 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
@@ -7,12 +7,14 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Nov 29, 2004
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
@@ -28,6 +30,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
+import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.core.runtime.PlatformObject;
@@ -368,4 +371,8 @@ public class CPPVariable extends PlatformObject implements ICPPVariable, ICPPInt
public boolean isRegister() {
return hasStorageClass( IASTDeclSpecifier.sc_register );
}
+
+ public ILinkage getLinkage() {
+ return Linkage.CPP_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java
index 1415fad55c8..a52e8b53810 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java
@@ -141,6 +141,7 @@ import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
+import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
@@ -618,7 +619,7 @@ public class CPPVisitor {
ICPPASTCompositeTypeSpecifier clsTypeSpec;
try {
- IASTNode node = ((ICPPClassScope)containingScope).getPhysicalNode();
+ IASTNode node = ASTInternal.getPhysicalNodeOfScope(containingScope);
if (node instanceof ICPPASTCompositeTypeSpecifier)
clsTypeSpec = (ICPPASTCompositeTypeSpecifier)node;
else
@@ -1639,7 +1640,7 @@ public class CPPVisitor {
IASTNode node = null;
while( scope != null ){
if( scope instanceof ICPPBlockScope ){
- node = ((ICPPBlockScope)scope).getPhysicalNode();
+ node = ASTInternal.getPhysicalNodeOfScope(scope);
if( node.getParent() instanceof IASTFunctionDefinition )
break;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java
new file mode 100644
index 00000000000..5924c8ef5c7
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java
@@ -0,0 +1,311 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.core.index;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.regex.Pattern;
+
+import org.eclipse.cdt.core.dom.IName;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexBinding;
+import org.eclipse.cdt.core.index.IIndexFile;
+import org.eclipse.cdt.core.index.IIndexInclude;
+import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.cdt.core.index.IndexFilter;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.SubProgressMonitor;
+
+public class CIndex implements IIndex {
+ final private IIndexFragment[] fFragments;
+ final private int fPrimaryFragmentCount;
+ private int fReadLock;
+
+ public CIndex(IIndexFragment[] fragments, int primaryFragmentCount) {
+ fFragments= fragments;
+ fPrimaryFragmentCount= primaryFragmentCount;
+ }
+
+ public CIndex(IIndexFragment[] fragments) {
+ this(fragments, fragments.length);
+ }
+
+ public IIndexBinding findBinding(ICElement element) throws CoreException {
+ // mstodo ICElement to IBinding
+ return null;
+ }
+
+ public IIndexBinding findBinding(IName name) throws CoreException {
+ if (name instanceof IIndexFragmentName) {
+ return findBinding((IIndexFragmentName) name);
+ }
+ if (name instanceof IASTName) {
+ return findBinding((IASTName) name);
+ }
+ return null;
+ }
+
+ private IIndexBinding findBinding(IIndexFragmentName indexName) throws CoreException {
+ IIndexProxyBinding proxy= indexName.getBinding();
+
+ if (proxy instanceof IIndexFragmentBinding) {
+ IIndexFragmentBinding binding= (IIndexFragmentBinding) proxy;
+ if (isFragment(binding.getFragment())) {
+ return binding;
+ }
+ }
+
+ if (proxy != null) {
+ for (int i = 0; i < fFragments.length; i++) {
+ IIndexProxyBinding result= fFragments[i].adaptBinding(proxy);
+ if (result instanceof IIndexFragmentBinding) {
+ return (IIndexFragmentBinding) result;
+ }
+ }
+ }
+ return null;
+ }
+
+ private boolean isFragment(IIndexFragment frag) {
+ for (int i = 0; i < fFragments.length; i++) {
+ if (frag == fFragments[i]) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean isPrimaryFragment(IIndexFragment frag) {
+ for (int i = 0; i < fPrimaryFragmentCount; i++) {
+ if (frag == fFragments[i]) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private IIndexBinding findBinding(IASTName astName) throws CoreException {
+ IIndexProxyBinding binding= null;
+ for (int i = 0; i < fFragments.length; i++) {
+ if (binding == null) {
+ binding= fFragments[i].findBinding(astName);
+ if (binding instanceof IIndexFragmentBinding) {
+ return (IIndexFragmentBinding) binding;
+ }
+ }
+ else {
+ IIndexProxyBinding alt= fFragments[i].adaptBinding(binding);
+ if (alt instanceof IIndexFragmentBinding) {
+ return (IIndexFragmentBinding) alt;
+ }
+ }
+ }
+ return null;
+ }
+
+ public IIndexBinding[] findBindings(Pattern pattern, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
+ return findBindings(new Pattern[]{pattern}, isFullyQualified, filter, monitor);
+ }
+
+ public IIndexBinding[] findBindings(Pattern[] patterns, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
+ ArrayList result= new ArrayList();
+ monitor.beginTask(Messages.CIndex_FindBindingsTask_label, fFragments.length);
+ for (int i = 0; !monitor.isCanceled() && i < fFragments.length; i++) {
+ result.addAll(Arrays.asList(fFragments[i].findBindings(patterns, isFullyQualified, filter, new SubProgressMonitor(monitor, 1))));
+ }
+ monitor.done();
+ return (IIndexBinding[]) result.toArray(new IIndexBinding[result.size()]);
+ }
+
+
+ public IIndexName[] findNames(IBinding binding, int flags) throws CoreException {
+ ArrayList result= new ArrayList();
+ for (int i = 0; i < fPrimaryFragmentCount; i++) {
+ IIndexProxyBinding adaptedBinding= fFragments[i].adaptBinding(binding);
+ if (adaptedBinding != null) {
+ result.addAll(Arrays.asList(fFragments[i].findNames(adaptedBinding, flags)));
+ }
+ }
+ return (IIndexName[]) result.toArray(new IIndexName[result.size()]);
+ }
+
+ public IIndexName[] findDeclarations(IBinding binding) throws CoreException {
+ return findNames(binding, FIND_DECLARATIONS_DEFINITIONS);
+ }
+
+ public IIndexName[] findDefinitions(IBinding binding) throws CoreException {
+ return findNames(binding, FIND_DEFINITIONS);
+ }
+
+ public IIndexName[] findReferences(IBinding binding) throws CoreException {
+ return findNames(binding, FIND_REFERENCES);
+ }
+
+ public IIndexFile getFile(IPath location) throws CoreException {
+ IIndexFile result= null;
+ for (int i = 0; result==null && i < fPrimaryFragmentCount; i++) {
+ result= fFragments[i].getFile(location);
+ }
+ return result;
+ }
+
+ public IIndexFile resolveInclude(IIndexInclude include) throws CoreException {
+ IIndexFragmentInclude fragmentInclude = (IIndexFragmentInclude) include;
+ IIndexFragment frag= fragmentInclude.getFragment();
+ if (isPrimaryFragment(frag)) {
+ IIndexFile result= fragmentInclude.getIncludes();
+ if (result != null) {
+ return result;
+ }
+ }
+ Path location= new Path(include.getIncludesLocation());
+ for (int i = 0; i < fPrimaryFragmentCount; i++) {
+ IIndexFragment otherFrag = fFragments[i];
+ if (otherFrag != frag) {
+ IIndexFile result= otherFrag.getFile(location);
+ if (result != null) {
+ return result;
+ }
+ }
+ }
+ return null;
+ }
+
+ public IIndexInclude[] findIncludedBy(IIndexFile file) throws CoreException {
+ return findIncludedBy(file, 0);
+ }
+
+ public IIndexInclude[] findIncludedBy(IIndexFile file, int depth) throws CoreException {
+ List result= new ArrayList();
+ findIncludedBy(Collections.singletonList(file), result, depth, new HashSet());
+ return (IIndexInclude[]) result.toArray(new IIndexInclude[result.size()]);
+ }
+
+ public void findIncludedBy(List in, List out, int depth, HashSet handled) throws CoreException {
+ List nextLevel= depth != 0 ? new LinkedList() : null;
+ for (Iterator it= in.iterator(); it.hasNext(); ) {
+ IIndexFragmentFile file = (IIndexFragmentFile) it.next();
+ for (int j= 0; j < fPrimaryFragmentCount; j++) {
+ IIndexInclude[] includedBy= fFragments[j].findIncludedBy(file);
+ for (int k= 0; k < includedBy.length; k++) {
+ IIndexInclude include = includedBy[k];
+ if (handled.add(include.getIncludedByLocation())) {
+ out.add(include);
+ if (depth != 0) {
+ nextLevel.add(include.getIncludedBy());
+ }
+ }
+ }
+ }
+ }
+ if (depth == 0 || nextLevel.isEmpty()) {
+ return;
+ }
+ if (depth > 0) {
+ depth--;
+ }
+ findIncludedBy(nextLevel, out, depth, handled);
+ }
+
+
+ public IIndexInclude[] findIncludes(IIndexFile file) throws CoreException {
+ return findIncludes(file, 0);
+ }
+
+ public IIndexInclude[] findIncludes(IIndexFile file, int depth) throws CoreException {
+ List result= new ArrayList();
+ findIncludes(Collections.singletonList(file), result, depth, new HashSet());
+ result= result.subList(1, result.size());
+ return (IIndexInclude[]) result.toArray(new IIndexInclude[result.size()]);
+ }
+
+ public void findIncludes(List in, List out, int depth, HashSet handled) throws CoreException {
+ List nextLevel= depth != 0 ? new LinkedList() : null;
+ for (Iterator it= in.iterator(); it.hasNext(); ) {
+ IIndexFragmentFile file = (IIndexFragmentFile) it.next();
+ IIndexFragment frag= file.getIndexFragment();
+ if (isPrimaryFragment(frag)) {
+ IIndexInclude[] includes= file.getIncludes();
+ for (int k= 0; k < includes.length; k++) {
+ IIndexInclude include = includes[k];
+ if (handled.add(include.getIncludesLocation())) {
+ out.add(include);
+ if (depth != 0) {
+ IIndexFile includedByFile= resolveInclude(include);
+ if (includedByFile != null) {
+ nextLevel.add(includedByFile);
+ }
+ }
+ }
+ }
+ }
+ }
+ if (depth == 0 || nextLevel.isEmpty()) {
+ return;
+ }
+ if (depth > 0) {
+ depth--;
+ }
+ findIncludes(nextLevel, out, depth, handled);
+ }
+
+ public synchronized void acquireReadLock() throws InterruptedException {
+ if (++fReadLock == 1) {
+ int i= 0;
+ try {
+ for (i = 0; i < fFragments.length; i++) {
+ fFragments[i].acquireReadLock();
+ }
+ }
+ finally {
+ if (i < fFragments.length) {
+ // rollback
+ fReadLock--;
+ while (--i >= 0) {
+ fFragments[i].releaseReadLock();
+ }
+ }
+ }
+ }
+ }
+
+ public synchronized void releaseReadLock() {
+ if (--fReadLock == 0) {
+ for (int i=0; i < fFragments.length; i++) {
+ fFragments[i].releaseReadLock();
+ }
+ }
+ }
+
+ protected synchronized int getReadLockCount() {
+ return fReadLock;
+ }
+
+ public long getLastWriteAccess() {
+ long result= 0;
+ for (int i=0; i < fFragments.length; i++) {
+ result= Math.max(result, fFragments[i].getLastWriteAccess());
+ }
+ return result;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/EmptyCIndex.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/EmptyCIndex.java
new file mode 100644
index 00000000000..d951fff3573
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/EmptyCIndex.java
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.core.index;
+
+import java.util.regex.Pattern;
+
+import org.eclipse.cdt.core.dom.IName;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexBinding;
+import org.eclipse.cdt.core.index.IIndexFile;
+import org.eclipse.cdt.core.index.IIndexInclude;
+import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.cdt.core.index.IndexFilter;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+final public class EmptyCIndex implements IIndex {
+ public static IIndex INSTANCE= new EmptyCIndex();
+
+ private EmptyCIndex() {
+ }
+
+ public IIndexBinding findBinding(ICElement element) {
+ return null;
+ }
+
+ public IIndexName[] findDeclarations(IBinding binding) {
+ return IIndexFragmentName.EMPTY_NAME_ARRAY;
+ }
+
+ public IIndexName[] findDefinitions(IBinding binding) {
+ return IIndexFragmentName.EMPTY_NAME_ARRAY;
+ }
+
+ public IIndexName[] findReferences(IBinding binding) {
+ return IIndexFragmentName.EMPTY_NAME_ARRAY;
+ }
+
+ public IIndexName[] findNames(IBinding binding, int flags) {
+ return IIndexFragmentName.EMPTY_NAME_ARRAY;
+ }
+
+ public IIndexFile getFile(IPath location) {
+ return null;
+ }
+
+ public IIndexFile resolveInclude(IIndexInclude include) {
+ return null;
+ }
+
+ public IIndexInclude[] findIncludedBy(IIndexFile file) {
+ return IIndexInclude.EMPTY_INCLUDES_ARRAY;
+ }
+
+ public IIndexInclude[] findIncludedBy(IIndexFile file, int depth) {
+ return IIndexInclude.EMPTY_INCLUDES_ARRAY;
+ }
+
+ public IIndexInclude[] findIncludes(IIndexFile file) {
+ return IIndexInclude.EMPTY_INCLUDES_ARRAY;
+ }
+
+ public IIndexInclude[] findIncludes(IIndexFile file, int depth) {
+ return IIndexInclude.EMPTY_INCLUDES_ARRAY;
+ }
+
+ public void acquireReadLock() {
+ }
+
+ public void releaseReadLock() {
+ }
+
+ public long getLastWriteAccess() {
+ return 0;
+ }
+
+ public IIndexBinding findBinding(IName name) {
+ return null;
+ }
+
+ public IIndexBinding[] findBindings(Pattern pattern, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) {
+ return IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
+ }
+
+ public IIndexBinding[] findBindings(Pattern[] pattern, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
+ return IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
+ }
+} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragment.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragment.java
new file mode 100644
index 00000000000..4cd52eb95f0
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragment.java
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.core.index;
+
+import java.util.regex.Pattern;
+
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IndexFilter;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * Interface for the implementation of the actual index storage mechanism.
+ *
+ * @since 4.0
+ */
+public interface IIndexFragment {
+ /**
+ * @see IIndex#FIND_DECLARATIONS
+ */
+ final int FIND_DECLARATIONS = IIndex.FIND_DECLARATIONS;
+ /**
+ * @see IIndex#FIND_DEFINITIONS
+ */
+ final int FIND_DEFINITIONS = IIndex.FIND_DEFINITIONS;
+ /**
+ * @see IIndex#FIND_REFERENCES
+ */
+ final int FIND_REFERENCES = IIndex.FIND_REFERENCES;
+ /**
+ * @see IIndex#FIND_DECLARATIONS_DEFINITIONS
+ */
+ final int FIND_DECLARATIONS_DEFINITIONS = IIndex.FIND_DECLARATIONS_DEFINITIONS;
+ /**
+ * @see IIndex#FIND_ALL_OCCURENCES
+ */
+ final int FIND_ALL_OCCURENCES = IIndex.FIND_ALL_OCCURENCES;
+
+ /**
+ * Returns the file for the given location. May return <code>null</code>, if no such file exists.
+ * This method may only return files that are actually managed by this fragement.
+ * @param location absolute path to the location of the file
+ * @return the file for the location
+ * @throws CoreException
+ */
+ IIndexFragmentFile getFile(IPath location) throws CoreException;
+
+ /**
+ * Returns all include directives that point to the given file. The input file may belong to
+ * another fragment. All of the include directives returned must belong to files managed by
+ * this fragment.
+ * @param file a file to search for includes pointing to it
+ * @return an array of inlucde directives managed by this fragment
+ * @throws CoreException
+ */
+ IIndexFragmentInclude[] findIncludedBy(IIndexFragmentFile file) throws CoreException;
+
+ /**
+ * Looks for a binding matching the given one. May return <code>null</code>, if no
+ * such binding exists. The binding may belong to an AST or another index fragment.
+ * @param binding the binding to look for.
+ * @return the binding, or <code>null</code>
+ * @throws CoreException
+ */
+ IIndexProxyBinding adaptBinding(IBinding binding) throws CoreException;
+
+ /**
+ * Looks for a proxy binding matching the given one. May return <code>null</code>, if no
+ * such binding exists. The binding may belong to another index fragment.
+ * @param proxy the binding to look for.
+ * @return the binding, or <code>null</code>
+ * @throws CoreException
+ */
+ IIndexProxyBinding adaptBinding(IIndexProxyBinding proxy) throws CoreException;
+
+ /**
+ * Looks for a binding of the given name from the AST. May return <code>null</code>, if no
+ * such binding exists.
+ * @param astName the name for looking up the binding
+ * @return the binding for the name, or <code>null</code>
+ * @throws CoreException
+ */
+ IIndexProxyBinding findBinding(IASTName astName) throws CoreException;
+
+ /**
+ * Searches for all bindings with qualified names that seen as an array of simple names match the given array
+ * of patterns. In case a binding exists in multiple projects, no duplicate bindings are returned.
+ * You can search with an array of patterns that specifies a partial qualification only.
+ * @param patterns an array of patterns the names of the qualified name of the bindings have to match.
+ * @param isFullyQualified if <code>true</code>, the array of pattern specifies the fully qualified name
+ * @param filter a filter that allows for skipping parts of the index
+ * @param monitor a monitor to report progress
+ * @return an array of bindings matching the pattern
+ * @throws CoreException
+ */
+ IIndexFragmentBinding[] findBindings(Pattern[] pattern, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException;
+
+ /**
+ * Searches for all names that resolve to the given binding. You can limit the result to references, declarations
+ * or definitions, or a combination of those.
+ * @param binding a binding for which names are searched for
+ * @param flags a combination of {@link #FIND_DECLARATIONS}, {@link #FIND_DEFINITIONS} and {@link #FIND_REFERENCES}
+ * @return an array of names
+ * @throws CoreException
+ */
+ IIndexFragmentName[] findNames(IIndexProxyBinding binding, int flags) throws CoreException;
+
+ /**
+ * Acquires a read lock.
+ * @throws InterruptedException
+ */
+ void acquireReadLock() throws InterruptedException;
+
+ /**
+ * Releases a read lock.
+ */
+ void releaseReadLock();
+
+ /**
+ * Returns the timestamp of the last modification to the index.
+ */
+ long getLastWriteAccess();
+
+
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentBinding.java
new file mode 100644
index 00000000000..b80265b9cb4
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentBinding.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.core.index;
+
+import org.eclipse.cdt.core.index.IIndexBinding;
+
+public interface IIndexFragmentBinding extends IIndexBinding, IIndexProxyBinding {
+ IIndexFragmentBinding[] EMPTY_INDEX_BINDING_ARRAY= new IIndexFragmentBinding[0];
+} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOMWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentFile.java
index 4bb5fd0fc1b..c6e1e27a2da 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOMWriter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentFile.java
@@ -1,24 +1,23 @@
/*******************************************************************************
- * Copyright (c) 2006 QNX Software Systems and others.
+ * Copyright (c) 2006 Wind River Systems, Inc. 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * QNX - Initial API and implementation
- *******************************************************************************/
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
-package org.eclipse.cdt.core.dom;
+package org.eclipse.cdt.internal.core.index;
-import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.cdt.core.index.IIndexFile;
-/**
- * This is the interface used by clients, such as indexers, to
- * write content to the PDOM.
- *
- * @author Doug Schaefer
- */
-public interface IPDOMWriter extends IAdaptable {
+public interface IIndexFragmentFile extends IIndexFile {
+
+ /**
+ * Returns the fragment that owns this file.
+ */
+ IIndexFragment getIndexFragment();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentInclude.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentInclude.java
new file mode 100644
index 00000000000..a690ad823b6
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentInclude.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.core.index;
+
+import org.eclipse.cdt.core.index.IIndexInclude;
+import org.eclipse.core.runtime.CoreException;
+
+public interface IIndexFragmentInclude extends IIndexInclude {
+
+ /**
+ * Returns the fragment that owns this include.
+ */
+ IIndexFragment getFragment();
+
+ /**
+ * Returns the file that is included by this include. May return <code>null</code> in case
+ * the included file is not part of this fragment.
+ */
+ IIndexFragmentFile getIncludes() throws CoreException;
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentName.java
new file mode 100644
index 00000000000..391d19f2c51
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentName.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.core.index;
+
+import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.core.runtime.CoreException;
+
+public interface IIndexFragmentName extends IIndexName {
+
+ public static final IIndexFragmentName[] EMPTY_NAME_ARRAY = new IIndexFragmentName[0];
+
+ /**
+ * Returns the fragment that owns this name.
+ */
+ IIndexFragment getIndexFragment();
+
+ /**
+ * Returns the (proxy) binding the name resolves to.
+ */
+ IIndexProxyBinding getBinding() throws CoreException;
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexProxyBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexProxyBinding.java
new file mode 100644
index 00000000000..f22008f9380
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexProxyBinding.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.core.index;
+
+import org.eclipse.cdt.core.dom.ILinkage;
+import org.eclipse.core.runtime.CoreException;
+
+public interface IIndexProxyBinding {
+ /**
+ * Returns the owner of the binding.
+ */
+ IIndexFragment getFragment();
+
+ /**
+ * Returns the linkage the binding belongs to.
+ */
+ ILinkage getLinkage() throws CoreException;
+
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IWritableIndex.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IWritableIndex.java
new file mode 100644
index 00000000000..9a10107b0fa
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IWritableIndex.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.core.index;
+
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * Interface used by the indexer to write to the index.
+ *
+ * @since 4.0
+ */
+public interface IWritableIndex extends IIndex {
+
+ /**
+ * Creates a file object for the given location or returns an existing one.
+ */
+ IIndexFragmentFile addFile(String fileLocation) throws CoreException;
+
+ /**
+ * Adds an AST name to the given file.
+ */
+ void addName(IIndexFragmentFile sourceFile, IASTName name) throws CoreException;
+
+ /**
+ * Adds a AST macro to the given file.
+ */
+ void addMacro(IIndexFragmentFile sourceFile, IASTPreprocessorMacroDefinition macro) throws CoreException;
+
+ /**
+ * Adds an include to the given file.
+ */
+ void addInclude(IIndexFragmentFile sourceFile, IIndexFragmentFile destFile) throws CoreException;
+
+ /**
+ * Clears the entire index.
+ */
+ void clear() throws CoreException;
+
+ /**
+ * Clears the given file in the index.
+ */
+ void clearFile(IIndexFragmentFile file) throws CoreException;
+
+ /**
+ * Acquires a write lock, while giving up a certain amount of read locks.
+ */
+ void acquireWriteLock(int giveupReadLockCount) throws InterruptedException;
+
+ /**
+ * Releases a write lock, reestablishing a certain amount of read locks.
+ */
+ void releaseWriteLock(int establishReadLockCount);
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IWritableIndexFragment.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IWritableIndexFragment.java
new file mode 100644
index 00000000000..b2681ce0d24
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IWritableIndexFragment.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.core.index;
+
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * The interface that an actual storage for an index has to implement.
+ */
+public interface IWritableIndexFragment extends IIndexFragment {
+
+ /**
+ * Clears the entire fragment.
+ */
+ void clear() throws CoreException;
+
+ /**
+ * Clears the given file in the index.
+ */
+ void clearFile(IIndexFragmentFile file) throws CoreException;
+
+ /**
+ * Creates a file object for the given location or returns an existing one.
+ */
+ IIndexFragmentFile addFile(String fileLocation) throws CoreException;
+
+ /**
+ * Adds an include to the given file.
+ */
+ void addInclude(IIndexFragmentFile sourceFile, IIndexFragmentFile destFile) throws CoreException;
+
+ /**
+ * Adds a AST macro to the given file.
+ */
+ void addMacro(IIndexFragmentFile sourceFile, IASTPreprocessorMacroDefinition macro) throws CoreException;
+
+ /**
+ * Adds an AST name to the given file.
+ */
+ void addName(IIndexFragmentFile sourceFile, IASTName name) throws CoreException;
+
+ /**
+ * Acquires a write lock, while giving up a certain amount of read locks.
+ */
+ void acquireWriteLock(int giveupReadLockCount) throws InterruptedException;
+
+ /**
+ * Releases a write lock, reestablishing a certain amount of read locks.
+ */
+ void releaseWriteLock(int establishReadLockCount);
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IWritableIndexManager.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IWritableIndexManager.java
new file mode 100644
index 00000000000..bda7cfd95a0
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IWritableIndexManager.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.core.index;
+
+import org.eclipse.cdt.core.index.IIndexManager;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.core.runtime.CoreException;
+
+public interface IWritableIndexManager extends IIndexManager {
+
+ IWritableIndex getWritableIndex(ICProject project) throws CoreException;
+
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMCodeReaderFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedCodeReaderFactory.java
index 397fe3c2b4a..af91825ed43 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMCodeReaderFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedCodeReaderFactory.java
@@ -7,8 +7,9 @@
*
* Contributors:
* QNX - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
-package org.eclipse.cdt.internal.core.pdom;
+package org.eclipse.cdt.internal.core.index;
import java.io.File;
import java.io.IOException;
@@ -22,53 +23,34 @@ import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexFile;
+import org.eclipse.cdt.core.index.IIndexInclude;
import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.core.parser.ICodeReaderCache;
import org.eclipse.cdt.core.parser.IMacro;
import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.core.parser.ParserUtil;
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectStyleMacro;
-import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
-import org.eclipse.cdt.internal.core.pdom.dom.PDOMInclude;
-import org.eclipse.cdt.internal.core.pdom.dom.PDOMMacro;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.Path;
/**
* @author Doug Schaefer
*
*/
-public class PDOMCodeReaderFactory implements ICodeReaderFactory {
+public class IndexBasedCodeReaderFactory implements ICodeReaderFactory {
- private final PDOM pdom;
+ private final IIndex index;
- private List workingCopies = new ArrayList(1);
private Map fileCache = new HashMap(); // filename, pdomFile
private Map macroCache = new HashMap();// record, list of IMacros
-
private List usedMacros = new ArrayList();
private static final char[] EMPTY_CHARS = new char[0];
- public PDOMCodeReaderFactory(PDOM pdom) {
- this.pdom = pdom;
- }
-
- public PDOMCodeReaderFactory(PDOM pdom, IWorkingCopy workingCopy) {
- this(pdom);
- workingCopies.add(workingCopy);
- }
-
- public PDOMFile getCachedFile(String filename) throws CoreException {
- PDOMFile file = (PDOMFile)fileCache.get(filename);
- if (file == null) {
- file = pdom.addFile(filename);
- fileCache.put(filename, file);
- }
- return file;
+ public IndexBasedCodeReaderFactory(IIndex index) {
+ this.index = index;
}
public int getUniqueIdentifier() {
@@ -76,38 +58,30 @@ public class PDOMCodeReaderFactory implements ICodeReaderFactory {
}
public CodeReader createCodeReaderForTranslationUnit(String path) {
- return ParserUtil.createReader(path,
- workingCopies != null ? workingCopies.iterator() : null);
- }
-
- public CodeReader createCodeReaderForTranslationUnit(ITranslationUnit tu) {
- return new CodeReader(tu.getResource().getLocation().toOSString(), tu.getContents());
+ return ParserUtil.createReader(path, null);
}
- private void fillMacros(PDOMFile file, IScanner scanner, Set visited) throws CoreException {
- Integer record = new Integer(file.getRecord());
- if (visited.contains(record))
+ private void fillMacros(IIndexFragmentFile file, IScanner scanner, Set visited) throws CoreException {
+ Object key= file.getLocation(); // mstodo revisit, the pdom-id was faster but cannot be used in indexes.
+ if (!visited.add(key)) {
return;
- visited.add(record);
+ }
// Follow the includes
- PDOMInclude include = file.getFirstInclude();
- while (include != null) {
- fillMacros(include.getIncludes(), scanner, visited);
- include = include.getNextInIncludes();
+ IIndexInclude[] includeDirectives= file.getIncludes();
+ for (int i = 0; i < includeDirectives.length; i++) {
+ IIndexFragmentFile includedFile= (IIndexFragmentFile) index.resolveInclude(includeDirectives[i]);
+ if (includedFile != null) {
+ fillMacros(includedFile, scanner, visited);
+ }
+ // mstodo revisit, what if includedFile == null (problem with index??)
}
// Add in my macros now
- IMacro[] macros = (IMacro[])macroCache.get(record);
+ IMacro[] macros = (IMacro[]) macroCache.get(key);
if (macros == null) {
- List macroList = new ArrayList();
- PDOMMacro macro = file.getFirstMacro();
- while (macro != null) {
- macroList.add(macro.getMacro());
- macro = macro.getNextMacro();
- }
- macros = (IMacro[])macroList.toArray(new IMacro[macroList.size()]);
- macroCache.put(record, macros);
+ macros= file.getMacros();
+ macroCache.put(key, macros);
}
for (int i = 0; i < macros.length; ++i)
@@ -128,11 +102,12 @@ public class PDOMCodeReaderFactory implements ICodeReaderFactory {
} catch (IOException e) {
// ignore and use the path we were passed in
}
- PDOMFile file = (PDOMFile)fileCache.get(path);
+ IIndexFragmentFile file = getCachedFile(path);
if (file == null) {
- file = pdom.getFile(path);
- if (file != null)
- fileCache.put(path, file);
+ file = (IIndexFragmentFile) index.getFile(new Path(path));
+ if (file != null) {
+ addFileToCache(path, file);
+ }
}
if (file != null) {
// Already got things from here,
@@ -141,8 +116,7 @@ public class PDOMCodeReaderFactory implements ICodeReaderFactory {
return new CodeReader(path, EMPTY_CHARS);
}
} catch (CoreException e) {
- CCorePlugin.log(new CoreException(new Status(IStatus.ERROR,
- CCorePlugin.PLUGIN_ID, 0, "PDOM Exception", e)));
+ CCorePlugin.log(e);
}
return ParserUtil.createReader(path, null);
@@ -166,4 +140,28 @@ public class PDOMCodeReaderFactory implements ICodeReaderFactory {
return null;
}
+ protected IIndexFragmentFile getCachedFile(String filename) throws CoreException {
+ IIndexFragmentFile file = (IIndexFragmentFile) fileCache.get(filename);
+ if (file == null) {
+ file = (IIndexFragmentFile) index.getFile(new Path(filename));
+ if (file != null) {
+ addFileToCache(filename, file);
+ }
+ }
+ return file;
+ }
+
+ protected void addFileToCache(String filename, IIndexFile file) {
+ fileCache.put(filename, file);
+ }
+
+ public IIndexFragmentFile createCachedFile(IWritableIndex index, String location) throws CoreException {
+ assert this.index == index;
+
+ IIndexFragmentFile file= getCachedFile(location);
+ if (file == null) {
+ file= index.addFile(location);
+ }
+ return file;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/Messages.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/Messages.java
new file mode 100644
index 00000000000..f643b9d53b5
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/Messages.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.core.index;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.core.index.messages"; //$NON-NLS-1$
+ public static String CIndex_FindBindingsTask_label;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/WritableCIndex.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/WritableCIndex.java
new file mode 100644
index 00000000000..480581059f9
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/WritableCIndex.java
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.core.index;
+
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
+import org.eclipse.core.runtime.CoreException;
+
+public class WritableCIndex extends CIndex implements IWritableIndex {
+
+ final private IWritableIndexFragment[] fWritableFragments;
+ private boolean fIsWriteLocked= false;
+
+ public WritableCIndex(IWritableIndexFragment[] writable, IIndexFragment[] readonly) {
+ super (concat(writable, readonly));
+ fWritableFragments= writable;
+ }
+
+ private static IIndexFragment[] concat(IIndexFragment[] writable, IIndexFragment[] readonly) {
+ IIndexFragment[] result= new IIndexFragment[writable.length + readonly.length];
+ System.arraycopy(writable, 0, result, 0, writable.length);
+ System.arraycopy(readonly, 0, result, writable.length, readonly.length);
+ return result;
+ }
+
+ public IIndexFragmentFile addFile(String fileLocation) throws CoreException {
+ IWritableIndexFragment frag= selectFragment(fileLocation);
+
+ return frag.addFile(fileLocation);
+ }
+
+ private IWritableIndexFragment selectFragment(String fileLocation) {
+ // todo handling of multiple writable indices
+ assert fWritableFragments.length == 1;
+ return fWritableFragments[0];
+ }
+
+ public void addInclude(IIndexFragmentFile sourceFile, IIndexFragmentFile destFile) throws CoreException {
+ IIndexFragment indexFragment = sourceFile.getIndexFragment();
+ assert isWritableFragment(indexFragment);
+ assert isWritableFragment(destFile.getIndexFragment());
+
+ ((IWritableIndexFragment) indexFragment).addInclude(sourceFile, destFile);
+ }
+
+ private boolean isWritableFragment(IIndexFragment frag) {
+ for (int i = 0; i < fWritableFragments.length; i++) {
+ if (fWritableFragments[i] == frag) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void addMacro(IIndexFragmentFile sourceFile, IASTPreprocessorMacroDefinition macro) throws CoreException {
+ IIndexFragment indexFragment = sourceFile.getIndexFragment();
+ assert isWritableFragment(indexFragment);
+
+ ((IWritableIndexFragment) indexFragment).addMacro(sourceFile, macro);
+ }
+
+ public void addName(IIndexFragmentFile sourceFile, IASTName name) throws CoreException {
+ IIndexFragment indexFragment = sourceFile.getIndexFragment();
+ assert isWritableFragment(indexFragment);
+
+ ((IWritableIndexFragment) indexFragment).addName(sourceFile, name);
+ }
+
+ public void clear() throws CoreException {
+ for (int i = 0; i < fWritableFragments.length; i++) {
+ IWritableIndexFragment frag = fWritableFragments[i];
+ frag.clear();
+ }
+ }
+
+ public void clearFile(IIndexFragmentFile file) throws CoreException {
+ IIndexFragment indexFragment = file.getIndexFragment();
+ assert isWritableFragment(indexFragment);
+
+ ((IWritableIndexFragment) indexFragment).clearFile(file);
+ }
+
+
+ public synchronized void acquireReadLock() throws InterruptedException {
+ assert !fIsWriteLocked: "Read locks are not allowed while write-locked."; //$NON-NLS-1$
+ super.acquireReadLock();
+ }
+
+ public synchronized void releaseReadLock() {
+ assert !fIsWriteLocked: "Read locks are not allowed while write-locked."; //$NON-NLS-1$
+ super.releaseReadLock();
+ }
+
+ public synchronized void acquireWriteLock(int giveupReadlockCount) throws InterruptedException {
+ assert !fIsWriteLocked: "Multiple write locks is not allowed"; //$NON-NLS-1$
+ assert giveupReadlockCount == getReadLockCount(): "Unexpected read lock is not allowed"; //$NON-NLS-1$
+
+ fIsWriteLocked= true;
+ int i= 0;
+ try {
+ for (i = 0; i < fWritableFragments.length; i++) {
+ fWritableFragments[i].acquireWriteLock(giveupReadlockCount);
+ }
+ }
+ finally {
+ if (i < fWritableFragments.length) {
+ // rollback
+ fIsWriteLocked= false;
+ while (--i >= 0) {
+ fWritableFragments[i].releaseWriteLock(giveupReadlockCount);
+ }
+ }
+ }
+ }
+
+ public synchronized void releaseWriteLock(int establishReadlockCount) {
+ assert fIsWriteLocked: "No write lock to be released"; //$NON-NLS-1$
+ assert establishReadlockCount == getReadLockCount(): "Unexpected read lock is not allowed"; //$NON-NLS-1$
+
+ fIsWriteLocked= false;
+ int i= 0;
+ for (i = 0; i < fWritableFragments.length; i++) {
+ fWritableFragments[i].releaseWriteLock(establishReadlockCount);
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/messages.properties b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/messages.properties
new file mode 100644
index 00000000000..cfa64aacf3e
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/messages.properties
@@ -0,0 +1 @@
+CIndex_FindBindingsTask_label=Find Bindings
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/LocationMap.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/LocationMap.java
index 9402ccb924a..713e0bfa9fb 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/LocationMap.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/LocationMap.java
@@ -7,9 +7,11 @@
*
* Contributors:
* IBM - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.parser.scanner2;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
import org.eclipse.cdt.core.dom.ast.IASTFunctionStyleMacroParameter;
import org.eclipse.cdt.core.dom.ast.IASTMacroExpansion;
@@ -40,6 +42,7 @@ import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.core.parser.IMacro;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
+import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ASTPreprocessorSelectionResult;
@@ -708,6 +711,10 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
public void setBinding(IBinding binding) {
//do nothing
}
+
+ public ILinkage getLinkage() {
+ return Linkage.NO_LINKAGE;
+ }
}
/**
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/MacroBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/MacroBinding.java
index 52694649582..7d1a1327e11 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/MacroBinding.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/MacroBinding.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2006 IBM Corporation 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
@@ -7,12 +7,15 @@
*
* Contributors:
* IBM - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.parser.scanner2;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.core.runtime.PlatformObject;
public class MacroBinding extends PlatformObject implements IMacroBinding {
@@ -47,5 +50,7 @@ public class MacroBinding extends PlatformObject implements IMacroBinding {
return definition;
}
-
+ public ILinkage getLinkage() {
+ return Linkage.NO_LINKAGE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/Messages.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/Messages.java
new file mode 100644
index 00000000000..46fa8d8d52d
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/Messages.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.core.pdom;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.core.pdom.messages"; //$NON-NLS-1$
+ public static String WritablePDOM_error_unknownLinkage;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java
index 6e6165cb00e..3870e564894 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java
@@ -12,6 +12,7 @@
package org.eclipse.cdt.internal.core.pdom;
import java.util.ArrayList;
+import java.util.BitSet;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
@@ -20,24 +21,31 @@ import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.dom.ICodeReaderFactory;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.IPDOM;
import org.eclipse.cdt.core.dom.IPDOMNode;
-import org.eclipse.cdt.core.dom.IPDOMResolver;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
-import org.eclipse.cdt.core.dom.IPDOMWriter;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
-import org.eclipse.cdt.core.model.ILanguage;
-import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexBinding;
+import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.cdt.core.index.IndexFilter;
import org.eclipse.cdt.core.model.LanguageManager;
+import org.eclipse.cdt.internal.core.index.IIndexFragment;
+import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
+import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
+import org.eclipse.cdt.internal.core.index.IIndexFragmentInclude;
+import org.eclipse.cdt.internal.core.index.IIndexFragmentName;
+import org.eclipse.cdt.internal.core.index.IIndexProxyBinding;
import org.eclipse.cdt.internal.core.pdom.db.BTree;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
+import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
+import org.eclipse.cdt.internal.core.pdom.dom.PDOMInclude;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
@@ -54,7 +62,7 @@ import org.eclipse.core.runtime.Status;
*
* @author Doug Schaefer
*/
-public class PDOM extends PlatformObject implements IPDOM, IPDOMResolver, IPDOMWriter {
+public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
private Database db;
@@ -78,19 +86,14 @@ public class PDOM extends PlatformObject implements IPDOM, IPDOMResolver, IPDOMW
// Local caches
private BTree fileIndex;
- private Map linkageCache = new HashMap();
+ private Map fLinkageIDCache = new HashMap();
public PDOM(IPath dbPath) throws CoreException {
// Load up the database
db = new Database(dbPath.toOSString());
if (db.getVersion() == VERSION) {
- // populate the linkage cache
- PDOMLinkage linkage = getFirstLinkage();
- while (linkage != null) {
- linkageCache.put(linkage.getLanguage().getId(), linkage);
- linkage = linkage.getNextLinkage();
- }
+ readLinkages();
}
}
@@ -101,24 +104,12 @@ public class PDOM extends PlatformObject implements IPDOM, IPDOMResolver, IPDOMW
} else
return false;
}
-
- public Object getAdapter(Class adapter) {
- if (adapter == IPDOM.class)
- return this;
- else if (adapter == IPDOMResolver.class)
- return this;
- else if (adapter == IPDOMWriter.class)
- return this;
- else if (adapter == PDOM.class)
- // TODO this use is deprecated (or bad at least)
- return this;
- else
- return super.getAdapter(adapter);
- }
public void accept(IPDOMVisitor visitor) throws CoreException {
- for (PDOMLinkage linkage = getFirstLinkage(); linkage != null; linkage = linkage.getNextLinkage())
+ for (Iterator iter = fLinkageIDCache.values().iterator(); iter.hasNext();) {
+ PDOMLinkage linkage = (PDOMLinkage) iter.next();
linkage.accept(visitor);
+ }
}
public static interface IListener {
@@ -164,11 +155,11 @@ public class PDOM extends PlatformObject implements IPDOM, IPDOMResolver, IPDOMW
return record != 0 ? new PDOMFile(this, record) : null;
}
- public PDOMFile getFile(IPath path) throws CoreException {
+ public IIndexFragmentFile getFile(IPath path) throws CoreException {
return getFile(path.toOSString());
}
- public PDOMFile addFile(String filename) throws CoreException {
+ protected IIndexFragmentFile addFile(String filename) throws CoreException {
PDOMFile file = getFile(filename);
if (file == null) {
file = new PDOMFile(this, filename);
@@ -177,7 +168,7 @@ public class PDOM extends PlatformObject implements IPDOM, IPDOMResolver, IPDOMW
return file;
}
- public void clear() throws CoreException {
+ protected void clear() throws CoreException {
Database db = getDB();
// Clear out the database
db.clear();
@@ -187,38 +178,23 @@ public class PDOM extends PlatformObject implements IPDOM, IPDOMResolver, IPDOMW
fileIndex = null;
db.putInt(LINKAGES, 0);
- linkageCache.clear();
+ fLinkageIDCache.clear();
}
public boolean isEmpty() throws CoreException {
- return getFirstLinkage() == null;
- }
-
- public ICodeReaderFactory getCodeReaderFactory() {
- return new PDOMCodeReaderFactory(this);
- }
-
- public ICodeReaderFactory getCodeReaderFactory(IWorkingCopy root) {
- return new PDOMCodeReaderFactory(this, root);
+ return getFirstLinkageRecord() == 0;
}
+ /**
+ * @deprecated use findDeclarations() instead.
+ */
public IName[] getDeclarations(IBinding binding) throws CoreException {
- if (binding instanceof PDOMBinding) {
- List names = new ArrayList();
- for (PDOMName name = ((PDOMBinding)binding).getFirstDeclaration();
- name != null;
- name = name.getNextInBinding())
- names.add(name);
- // Add in definitions, too
- for (PDOMName name = ((PDOMBinding)binding).getFirstDefinition();
- name != null;
- name = name.getNextInBinding())
- names.add(name);
- return (IName[])names.toArray(new IName[names.size()]);
- }
- return IName.EMPTY_NAME_ARRAY;
+ return findNames(binding, IIndex.FIND_DECLARATIONS_DEFINITIONS);
}
+ /**
+ * @deprecated use findDefinitions() instead
+ */
public IName[] getDefinitions(IBinding binding) throws CoreException {
if (binding instanceof PDOMBinding) {
List names = new ArrayList();
@@ -226,11 +202,14 @@ public class PDOM extends PlatformObject implements IPDOM, IPDOMResolver, IPDOMW
name != null;
name = name.getNextInBinding())
names.add(name);
- return (IName[])names.toArray(new IName[names.size()]);
+ return (IName[]) names.toArray(new IIndexName[names.size()]);
}
- return IName.EMPTY_NAME_ARRAY;
+ return IIndexFragmentName.EMPTY_NAME_ARRAY;
}
-
+
+ /**
+ * @deprecated use findReferences() instead
+ */
public IName[] getReferences(IBinding binding) throws CoreException {
if (binding instanceof PDOMBinding) {
List names = new ArrayList();
@@ -238,19 +217,16 @@ public class PDOM extends PlatformObject implements IPDOM, IPDOMResolver, IPDOMW
name != null;
name = name.getNextInBinding())
names.add(name);
- return (IName[])names.toArray(new IName[names.size()]);
+ return (IName[]) names.toArray(new IIndexName[names.size()]);
}
- return IName.EMPTY_NAME_ARRAY;
+ return IIndexFragmentName.EMPTY_NAME_ARRAY;
}
-
- public IBinding resolveBinding(IASTName name) {
- try {
- ILanguage language = name.getTranslationUnit().getLanguage();
- return getLinkage(language).resolveBinding(name);
- } catch (CoreException e) {
- CCorePlugin.log(e);
- }
+ public IIndexProxyBinding findBinding(IASTName name) throws CoreException {
+ PDOMLinkage linkage= adaptLinkage(name.getLinkage());
+ if (linkage != null) {
+ return linkage.resolveBinding(name);
+ }
return null;
}
@@ -258,14 +234,19 @@ public class PDOM extends PlatformObject implements IPDOM, IPDOMResolver, IPDOMW
private final Pattern[] pattern;
private final IProgressMonitor monitor;
- private final IBinding[] match;
- private int level = 0;
+ private final ArrayList currentPath= new ArrayList();
+ private final ArrayList matchStack= new ArrayList();
private List bindings = new ArrayList();
+ private boolean isFullyQualified;
+ private BitSet matchesUpToLevel;
- public BindingFinder(Pattern[] pattern, IProgressMonitor monitor) {
+ public BindingFinder(Pattern[] pattern, boolean isFullyQualified, IProgressMonitor monitor) {
this.pattern = pattern;
this.monitor = monitor;
- match = new IBinding[pattern.length];
+ this.isFullyQualified= isFullyQualified;
+ matchesUpToLevel= new BitSet();
+ matchesUpToLevel.set(0);
+ matchStack.add(matchesUpToLevel);
}
public boolean visit(IPDOMNode node) throws CoreException {
@@ -274,71 +255,117 @@ public class PDOM extends PlatformObject implements IPDOM, IPDOMResolver, IPDOMW
if (node instanceof IBinding) {
IBinding binding = (IBinding)node;
- if (pattern[level].matcher(binding.getName()).matches()) {
- if (level < pattern.length - 1) {
- match[level++] = binding;
- } else {
- bindings.add(binding);
- // Only visit children if using simple name
- return pattern.length == 1;
+ String name = binding.getName();
+
+ // check if we have a complete match.
+ final int lastIdx = pattern.length-1;
+ if (matchesUpToLevel.get(lastIdx) && pattern[lastIdx].matcher(name).matches()) {
+ bindings.add(binding);
+ }
+
+ // check if we have a partial match
+ if (binding instanceof IPDOMMemberOwner) {
+ boolean visitNextLevel= false;
+ BitSet updatedMatchesUpToLevel= new BitSet();
+ if (!isFullyQualified) {
+ updatedMatchesUpToLevel.set(0);
+ visitNextLevel= true;
+ }
+ for (int i=0; i < lastIdx; i++) {
+ if (matchesUpToLevel.get(i) && pattern[i].matcher(name).matches()) {
+ updatedMatchesUpToLevel.set(i+1);
+ visitNextLevel= true;
+ }
+ }
+ if (visitNextLevel) {
+ matchStack.add(matchesUpToLevel);
+ matchesUpToLevel= updatedMatchesUpToLevel;
+ currentPath.add(binding);
+ return true;
}
}
+ return false;
}
-
- return true;
+ return false;
}
-
+
public void leave(IPDOMNode node) throws CoreException {
- if (node instanceof IBinding) {
- if (level > 0 && match[level - 1] == (IBinding)node)
- // pop the stack
- --level;
+ final int idx= currentPath.size()-1;
+ if (idx >= 0 && currentPath.get(idx) == node) {
+ currentPath.remove(idx);
+ matchesUpToLevel= (BitSet) matchStack.remove(matchStack.size()-1);
}
}
- public IBinding[] getBindings() {
- return (IBinding[])bindings.toArray(new IBinding[bindings.size()]);
+ public IIndexFragmentBinding[] getBindings() {
+ return (IIndexFragmentBinding[])bindings.toArray(new IIndexFragmentBinding[bindings.size()]);
}
}
+ /**
+ * @deprecated
+ */
public IBinding[] findBindings(Pattern pattern, IProgressMonitor monitor) throws CoreException {
- return findBindings(new Pattern[] { pattern }, monitor);
+ return findBindings(new Pattern[] { pattern }, false, new IndexFilter(), monitor);
}
-
+
+ /**
+ * @deprecated
+ */
public IBinding[] findBindings(Pattern[] pattern, IProgressMonitor monitor) throws CoreException {
- BindingFinder finder = new BindingFinder(pattern, monitor);
- PDOMLinkage linkage = getFirstLinkage();
- while (linkage != null) {
- try {
- linkage.accept(finder);
- } catch (CoreException e) {
- if (e.getStatus() != Status.OK_STATUS)
- throw e;
- else
- return new IBinding[0];
+ return findBindings(pattern, true, new IndexFilter(), monitor);
+ }
+
+ public IIndexBinding[] findBindings(Pattern pattern, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
+ return findBindings(new Pattern[] { pattern }, isFullyQualified, filter, monitor);
+ }
+
+ public IIndexFragmentBinding[] findBindings(Pattern[] pattern, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
+ BindingFinder finder = new BindingFinder(pattern, isFullyQualified, monitor);
+ for (Iterator iter = fLinkageIDCache.values().iterator(); iter.hasNext();) {
+ PDOMLinkage linkage = (PDOMLinkage) iter.next();
+ if (filter.acceptLinkage(linkage)) {
+ try {
+ linkage.accept(finder);
+ } catch (CoreException e) {
+ if (e.getStatus() != Status.OK_STATUS)
+ throw e;
+ else
+ return IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
+ }
}
- linkage = linkage.getNextLinkage();
}
return finder.getBindings();
}
-
- public PDOMLinkage getLinkage(ILanguage language) throws CoreException {
- PDOMLinkage linkage = (PDOMLinkage)linkageCache.get(language.getId());
- if (linkage != null)
- return linkage;
-
- // Need to create it
- IPDOMLinkageFactory factory = (IPDOMLinkageFactory)language.getAdapter(IPDOMLinkageFactory.class);
- String id = language.getId();
- int linkrec = db.getInt(LINKAGES);
- while (linkrec != 0) {
- if (PDOMLinkage.getId(this, linkrec).equals(id))
- return factory.getLinkage(this, linkrec);
- else
- linkrec = PDOMLinkage.getNextLinkageRecord(this, linkrec);
+
+ private void readLinkages() throws CoreException {
+ // populate the linkage cache
+ int record= getFirstLinkageRecord();
+ while (record != 0) {
+ String linkageID= PDOMLinkage.getId(this, record).getString();
+ IPDOMLinkageFactory factory= LanguageManager.getInstance().getPDOMLinkageFactory(linkageID);
+ if (factory != null) {
+ PDOMLinkage linkage= factory.getLinkage(this, record);
+ fLinkageIDCache.put(linkageID, linkage);
+ }
+ record= PDOMLinkage.getNextLinkageRecord(this, record);
}
-
- return factory.createLinkage(this);
+ }
+
+ public PDOMLinkage getLinkage(String linkageID) throws CoreException {
+ return (PDOMLinkage) fLinkageIDCache.get(linkageID);
+ }
+
+ public PDOMLinkage createLinkage(String linkageID) throws CoreException {
+ PDOMLinkage pdomLinkage= (PDOMLinkage) fLinkageIDCache.get(linkageID);
+ if (pdomLinkage == null) {
+ // Need to create it
+ IPDOMLinkageFactory factory= LanguageManager.getInstance().getPDOMLinkageFactory(linkageID);
+ if (factory != null) {
+ return factory.createLinkage(this);
+ }
+ }
+ return pdomLinkage;
}
public PDOMLinkage getLinkage(int record) throws CoreException {
@@ -347,7 +374,7 @@ public class PDOM extends PlatformObject implements IPDOM, IPDOMResolver, IPDOMW
// First check the cache. We do a linear search since there will be very few linkages
// in a given database.
- Iterator i = linkageCache.values().iterator();
+ Iterator i = fLinkageIDCache.values().iterator();
while (i.hasNext()) {
PDOMLinkage linkage = (PDOMLinkage)i.next();
if (linkage.getRecord() == record)
@@ -355,23 +382,22 @@ public class PDOM extends PlatformObject implements IPDOM, IPDOMResolver, IPDOMW
}
String id = PDOMLinkage.getId(this, record).getString();
- ILanguage language = LanguageManager.getInstance().getLanguage(id);
- return getLinkage(language);
+ return createLinkage(id);
}
- public PDOMLinkage getFirstLinkage() throws CoreException {
- return getLinkage(db.getInt(LINKAGES));
+ private int getFirstLinkageRecord() throws CoreException {
+ return db.getInt(LINKAGES);
}
public PDOMLinkage[] getLinkages() {
- Collection values = linkageCache.values();
- return (PDOMLinkage[])values.toArray(new PDOMLinkage[values.size()]);
+ Collection values = fLinkageIDCache.values();
+ return (PDOMLinkage[]) values.toArray(new PDOMLinkage[values.size()]);
}
public void insertLinkage(PDOMLinkage linkage) throws CoreException {
linkage.setNext(db.getInt(LINKAGES));
db.putInt(LINKAGES, linkage.getRecord());
- linkageCache.put(linkage.getLanguage().getId(), linkage);
+ fLinkageIDCache.put(linkage.getID(), linkage);
}
public PDOMBinding getBinding(int record) throws CoreException {
@@ -388,6 +414,7 @@ public class PDOM extends PlatformObject implements IPDOM, IPDOMResolver, IPDOMW
private Object mutex = new Object();
private int lockCount;
private int waitingReaders;
+ private long lastWriteAccess= 0;
public void acquireReadLock() throws InterruptedException {
synchronized (mutex) {
@@ -401,6 +428,7 @@ public class PDOM extends PlatformObject implements IPDOM, IPDOMResolver, IPDOMW
public void releaseReadLock() {
synchronized (mutex) {
+ assert lockCount > 0: "No lock to release"; //$NON-NLS-1$
if (lockCount > 0)
--lockCount;
mutex.notifyAll();
@@ -408,7 +436,22 @@ public class PDOM extends PlatformObject implements IPDOM, IPDOMResolver, IPDOMW
}
public void acquireWriteLock() throws InterruptedException {
+ acquireWriteLock(0);
+ }
+
+ public void acquireWriteLock(int giveupReadLocks) throws InterruptedException {
synchronized (mutex) {
+ if (giveupReadLocks > 0) {
+ // giveup on read locks
+ assert lockCount >= giveupReadLocks: "Not enough locks to release"; //$NON-NLS-1$
+ if (lockCount >= giveupReadLocks) {
+ lockCount-= giveupReadLocks;
+ }
+ else if (lockCount >= 0) {
+ lockCount= 0;
+ }
+ }
+
// Let the readers go first
while (lockCount != 0 || waitingReaders > 0)
mutex.wait();
@@ -417,12 +460,131 @@ public class PDOM extends PlatformObject implements IPDOM, IPDOMResolver, IPDOMW
}
public void releaseWriteLock() {
+ releaseWriteLock(0);
+ }
+
+ public void releaseWriteLock(int establishReadLocks) {
+ assert lockCount == -1;
+ lastWriteAccess= System.currentTimeMillis();
synchronized (mutex) {
if (lockCount < 0)
- ++lockCount;
+ lockCount= establishReadLocks;
mutex.notifyAll();
}
fireChange();
}
+
+
+ public long getLastWriteAccess() {
+ return lastWriteAccess;
+ }
+
+ protected PDOMLinkage adaptLinkage(ILinkage linkage) throws CoreException {
+ return (PDOMLinkage) fLinkageIDCache.get(linkage.getID());
+ }
+
+ public IIndexProxyBinding adaptBinding(IBinding binding) throws CoreException {
+ if (binding instanceof PDOMBinding) {
+ PDOMBinding pdomBinding= (PDOMBinding) binding;
+ if (pdomBinding.getPDOM() == this) {
+ return pdomBinding;
+ }
+ }
+
+ PDOMLinkage linkage= adaptLinkage(binding.getLinkage());
+ if (linkage != null) {
+ return linkage.adaptBinding(binding);
+ }
+ return null;
+ }
+
+ public IIndexProxyBinding adaptBinding(IIndexProxyBinding binding) throws CoreException {
+ if (binding instanceof IBinding) {
+ return adaptBinding((IBinding) binding);
+ }
+ return null;
+ }
+
+ public IIndexFragmentBinding findBinding(IIndexFragmentName indexName) throws CoreException {
+ if (indexName instanceof PDOMName) {
+ PDOMName pdomName= (PDOMName) indexName;
+ return pdomName.getPDOMBinding();
+ }
+ return null;
+ }
+
+ public IIndexFragmentName[] findNames(IBinding binding, int options) throws CoreException {
+ IIndexProxyBinding proxyBinding= adaptBinding(binding);
+ if (proxyBinding != null) {
+ return findNames(proxyBinding, options);
+ }
+ return IIndexFragmentName.EMPTY_NAME_ARRAY;
+ }
+
+ public IIndexFragmentName[] findNames(IIndexProxyBinding binding, int options) throws CoreException {
+ PDOMBinding pdomBinding = (PDOMBinding) adaptBinding(binding);
+
+ if (pdomBinding != null) {
+ PDOMName name;
+ List names = new ArrayList();
+ if ((options & FIND_DECLARATIONS) != 0) {
+ for (name= pdomBinding.getFirstDeclaration(); name != null; name= name.getNextInBinding()) {
+ names.add(name);
+ }
+ }
+ if ((options & FIND_DEFINITIONS) != 0) {
+ for (name = pdomBinding.getFirstDefinition(); name != null; name= name.getNextInBinding()) {
+ names.add(name);
+ }
+ }
+ if ((options & FIND_REFERENCES) != 0) {
+ for (name = pdomBinding.getFirstReference(); name != null; name= name.getNextInBinding()) {
+ names.add(name);
+ }
+ }
+ return (IIndexFragmentName[]) names.toArray(new IIndexFragmentName[names.size()]);
+ }
+ return IIndexFragmentName.EMPTY_NAME_ARRAY;
+ }
+
+ public IIndexFragmentInclude[] findIncludedBy(IIndexFragmentFile file) throws CoreException {
+ PDOMFile pdomFile= adaptFile(file);
+ if (pdomFile != null) {
+ List result = new ArrayList();
+ for (PDOMInclude i= pdomFile.getFirstIncludedBy(); i != null; i= i.getNextInIncludedBy()) {
+ result.add(i);
+ }
+ return (IIndexFragmentInclude[]) result.toArray(new PDOMInclude[result.size()]);
+ }
+ return new PDOMInclude[0];
+ }
+
+ private PDOMFile adaptFile(IIndexFragmentFile file) throws CoreException {
+ if (file.getIndexFragment() == this && file instanceof PDOMFile) {
+ return (PDOMFile) file;
+ }
+
+ return getFile(file.getLocation());
+ }
+
+ public IIndexFragmentInclude[] findIncludes(IIndexFragmentFile file) throws CoreException {
+ PDOMFile pdomFile= adaptFile(file);
+ if (file != null) {
+ List result = new ArrayList();
+ for (PDOMInclude i= pdomFile.getFirstInclude(); i != null; i= i.getNextInIncludes()) {
+ result.add(i);
+ }
+ return (IIndexFragmentInclude[]) result.toArray(new PDOMInclude[result.size()]);
+ }
+ return new PDOMInclude[0];
+ }
+ public IIndexFragmentFile resolveInclude(IIndexFragmentInclude include) throws CoreException {
+ if (include.getFragment() == this && include instanceof PDOMInclude) {
+ PDOMInclude pdomInclude= (PDOMInclude) include;
+ return pdomInclude.getIncludes();
+ }
+ return getFile(include.getIncludesLocation());
+ }
+
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java
index 4ebb4db17eb..9fd39e0b18a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java
@@ -7,10 +7,19 @@
*
* Contributors:
* QNX - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICDescriptor;
@@ -19,12 +28,21 @@ import org.eclipse.cdt.core.dom.IPDOM;
import org.eclipse.cdt.core.dom.IPDOMIndexer;
import org.eclipse.cdt.core.dom.IPDOMIndexerTask;
import org.eclipse.cdt.core.dom.IPDOMManager;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexManager;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ElementChangedEvent;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICElementDelta;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IElementChangedListener;
+import org.eclipse.cdt.internal.core.index.CIndex;
+import org.eclipse.cdt.internal.core.index.EmptyCIndex;
+import org.eclipse.cdt.internal.core.index.IIndexFragment;
+import org.eclipse.cdt.internal.core.index.IWritableIndex;
+import org.eclipse.cdt.internal.core.index.IWritableIndexFragment;
+import org.eclipse.cdt.internal.core.index.IWritableIndexManager;
+import org.eclipse.cdt.internal.core.index.WritableCIndex;
import org.eclipse.cdt.internal.core.pdom.indexer.nulli.PDOMNullIndexer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ProjectScope;
@@ -51,7 +69,7 @@ import org.osgi.service.prefs.BackingStoreException;
*
* @author Doug Schaefer
*/
-public class PDOMManager implements IPDOMManager, IElementChangedListener {
+public class PDOMManager implements IPDOMManager, IWritableIndexManager, IElementChangedListener {
private static final QualifiedName indexerProperty
= new QualifiedName(CCorePlugin.PLUGIN_ID, "pdomIndexer"); //$NON-NLS-1$
@@ -62,7 +80,7 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener {
public synchronized IPDOM getPDOM(ICProject project) throws CoreException {
IProject rproject = project.getProject();
- PDOM pdom = (PDOM)rproject.getSessionProperty(pdomProperty);
+ WritablePDOM pdom = (WritablePDOM)rproject.getSessionProperty(pdomProperty);
if (pdom == null) {
String dbName = rproject.getPersistentProperty(dbNameProperty);
if (dbName == null) {
@@ -71,7 +89,7 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener {
rproject.setPersistentProperty(dbNameProperty, dbName);
}
IPath dbPath = CCorePlugin.getDefault().getStateLocation().append(dbName);
- pdom = new PDOM(dbPath);
+ pdom = new WritablePDOM(dbPath);
rproject.setSessionProperty(pdomProperty, pdom);
if (pdom.versionMismatch())
getIndexer(project).reindex();
@@ -95,6 +113,139 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener {
}
}
+ public IIndex getIndex(ICProject project) throws CoreException {
+ return getIndex(new ICProject[] {project}, 0);
+ }
+
+ public IIndex getIndex(ICProject project, int options) throws CoreException {
+ return getIndex(new ICProject[] {project}, options);
+ }
+
+ public IIndex getIndex(ICProject[] projects) throws CoreException {
+ return getIndex(projects, 0);
+ }
+
+ public IIndex getIndex(ICProject[] projects, int options) throws CoreException {
+ boolean addDependencies= (options & ADD_DEPENDENCIES) != 0;
+ boolean addDependent= (options & ADD_DEPENDENT) != 0;
+
+ HashMap map= new HashMap();
+ Collection selectedProjects= getProjects(projects, addDependencies, addDependent, map, new Integer(1));
+
+ ArrayList pdoms= new ArrayList();
+ for (Iterator iter = selectedProjects.iterator(); iter.hasNext(); ) {
+ ICProject project = (ICProject) iter.next();
+ IWritableIndexFragment pdom= (IWritableIndexFragment) getPDOM(project);
+ if (pdom != null) {
+ pdoms.add(pdom);
+ }
+ }
+ if (pdoms.isEmpty()) {
+ return EmptyCIndex.INSTANCE;
+ }
+
+ // todo add the SDKs
+ int primaryFragmentCount= pdoms.size();
+
+ if (!addDependencies) {
+ projects= (ICProject[]) selectedProjects.toArray(new ICProject[selectedProjects.size()]);
+ selectedProjects.clear();
+ // don't clear the map, so projects are not selected again
+ selectedProjects= getProjects(projects, true, false, map, new Integer(2));
+ for (Iterator iter = selectedProjects.iterator(); iter.hasNext(); ) {
+ ICProject project = (ICProject) iter.next();
+ IWritableIndexFragment pdom= (IWritableIndexFragment) getPDOM(project);
+ if (pdom != null) {
+ pdoms.add(pdom);
+ }
+ }
+ // todo add further SDKs
+ }
+
+ return new CIndex((IIndexFragment[]) pdoms.toArray(new IIndexFragment[pdoms.size()]), primaryFragmentCount);
+ }
+
+ private Collection getProjects(ICProject[] projects, boolean addDependencies, boolean addDependent, HashMap map, Integer markWith) {
+ List projectsToSearch= new ArrayList();
+
+ for (int i = 0; i < projects.length; i++) {
+ ICProject cproject = projects[i];
+ IProject project= cproject.getProject();
+ checkAddProject(project, map, projectsToSearch, markWith);
+ }
+
+ if (addDependencies || addDependent) {
+ for (int i=0; i<projectsToSearch.size(); i++) {
+ IProject project= (IProject) projectsToSearch.get(i);
+ IProject[] nextLevel;
+ try {
+ if (addDependencies) {
+ nextLevel = project.getReferencedProjects();
+ for (int j = 0; j < nextLevel.length; j++) {
+ checkAddProject(nextLevel[j], map, projectsToSearch, markWith);
+ }
+ }
+ if (addDependent) {
+ nextLevel= project.getReferencingProjects();
+ for (int j = 0; j < nextLevel.length; j++) {
+ checkAddProject(nextLevel[j], map, projectsToSearch, markWith);
+ }
+ }
+ } catch (CoreException e) {
+ // silently ignore
+ map.put(project, new Integer(0));
+ }
+ }
+ }
+
+ CoreModel cm= CoreModel.getDefault();
+ Collection result= new ArrayList();
+ for (Iterator iter= map.entrySet().iterator(); iter.hasNext(); ) {
+ Map.Entry entry= (Map.Entry) iter.next();
+ if (entry.getValue() == markWith) {
+ ICProject cproject= cm.create((IProject) entry.getKey());
+ if (cproject != null) {
+ result.add(cproject);
+ }
+ }
+ }
+ return result;
+ }
+
+ private void checkAddProject(IProject project, HashMap map, List projectsToSearch, Integer markWith) {
+ if (map.get(project) == null) {
+ if (project.isOpen()) {
+ map.put(project, markWith);
+ projectsToSearch.add(project);
+ }
+ else {
+ map.put(project, new Integer(0));
+ }
+ }
+ }
+
+ public IWritableIndex getWritableIndex(ICProject project) throws CoreException {
+// mstodo to support dependent projects: Collection selectedProjects= getSelectedProjects(new ICProject[]{project}, false);
+
+ Collection selectedProjects= Collections.singleton(project);
+
+ ArrayList pdoms= new ArrayList();
+ for (Iterator iter = selectedProjects.iterator(); iter.hasNext(); ) {
+ ICProject p = (ICProject) iter.next();
+ IWritableIndexFragment pdom= (IWritableIndexFragment) getPDOM(p);
+ if (pdom != null) {
+ pdoms.add(pdom);
+ }
+ }
+
+ if (pdoms.isEmpty()) {
+ throw new CoreException(CCorePlugin.createStatus(
+ MessageFormat.format("Cannot obtain index for project ''{0}''", new Object[]{project.getElementName()})));
+ }
+
+ return new WritableCIndex((IWritableIndexFragment[]) pdoms.toArray(new IWritableIndexFragment[pdoms.size()]), new IIndexFragment[0]);
+ }
+
public synchronized void elementChanged(ElementChangedEvent event) {
// Only respond to post change events
if (event.getType() != ElementChangedEvent.POST_CHANGE)
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/WritablePDOM.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/WritablePDOM.java
new file mode 100644
index 00000000000..afe6a6e6ce8
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/WritablePDOM.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.core.pdom;
+
+import java.text.MessageFormat;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
+import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
+import org.eclipse.cdt.internal.core.index.IWritableIndexFragment;
+import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
+import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+
+public class WritablePDOM extends PDOM implements IWritableIndexFragment {
+
+ public WritablePDOM(IPath dbPath) throws CoreException {
+ super(dbPath);
+ }
+ public IIndexFragmentFile addFile(String filename) throws CoreException {
+ return super.addFile(filename);
+ }
+
+ public void addInclude(IIndexFragmentFile sourceFile, IIndexFragmentFile destFile) throws CoreException {
+ assert sourceFile.getIndexFragment() == this;
+ assert destFile.getIndexFragment() == this;
+ ((PDOMFile) sourceFile).addIncludeTo((PDOMFile) destFile);
+ }
+
+ public void addMacro(IIndexFragmentFile sourceFile, IASTPreprocessorMacroDefinition macro) throws CoreException {
+ assert sourceFile.getIndexFragment() == this;
+ ((PDOMFile) sourceFile).addMacro(macro);
+ }
+
+ public void addName(IIndexFragmentFile sourceFile, IASTName name) throws CoreException {
+ assert sourceFile.getIndexFragment() == this;
+ PDOMLinkage linkage= createLinkage(name.getLinkage().getID());
+ if (linkage == null) {
+ CCorePlugin.log(MessageFormat.format(Messages.WritablePDOM_error_unknownLinkage, new Object[]{name.getLinkage()}));
+ }
+ else {
+ linkage.addName(name, (PDOMFile) sourceFile);
+ }
+ }
+
+ public void clearFile(IIndexFragmentFile file) throws CoreException {
+ assert file.getIndexFragment() == this;
+ ((PDOMFile) file).clear();
+ }
+
+ public void clear() throws CoreException {
+ super.clear();
+ }
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMBinding.java
index 1ff6c9c95f4..81f043f5c1e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMBinding.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMBinding.java
@@ -7,14 +7,17 @@
*
* Contributors:
* QNX - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
-import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.core.index.IIndexBinding;
+import org.eclipse.cdt.internal.core.index.IIndexFragment;
+import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.core.runtime.CoreException;
@@ -23,7 +26,7 @@ import org.eclipse.core.runtime.CoreException;
* @author Doug Schaefer
*
*/
-public abstract class PDOMBinding extends PDOMNamedNode implements IBinding {
+public abstract class PDOMBinding extends PDOMNamedNode implements IIndexFragmentBinding {
private static final int FIRST_DECL_OFFSET = PDOMNamedNode.RECORD_SIZE + 0; // size 4
private static final int FIRST_DEF_OFFSET = PDOMNamedNode.RECORD_SIZE + 4; // size 4
@@ -152,4 +155,15 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IBinding {
return null;
}
+ public IIndexBinding getParentBinding() throws CoreException {
+ PDOMNode parent= getParentNode();
+ if (parent instanceof IIndexBinding) {
+ return (IIndexBinding) parent;
+ }
+ return null;
+ }
+
+ public IIndexFragment getFragment() {
+ return pdom;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMBindingAdapterFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMBindingAdapterFactory.java
deleted file mode 100644
index 72fa16dfea6..00000000000
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMBindingAdapterFactory.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.core.pdom.dom;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.dom.IPDOM;
-import org.eclipse.cdt.core.dom.ast.DOMException;
-import org.eclipse.cdt.core.dom.ast.IBinding;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.internal.core.pdom.PDOM;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdapterFactory;
-
-/**
- * @author Doug Schaefer
- * This factory adapts IBinding object to PDOMBinding object
- */
-public class PDOMBindingAdapterFactory implements IAdapterFactory {
-
- public Object getAdapter(Object adaptableObject, Class adapterType) {
- if (adaptableObject instanceof PDOMBinding)
- return adaptableObject;
-
- try {
- IBinding binding = (IBinding)adaptableObject;
- ICProject[] projects = CoreModel.getDefault().getCModel().getCProjects();
- for (int i = 0; i < projects.length; ++i) {
- IPDOM ipdom = CCorePlugin.getPDOMManager().getPDOM(projects[i]);
- if (ipdom == null || !(ipdom instanceof PDOM))
- continue;
- PDOM pdom = (PDOM)ipdom;
-
- for (PDOMLinkage linkage = pdom.getFirstLinkage(); linkage != null; linkage = linkage.getNextLinkage()) {
- PDOMBinding pdomBinding = linkage.adaptBinding(binding);
- if (binding != null)
- return pdomBinding;
- }
- }
- return null;
- } catch (DOMException e) {
- CCorePlugin.log(e);
- return null;
- } catch (CoreException e) {
- CCorePlugin.log(e);
- return null;
- }
- }
-
- private static Class[] adapterList = {
- PDOMBinding.class
- };
-
- public Class[] getAdapterList() {
- return adapterList;
- }
-
-}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMFile.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMFile.java
index e9081e2950c..21a9bfc2b95 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMFile.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMFile.java
@@ -7,15 +7,18 @@
*
* Contributors:
* QNX - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.Map;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
+import org.eclipse.cdt.core.index.IIndexInclude;
+import org.eclipse.cdt.core.index.IIndexMacro;
+import org.eclipse.cdt.internal.core.index.IIndexFragment;
+import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
@@ -29,7 +32,7 @@ import org.eclipse.core.runtime.CoreException;
* @author Doug Schaefer
*
*/
-public class PDOMFile {
+public class PDOMFile implements IIndexFragmentFile {
private final PDOM pdom;
private final int record;
@@ -167,11 +170,12 @@ public class PDOMFile {
public void addMacro(IASTPreprocessorMacroDefinition macro) throws CoreException {
PDOMMacro firstMacro = getFirstMacro();
+ // mstodo revisit: this can probably be done more efficiently
// Make sure we don't already have one
char[] name = macro.getName().toCharArray();
PDOMMacro pdomMacro = firstMacro;
while (pdomMacro != null) {
- if (pdomMacro.getName().equals(name))
+ if (pdomMacro.getNameInDB().equals(name))
return;
pdomMacro = pdomMacro.getNextMacro();
}
@@ -235,64 +239,33 @@ public class PDOMFile {
setFirstIncludedBy(include);
}
- public PDOMFile[] getAllIncludedBy() throws CoreException {
- Map files = new HashMap();
- LinkedList todo = new LinkedList();
-
- // Add me in to make sure we don't get caught in a circular include
- IString myFileName = getFileName();
- files.put(myFileName, this);
-
- todo.addLast(this);
- while (todo.size() > 0) {
- PDOMFile file = (PDOMFile)todo.removeFirst();
- PDOMInclude includedBy = file.getFirstIncludedBy();
- while (includedBy != null) {
- PDOMFile incFile = includedBy.getIncludedBy();
- IString incFileName = incFile.getFileName();
- if (files.get(incFileName) == null) {
- files.put(incFileName, incFile);
- todo.addLast(incFile);
- }
- includedBy = includedBy.getNextInIncludedBy();
- }
+
+
+ public IIndexInclude[] getIncludes() throws CoreException {
+ List result= new ArrayList();
+ PDOMInclude include = getFirstInclude();
+ while (include != null) {
+ result.add(include);
+ include = include.getNextInIncludes();
}
-
- // Now remove me
- files.remove(myFileName);
-
- Collection values = files.values();
- return (PDOMFile[])values.toArray(new PDOMFile[values.size()]);
+ return (IIndexInclude[]) result.toArray(new IIndexInclude[result.size()]);
}
-
- public PDOMFile[] getAllIncludes() throws CoreException {
- Map files = new HashMap();
- LinkedList todo = new LinkedList();
-
- // Add me in to make sure we don't get caught in a circular include
- IString myFileName = getFileName();
- files.put(myFileName, this);
-
- todo.addLast(this);
- while (todo.size() > 0) {
- PDOMFile file = (PDOMFile)todo.removeFirst();
- PDOMInclude include = file.getFirstInclude();
- while (include != null) {
- PDOMFile incFile = include.getIncludes();
- IString incFileName = incFile.getFileName();
- if (files.get(incFileName) == null) {
- files.put(incFileName, incFile);
- todo.addLast(incFile);
- }
- include = include.getNextInIncludes();
- }
+
+ public String getLocation() throws CoreException {
+ return getFileName().getString();
+ }
+
+ public IIndexMacro[] getMacros() throws CoreException {
+ List result= new ArrayList();
+ PDOMMacro macro = getFirstMacro();
+ while (macro != null) {
+ result.add(macro);
+ macro = macro.getNextMacro();
}
-
- // Now remove me
- files.remove(myFileName);
-
- Collection values = files.values();
- return (PDOMFile[])values.toArray(new PDOMFile[values.size()]);
+ return (IIndexMacro[]) result.toArray(new IIndexMacro[result.size()]);
}
+ public IIndexFragment getIndexFragment() {
+ return pdom;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMInclude.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMInclude.java
index a4c5d305145..86110ba2d22 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMInclude.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMInclude.java
@@ -7,10 +7,15 @@
*
* Contributors:
* QNX - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom;
+import org.eclipse.cdt.core.index.IIndexFile;
+import org.eclipse.cdt.internal.core.index.IIndexFragment;
+import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
+import org.eclipse.cdt.internal.core.index.IIndexFragmentInclude;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.core.runtime.CoreException;
@@ -18,7 +23,7 @@ import org.eclipse.core.runtime.CoreException;
* @author Doug Schaefer
*
*/
-public class PDOMInclude {
+public class PDOMInclude implements IIndexFragmentInclude {
private final PDOM pdom;
private final int record;
@@ -52,7 +57,7 @@ public class PDOMInclude {
if (prevInclude != null)
prevInclude.setNextInIncludedBy(nextInclude);
else
- getIncludes().setFirstIncludedBy(null);
+ ((PDOMFile) getIncludes()).setFirstIncludedBy(null);
if (nextInclude != null)
nextInclude.setPrevInIncludedBy(prevInclude);
@@ -61,7 +66,7 @@ public class PDOMInclude {
pdom.getDB().free(record);
}
- public PDOMFile getIncludes() throws CoreException {
+ public IIndexFragmentFile getIncludes() throws CoreException {
int rec = pdom.getDB().getInt(record + INCLUDES);
return rec != 0 ? new PDOMFile(pdom, rec) : null;
}
@@ -71,7 +76,7 @@ public class PDOMInclude {
pdom.getDB().putInt(record + INCLUDES, rec);
}
- public PDOMFile getIncludedBy() throws CoreException {
+ public IIndexFile getIncludedBy() throws CoreException {
int rec = pdom.getDB().getInt(record + INCLUDED_BY);
return rec != 0 ? new PDOMFile(pdom, rec) : null;
}
@@ -110,5 +115,17 @@ public class PDOMInclude {
int rec = include != null ? include.getRecord() : 0;
pdom.getDB().putInt(record + INCLUDED_BY_PREV, rec);
}
+
+ public String getIncludedByLocation() throws CoreException {
+ return getIncludedBy().getLocation();
+ }
+
+ public String getIncludesLocation() throws CoreException {
+ return getIncludes().getLocation();
+ }
+
+ public IIndexFragment getFragment() {
+ return pdom;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java
index 74fb052a614..06990ac1cd3 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java
@@ -7,17 +7,27 @@
*
* Contributors:
* QNX - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom;
+import org.eclipse.cdt.core.dom.ILinkage;
+import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IPointerType;
import org.eclipse.cdt.core.dom.ast.IQualifierType;
+import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.index.IIndexBinding;
+import org.eclipse.cdt.core.index.IIndexLinkage;
import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.BTree;
import org.eclipse.cdt.internal.core.pdom.db.Database;
@@ -31,7 +41,7 @@ import org.eclipse.core.runtime.CoreException;
* This class represents a collection of symbols that can be linked together at
* link time. These are generally global symbols specific to a given language.
*/
-public abstract class PDOMLinkage extends PDOMNamedNode {
+public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage {
// record offsets
private static final int ID_OFFSET = PDOMNamedNode.RECORD_SIZE + 0;
@@ -65,22 +75,20 @@ public abstract class PDOMLinkage extends PDOMNamedNode {
return RECORD_SIZE;
}
+ public int getNodeType() {
+ return LINKAGE;
+ }
+
public static IString getId(PDOM pdom, int record) throws CoreException {
Database db = pdom.getDB();
int namerec = db.getInt(record + ID_OFFSET);
return db.getString(namerec);
}
- public abstract ILanguage getLanguage();
-
public static int getNextLinkageRecord(PDOM pdom, int record) throws CoreException {
return pdom.getDB().getInt(record + NEXT_OFFSET);
}
-
- public PDOMLinkage getNextLinkage() throws CoreException {
- return pdom.getLinkage(pdom.getDB().getInt(record + NEXT_OFFSET));
- }
-
+
public void setNext(int nextrec) throws CoreException {
pdom.getDB().putInt(record + NEXT_OFFSET, nextrec);
}
@@ -107,7 +115,7 @@ public abstract class PDOMLinkage extends PDOMNamedNode {
});
}
- public PDOMLinkage getLinkage() throws CoreException {
+ public ILinkage getLinkage() throws CoreException {
return this;
}
@@ -138,6 +146,37 @@ public abstract class PDOMLinkage extends PDOMNamedNode {
public abstract PDOMBinding adaptBinding(IBinding binding) throws CoreException;
- public abstract IBinding resolveBinding(IASTName name) throws CoreException;
-
+ public abstract PDOMBinding resolveBinding(IASTName name) throws CoreException;
+
+ public PDOMNode getAdaptedParent(IBinding binding) throws CoreException {
+ IScope scope = binding.getScope();
+ if (scope == null)
+ return null;
+
+ if (scope instanceof IIndexBinding) {
+ IIndexBinding parent= ((IIndexBinding) scope).getParentBinding();
+ if (parent == null) {
+ return this;
+ }
+ return adaptBinding(parent);
+ }
+
+ // the scope is from the ast
+ IASTNode scopeNode = ASTInternal.getPhysicalNodeOfScope(scope);
+ if (scopeNode instanceof IASTCompoundStatement)
+ return null;
+ else if (scopeNode instanceof IASTTranslationUnit)
+ return this;
+ else {
+ IName scopeName = scope.getScopeName();
+ if (scopeName instanceof IASTName) {
+ IBinding scopeBinding = ((IASTName) scopeName).resolveBinding();
+ PDOMBinding scopePDOMBinding = adaptBinding(scopeBinding);
+ if (scopePDOMBinding != null)
+ return scopePDOMBinding;
+ }
+ }
+
+ return null;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMMacro.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMMacro.java
index be2f2c54891..853fbf9613c 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMMacro.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMMacro.java
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom;
@@ -18,6 +19,7 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IASTFunctionStyleMacroParameter;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorFunctionStyleMacroDefinition;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
+import org.eclipse.cdt.core.index.IIndexMacro;
import org.eclipse.cdt.core.parser.IMacro;
import org.eclipse.cdt.internal.core.parser.scanner2.FunctionStyleMacro;
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectStyleMacro;
@@ -31,10 +33,11 @@ import org.eclipse.core.runtime.CoreException;
*
* @author Doug Schaefer
*/
-public class PDOMMacro {
+public class PDOMMacro implements IIndexMacro {
private final PDOM pdom;
private final int record;
+ private IMacro macro;
private static final int NAME = 0;
private static final int FIRST_PARAMETER = 4;
@@ -77,21 +80,21 @@ public class PDOMMacro {
}
public void delete() throws CoreException {
- getName().delete();
- getExpansion().delete();
+ getNameInDB().delete();
+ getExpansionInDB().delete();
PDOMMacroParameter param = getFirstParameter();
if (param != null)
param.delete();
pdom.getDB().free(record);
}
- public IString getName() throws CoreException {
+ public IString getNameInDB() throws CoreException {
Database db = pdom.getDB();
int rec = db.getInt(record + NAME);
return db.getString(rec);
}
- public IString getExpansion() throws CoreException {
+ public IString getExpansionInDB() throws CoreException {
Database db = pdom.getDB();
int rec = db.getInt(record + EXPANSION);
return db.getString(rec);
@@ -135,7 +138,7 @@ public class PDOMMacro {
private char[] getMacroExpansion() {
try {
- return PDOMMacro.this.getExpansion().getChars();
+ return PDOMMacro.this.getExpansionInDB().getChars();
} catch (CoreException e) {
CCorePlugin.log(e);
return new char[] { ' ' };
@@ -143,7 +146,12 @@ public class PDOMMacro {
}
public IMacro getMacro() throws CoreException {
- char[] name = getName().getChars();
+ rebuildMacro();
+ return macro;
+ }
+
+ private void rebuildMacro() throws CoreException {
+ char[] name = getNameInDB().getChars();
PDOMMacroParameter param = getFirstParameter();
if (param != null) {
List paramList = new ArrayList();
@@ -152,8 +160,38 @@ public class PDOMMacro {
param = param.getNextParameter();
}
char[][] params = (char[][])paramList.toArray(new char[paramList.size()][]);
- return new FunctionStylePDOMMacro(name, params);
+ macro= new FunctionStylePDOMMacro(name, params);
} else
- return new ObjectStylePDOMMacro(name);
+ macro= new ObjectStylePDOMMacro(name);
+ }
+
+ public char[] getSignature() {
+ try {
+ rebuildMacro();
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ return new char[] { ' ' };
+ }
+ return macro.getSignature();
+ }
+
+ public char[] getExpansion() {
+ try {
+ rebuildMacro();
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ return new char[] { ' ' };
+ }
+ return macro.getExpansion();
+ }
+
+ public char[] getName() {
+ try {
+ rebuildMacro();
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ return new char[] { ' ' };
+ }
+ return macro.getName();
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMName.java
index 32ca488b291..cbbf7d155a6 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMName.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMName.java
@@ -14,8 +14,9 @@ package org.eclipse.cdt.internal.core.pdom.dom;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
import org.eclipse.cdt.core.dom.ast.IASTName;
-import org.eclipse.cdt.core.dom.ast.IBinding;
-import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.cdt.internal.core.index.IIndexFragment;
+import org.eclipse.cdt.internal.core.index.IIndexFragmentName;
+import org.eclipse.cdt.internal.core.index.IIndexProxyBinding;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.core.runtime.CoreException;
@@ -24,7 +25,7 @@ import org.eclipse.core.runtime.CoreException;
* @author Doug Schaefer
*
*/
-public class PDOMName implements IIndexName, IASTFileLocation {
+public class PDOMName implements IIndexFragmentName, IASTFileLocation {
private final PDOM pdom;
private final int record;
@@ -162,7 +163,7 @@ public class PDOMName implements IIndexName, IASTFileLocation {
setNameField(FILE_PREV_OFFSET, name);
}
- public IBinding resolveBinding() {
+ public PDOMBinding resolveBinding() {
try {
int bindingRecord = pdom.getDB().getInt(record + BINDING_REC_OFFSET);
return pdom.getBinding(bindingRecord);
@@ -288,5 +289,12 @@ public class PDOMName implements IIndexName, IASTFileLocation {
// Delete our record
pdom.getDB().free(record);
}
+
+ public IIndexFragment getIndexFragment() {
+ return pdom;
+ }
+ public IIndexProxyBinding getBinding() throws CoreException {
+ return getPDOMBinding();
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMNode.java
index 1db98dfdafc..370b5eb41df 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMNode.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMNode.java
@@ -7,12 +7,15 @@
*
* Contributors:
* QNX - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.IPDOMNode;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
+import org.eclipse.cdt.core.index.IIndexLinkage;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.core.runtime.CoreException;
@@ -86,13 +89,17 @@ public abstract class PDOMNode implements IPDOMNode{
public PDOMNode getParentNode() throws CoreException {
int parentrec = pdom.getDB().getInt(record + PARENT);
- return parentrec != 0 ? getLinkage().getNode(parentrec) : null;
+ return parentrec != 0 ? getLinkageImpl().getNode(parentrec) : null;
}
- public PDOMLinkage getLinkage() throws CoreException {
+ public ILinkage getLinkage() throws CoreException {
return getLinkage(pdom, record);
}
-
+
+ public PDOMLinkage getLinkageImpl() throws CoreException {
+ return getLinkage(pdom, record);
+ }
+
public static PDOMLinkage getLinkage(PDOM pdom, int record) throws CoreException {
Database db = pdom.getDB();
int linkagerec = record;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMPointerType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMPointerType.java
index 90b3b9ef9be..944d45d9ba8 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMPointerType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMPointerType.java
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom;
@@ -47,7 +48,7 @@ public class PDOMPointerType extends PDOMNode implements IPointerType,
IType targetType = ((ITypeContainer)type).getType();
int typeRec = 0;
if (type != null) {
- PDOMNode targetTypeNode = getLinkage().addType(this, targetType);
+ PDOMNode targetTypeNode = getLinkageImpl().addType(this, targetType);
if (targetTypeNode != null)
typeRec = targetTypeNode.getRecord();
}
@@ -76,7 +77,7 @@ public class PDOMPointerType extends PDOMNode implements IPointerType,
public IType getType() throws DOMException {
try {
- PDOMNode node = getLinkage().getNode(pdom.getDB().getInt(record + TYPE));
+ PDOMNode node = getLinkageImpl().getNode(pdom.getDB().getInt(record + TYPE));
return node instanceof IType ? (IType)node : null;
} catch (CoreException e) {
CCorePlugin.log(e);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMQualifierType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMQualifierType.java
index 66fe3892f7c..afec28bb507 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMQualifierType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMQualifierType.java
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom;
@@ -47,7 +48,7 @@ public class PDOMQualifierType extends PDOMNode implements IQualifierType,
// type
IType targetType = ((ITypeContainer)type).getType();
if (type != null) {
- PDOMNode targetTypeNode = getLinkage().addType(this, targetType);
+ PDOMNode targetTypeNode = getLinkageImpl().addType(this, targetType);
if (targetTypeNode != null) {
db.putInt(record + TYPE, targetTypeNode.getRecord());
}
@@ -72,7 +73,7 @@ public class PDOMQualifierType extends PDOMNode implements IQualifierType,
public IType getType() throws DOMException {
try {
- PDOMNode node = getLinkage().getNode(pdom.getDB().getInt(record + TYPE));
+ PDOMNode node = getLinkageImpl().getNode(pdom.getDB().getInt(record + TYPE));
return node instanceof IType ? (IType)node : null;
} catch (CoreException e) {
CCorePlugin.log(e);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCLinkage.java
index 2146dc3fe5e..0479f830258 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCLinkage.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCLinkage.java
@@ -35,7 +35,9 @@ import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.dom.ast.c.ICASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage;
+import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
@@ -57,13 +59,13 @@ class PDOMCLinkage extends PDOMLinkage {
}
public PDOMCLinkage(PDOM pdom) throws CoreException {
- super(pdom, GCCLanguage.ID, "C".toCharArray()); //$NON-NLS-1$
+ super(pdom, GCCLanguage.ID, C_LINKAGE_ID.toCharArray());
}
- public int getNodeType() {
- return LINKAGE;
+ public String getID() {
+ return C_LINKAGE_ID;
}
-
+
public static final int CVARIABLE = PDOMLinkage.LAST_NODE_TYPE + 1;
public static final int CFUNCTION = PDOMLinkage.LAST_NODE_TYPE + 2;
public static final int CSTRUCTURE = PDOMLinkage.LAST_NODE_TYPE + 3;
@@ -75,30 +77,7 @@ class PDOMCLinkage extends PDOMLinkage {
public ILanguage getLanguage() {
return new GCCLanguage();
}
-
- public PDOMNode getParent(IBinding binding) throws CoreException {
- IScope scope = binding.getScope();
- if (scope == null)
- return null;
- IASTNode scopeNode = scope.getPhysicalNode();
- if (scopeNode instanceof IASTCompoundStatement)
- return null;
- else if (scopeNode instanceof IASTTranslationUnit)
- return this;
- else {
- IName scopeName = scope.getScopeName();
- if (scopeName != null) {
- IBinding scopeBinding = scopeName.resolveBinding();
- PDOMBinding scopePDOMBinding = adaptBinding(scopeBinding);
- if (scopePDOMBinding != null)
- return scopePDOMBinding;
- }
- }
-
- return null;
- }
-
public PDOMBinding addName(IASTName name, PDOMFile file) throws CoreException {
if (name == null)
return null;
@@ -118,7 +97,7 @@ class PDOMCLinkage extends PDOMLinkage {
PDOMBinding pdomBinding = adaptBinding(binding);
if (pdomBinding == null) {
- PDOMNode parent = getParent(binding);
+ PDOMNode parent = getAdaptedParent(binding);
if (parent == null)
return null;
@@ -236,7 +215,7 @@ class PDOMCLinkage extends PDOMLinkage {
// so if the binding is from another pdom it has to be adapted.
}
- PDOMNode parent = getParent(binding);
+ PDOMNode parent = getAdaptedParent(binding);
if (parent == this) {
FindBinding visitor = new FindBinding(pdom, binding.getNameCharArray(), getBindingType(binding));
getIndex().accept(visitor);
@@ -280,7 +259,7 @@ class PDOMCLinkage extends PDOMLinkage {
return super.getNode(record);
}
- public IBinding resolveBinding(IASTName name) throws CoreException {
+ public PDOMBinding resolveBinding(IASTName name) throws CoreException {
IASTNode parent = name.getParent();
if (parent instanceof IASTIdExpression) {
// reference
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCStructure.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCStructure.java
index e92aeca38ca..03e470d815e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCStructure.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCStructure.java
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.c;
@@ -27,6 +28,7 @@ import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
+import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
import org.eclipse.core.runtime.CoreException;
@@ -51,11 +53,11 @@ public class PDOMCStructure extends PDOMBinding implements ICompositeType, IPDOM
public void accept(IPDOMVisitor visitor) throws CoreException {
super.accept(visitor);
- new PDOMNodeLinkedList(pdom, record+MEMBERLIST, getLinkage()).accept(visitor);
+ new PDOMNodeLinkedList(pdom, record+MEMBERLIST, getLinkageImpl()).accept(visitor);
}
public void addMember(PDOMNode member) throws CoreException {
- new PDOMNodeLinkedList(pdom, record+MEMBERLIST, getLinkage()).addMember(member);
+ new PDOMNodeLinkedList(pdom, record+MEMBERLIST, getLinkageImpl()).addMember(member);
}
public int getNodeType() {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCTypedef.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCTypedef.java
index a2b639a153c..dbbe74ce483 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCTypedef.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCTypedef.java
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.c;
@@ -35,7 +36,7 @@ class PDOMCTypedef extends PDOMBinding implements ITypedef {
super(pdom, parent, name);
IType type = typedef.getType();
- PDOMNode typeNode = parent.getLinkage().addType(this, type);
+ PDOMNode typeNode = parent.getLinkageImpl().addType(this, type);
if (typeNode != null)
pdom.getDB().putInt(record + TYPE, typeNode.getRecord());
}
@@ -55,7 +56,7 @@ class PDOMCTypedef extends PDOMBinding implements ITypedef {
public IType getType() throws DOMException {
try {
int typeRec = pdom.getDB().getInt(record + TYPE);
- return (IType)getLinkage().getNode(typeRec);
+ return (IType)getLinkageImpl().getNode(typeRec);
} catch (CoreException e) {
CCorePlugin.log(e);
return null;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java
index 9bee49195c1..708772310c9 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java
@@ -71,7 +71,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType,
}
public void addMember(PDOMNode member) throws CoreException {
- PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkage());
+ PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkageImpl());
list.addMember(member);
}
@@ -135,7 +135,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType,
public void accept(IPDOMVisitor visitor) throws CoreException {
super.accept(visitor);
- PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkage());
+ PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkageImpl());
list.accept(visitor);
}
@@ -308,10 +308,6 @@ class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType,
throw new PDOMNotImplementedError();
}
- public void flushCache() throws DOMException {
- throw new PDOMNotImplementedError();
- }
-
public IBinding getBinding(IASTName name, boolean resolve) throws DOMException {
return null;
}
@@ -320,10 +316,6 @@ class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType,
return null;
}
- public IASTNode getPhysicalNode() throws DOMException {
- throw new PDOMNotImplementedError();
- }
-
public IName getScopeName() throws DOMException {
try {
PDOMName name = getFirstDefinition();
@@ -336,16 +328,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType,
}
}
- public boolean isFullyCached() throws DOMException {
- return true;
- }
-
public void removeBinding(IBinding binding) throws DOMException {
throw new PDOMNotImplementedError();
}
-
- public void setFullyCached(boolean b) throws DOMException {
- throw new PDOMNotImplementedError();
- }
-
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java
index 06682ce0a3e..1c9cb97ae60 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java
@@ -12,7 +12,6 @@
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
-import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.IPDOMNode;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
@@ -68,17 +67,17 @@ class PDOMCPPLinkage extends PDOMLinkage {
public PDOMCPPLinkage(PDOM pdom)
throws CoreException {
- super(pdom, GPPLanguage.ID, "C++".toCharArray());
+ super(pdom, GPPLanguage.ID, CPP_LINKAGE_ID.toCharArray());
}
- protected int getRecordSize() {
- return RECORD_SIZE;
+ public String getID() {
+ return CPP_LINKAGE_ID;
}
- public int getNodeType() {
- return LINKAGE;
+ protected int getRecordSize() {
+ return RECORD_SIZE;
}
-
+
// Binding types
public static final int CPPVARIABLE = PDOMLinkage.LAST_NODE_TYPE + 1;
public static final int CPPFUNCTION = PDOMLinkage.LAST_NODE_TYPE + 2;
@@ -96,22 +95,7 @@ class PDOMCPPLinkage extends PDOMLinkage {
public ILanguage getLanguage() {
return new GPPLanguage();
}
-
- public PDOMNode getParent(IBinding binding) throws CoreException {
- PDOMNode parent = this;
- IScope scope = binding.getScope();
- if (scope != null) {
- IName scopeName = scope.getScopeName();
- if (scopeName != null) {
- IBinding scopeBinding = scopeName.resolveBinding();
- PDOMBinding scopePDOMBinding = adaptBinding(scopeBinding);
- if (scopePDOMBinding != null)
- parent = scopePDOMBinding;
- }
- }
- return parent;
- }
-
+
public PDOMBinding addName(IASTName name, PDOMFile file) throws CoreException {
if (name == null || name instanceof ICPPASTQualifiedName)
return null;
@@ -132,39 +116,40 @@ class PDOMCPPLinkage extends PDOMLinkage {
PDOMBinding pdomBinding = adaptBinding(binding);
if (pdomBinding == null) {
- PDOMNode parent = getParent(binding);
-
- if (binding instanceof ICPPField && parent instanceof PDOMCPPClassType)
- pdomBinding = new PDOMCPPField(pdom, (PDOMCPPClassType)parent, name);
- else if (binding instanceof ICPPVariable) {
- if (!(binding.getScope() instanceof CPPBlockScope))
- pdomBinding = new PDOMCPPVariable(pdom, parent, name);
- } else if (binding instanceof ICPPMethod && parent instanceof PDOMCPPClassType) {
- pdomBinding = new PDOMCPPMethod(pdom, parent, name);
- } else if (binding instanceof CPPImplicitMethod && parent instanceof PDOMCPPClassType) {
- if(!name.isReference()) {
- //because we got the implicit method off of an IASTName that is not a reference,
- //it is no longer completly implicit and it should be treated as a normal method.
+ PDOMNode parent = getAdaptedParent(binding);
+ if (parent != null) {
+ if (binding instanceof ICPPField && parent instanceof PDOMCPPClassType)
+ pdomBinding = new PDOMCPPField(pdom, (PDOMCPPClassType)parent, name);
+ else if (binding instanceof ICPPVariable) {
+ if (!(binding.getScope() instanceof CPPBlockScope))
+ pdomBinding = new PDOMCPPVariable(pdom, parent, name);
+ } else if (binding instanceof ICPPMethod && parent instanceof PDOMCPPClassType) {
pdomBinding = new PDOMCPPMethod(pdom, parent, name);
+ } else if (binding instanceof CPPImplicitMethod && parent instanceof PDOMCPPClassType) {
+ if(!name.isReference()) {
+ //because we got the implicit method off of an IASTName that is not a reference,
+ //it is no longer completly implicit and it should be treated as a normal method.
+ pdomBinding = new PDOMCPPMethod(pdom, parent, name);
+ }
+ } else if (binding instanceof ICPPFunction) {
+ pdomBinding = new PDOMCPPFunction(pdom, parent, name);
+ } else if (binding instanceof ICPPClassType) {
+ pdomBinding = new PDOMCPPClassType(pdom, parent, name);
+ } else if (binding instanceof ICPPNamespaceAlias) {
+ pdomBinding = new PDOMCPPNamespaceAlias(pdom, parent, name);
+ } else if (binding instanceof ICPPNamespace) {
+ pdomBinding = new PDOMCPPNamespace(pdom, parent, name);
+ } else if (binding instanceof IEnumeration) {
+ pdomBinding = new PDOMCPPEnumeration(pdom, parent, name);
+ } else if (binding instanceof IEnumerator) {
+ IEnumeration enumeration = (IEnumeration)((IEnumerator)binding).getType();
+ PDOMBinding pdomEnumeration = adaptBinding(enumeration);
+ if (pdomEnumeration instanceof PDOMCPPEnumeration)
+ pdomBinding = new PDOMCPPEnumerator(pdom, parent, name,
+ (PDOMCPPEnumeration)pdomEnumeration);
+ } else if (binding instanceof ITypedef) {
+ pdomBinding = new PDOMCPPTypedef(pdom, parent, name, (ITypedef)binding);
}
- } else if (binding instanceof ICPPFunction) {
- pdomBinding = new PDOMCPPFunction(pdom, parent, name);
- } else if (binding instanceof ICPPClassType) {
- pdomBinding = new PDOMCPPClassType(pdom, parent, name);
- } else if (binding instanceof ICPPNamespaceAlias) {
- pdomBinding = new PDOMCPPNamespaceAlias(pdom, parent, name);
- } else if (binding instanceof ICPPNamespace) {
- pdomBinding = new PDOMCPPNamespace(pdom, parent, name);
- } else if (binding instanceof IEnumeration) {
- pdomBinding = new PDOMCPPEnumeration(pdom, parent, name);
- } else if (binding instanceof IEnumerator) {
- IEnumeration enumeration = (IEnumeration)((IEnumerator)binding).getType();
- PDOMBinding pdomEnumeration = adaptBinding(enumeration);
- if (pdomEnumeration instanceof PDOMCPPEnumeration)
- pdomBinding = new PDOMCPPEnumerator(pdom, parent, name,
- (PDOMCPPEnumeration)pdomEnumeration);
- } else if (binding instanceof ITypedef) {
- pdomBinding = new PDOMCPPTypedef(pdom, parent, name, (ITypedef)binding);
}
}
@@ -294,7 +279,7 @@ class PDOMCPPLinkage extends PDOMLinkage {
// so if the binding is from another pdom it has to be adapted.
}
- PDOMNode parent = getParent(binding);
+ PDOMNode parent = getAdaptedParent(binding);
if (parent == this) {
FindBinding visitor = new FindBinding(pdom, binding.getNameCharArray(), getBindingType(binding));
getIndex().accept(visitor);
@@ -318,7 +303,8 @@ class PDOMCPPLinkage extends PDOMLinkage {
return null;
}
- public IBinding resolveBinding(IASTName name) throws CoreException {
+ public PDOMBinding resolveBinding(IASTName name) throws CoreException {
+ // mstodo revisit
IBinding origBinding = name.getBinding();
if (origBinding != null)
return adaptBinding(origBinding);
@@ -329,7 +315,7 @@ class PDOMCPPLinkage extends PDOMLinkage {
IASTName lastName = names[names.length - 1];
PDOMBinding nsBinding = adaptBinding(names[names.length - 2].resolveBinding());
if (nsBinding instanceof IScope) {
- return ((IScope)nsBinding).getBinding(lastName, true);
+ return (PDOMBinding) ((IScope)nsBinding).getBinding(lastName, true);
}
}
IASTNode parent = name.getParent();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespace.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespace.java
index d9ee2268f4e..cd3ef20f4cf 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespace.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespace.java
@@ -125,10 +125,6 @@ class PDOMCPPNamespace extends PDOMCPPBinding
}
}
- public void flushCache() throws DOMException {
- throw new PDOMNotImplementedError();
- }
-
public IBinding getBinding(IASTName name, boolean resolve) throws DOMException {
try {
if (name instanceof ICPPASTQualifiedName) {
@@ -147,7 +143,7 @@ class PDOMCPPNamespace extends PDOMCPPBinding
nsname = names[i];
}
// make sure we're the namespace they're talking about
- if (nsname != null && !equals(pdom.resolveBinding(nsname)))
+ if (nsname != null && !equals(pdom.findBinding(nsname)))
return null;
// Look up the name
@@ -198,24 +194,11 @@ class PDOMCPPNamespace extends PDOMCPPBinding
return null;
}
- public IASTNode getPhysicalNode() throws DOMException {
- throw new PDOMNotImplementedError();
- }
-
public IName getScopeName() throws DOMException {
throw new PDOMNotImplementedError();
}
- public boolean isFullyCached() throws DOMException {
- return true;
- }
-
public void removeBinding(IBinding binding) throws DOMException {
throw new PDOMNotImplementedError();
}
-
- public void setFullyCached(boolean b) throws DOMException {
- throw new PDOMNotImplementedError();
- }
-
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameter.java
index 76f05070e32..d6da5e32890 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameter.java
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@@ -51,7 +52,7 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter {
IType type = param.getType();
if (type != null) {
- PDOMNode typeNode = getLinkage().addType(this, type);
+ PDOMNode typeNode = getLinkageImpl().addType(this, type);
db.putInt(record + TYPE, typeNode != null ? typeNode.getRecord() : 0);
}
}
@@ -97,7 +98,7 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter {
public IType getType() throws DOMException {
try {
- PDOMNode node = getLinkage().getNode(pdom.getDB().getInt(record + TYPE));
+ PDOMNode node = getLinkageImpl().getNode(pdom.getDB().getInt(record + TYPE));
return node instanceof IType ? (IType)node : null;
} catch (CoreException e) {
CCorePlugin.log(e);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTypedef.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTypedef.java
index ec3a7d54f92..0848242a43b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTypedef.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTypedef.java
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@@ -34,7 +35,7 @@ class PDOMCPPTypedef extends PDOMBinding implements ITypedef {
throws CoreException {
super(pdom, parent, name);
IType type = typedef.getType();
- PDOMNode typeNode = parent.getLinkage().addType(this, type);
+ PDOMNode typeNode = parent.getLinkageImpl().addType(this, type);
if (typeNode != null)
pdom.getDB().putInt(record + TYPE, typeNode.getRecord());
}
@@ -53,7 +54,7 @@ class PDOMCPPTypedef extends PDOMBinding implements ITypedef {
public IType getType() throws DOMException {
try {
- PDOMNode node = getLinkage().getNode(pdom.getDB().getInt(record + TYPE));
+ PDOMNode node = getLinkageImpl().getNode(pdom.getDB().getInt(record + TYPE));
return node instanceof IType ? (IType)node : null;
} catch (CoreException e) {
CCorePlugin.log(e);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPVariable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPVariable.java
index 6a67fbfd41c..ac328f46cd9 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPVariable.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPVariable.java
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@@ -43,7 +44,7 @@ class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
if (nameParent instanceof IASTDeclarator) {
IASTDeclarator declarator = (IASTDeclarator)nameParent;
IType type = CPPVisitor.createType(declarator);
- PDOMNode typeNode = parent.getLinkage().addType(this, type);
+ PDOMNode typeNode = parent.getLinkageImpl().addType(this, type);
if (typeNode != null)
pdom.getDB().putInt(record + TYPE_OFFSET, typeNode.getRecord());
}
@@ -68,7 +69,7 @@ class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
public IType getType() throws DOMException {
try {
int typeRec = pdom.getDB().getInt(record + TYPE_OFFSET);
- return (IType)getLinkage().getNode(typeRec);
+ return (IType)getLinkageImpl().getNode(typeRec);
} catch (CoreException e) {
CCorePlugin.log(e);
return null;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/fast/PDOMFastHandleDelta.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/fast/PDOMFastHandleDelta.java
index d76762cb2a4..10def35fede 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/fast/PDOMFastHandleDelta.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/fast/PDOMFastHandleDelta.java
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.indexer.fast;
@@ -16,13 +17,11 @@ import java.util.Iterator;
import java.util.List;
import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.index.IIndexFile;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICElementDelta;
-import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.core.pdom.PDOMCodeReaderFactory;
-import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
+import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -121,47 +120,15 @@ class PDOMFastHandleDelta extends PDOMFastIndexerJob {
}
}
- protected void changeTU(ITranslationUnit tu) throws CoreException, InterruptedException {
- ILanguage language = tu.getLanguage();
- if (language == null)
- return;
-
- PDOMCodeReaderFactory codeReaderFactory = new PDOMCodeReaderFactory(pdom);
-
- // get the AST in a "Fast" way
- IASTTranslationUnit ast = language.getASTTranslationUnit(tu,
- codeReaderFactory,
- ILanguage.AST_USE_INDEX | ILanguage.AST_SKIP_IF_NO_BUILD_INFO);
- if (ast == null)
- return;
-
- // Clear the macros
- codeReaderFactory.clearMacros();
-
- pdom.acquireWriteLock();
- try {
- // Remove the old symbols in the tu
- IPath path = ((IFile)tu.getResource()).getLocation();
- PDOMFile file = pdom.getFile(path);
- if (file != null)
- file.clear();
-
- // Add the new symbols
- addSymbols(tu.getLanguage(), ast);
- } finally {
- pdom.releaseWriteLock();
- }
- }
-
protected void removeTU(ITranslationUnit tu) throws CoreException, InterruptedException {
- pdom.acquireWriteLock();
+ index.acquireWriteLock(0);
try {
IPath path = ((IFile)tu.getResource()).getLocation();
- PDOMFile file = pdom.getFile(path);
+ IIndexFragmentFile file = (IIndexFragmentFile) index.getFile(path);
if (file != null)
- file.clear();
+ index.clearFile(file);
} finally {
- pdom.releaseWriteLock();
+ index.releaseWriteLock(0);
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/fast/PDOMFastIndexerJob.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/fast/PDOMFastIndexerJob.java
index 5b792818189..76b3ee4ec7a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/fast/PDOMFastIndexerJob.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/fast/PDOMFastIndexerJob.java
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.indexer.fast;
@@ -22,11 +23,13 @@ import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.core.pdom.PDOM;
-import org.eclipse.cdt.internal.core.pdom.PDOMCodeReaderFactory;
-import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
-import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
+import org.eclipse.cdt.core.parser.IScannerInfo;
+import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
+import org.eclipse.cdt.internal.core.index.IWritableIndex;
+import org.eclipse.cdt.internal.core.index.IWritableIndexManager;
+import org.eclipse.cdt.internal.core.index.IndexBasedCodeReaderFactory;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
/**
* @author Doug Schaefer
@@ -35,8 +38,8 @@ import org.eclipse.core.runtime.CoreException;
public abstract class PDOMFastIndexerJob implements IPDOMIndexerTask {
protected final PDOMFastIndexer indexer;
- protected final PDOM pdom;
- protected final PDOMCodeReaderFactory codeReaderFactory;
+ protected final IWritableIndex index;
+ protected final IndexBasedCodeReaderFactory codeReaderFactory;
// Error counter. If we too many errors we bail
protected int errorCount;
@@ -44,8 +47,8 @@ public abstract class PDOMFastIndexerJob implements IPDOMIndexerTask {
public PDOMFastIndexerJob(PDOMFastIndexer indexer) throws CoreException {
this.indexer = indexer;
- this.pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(indexer.getProject());
- this.codeReaderFactory = new PDOMCodeReaderFactory(pdom);
+ this.index= ((IWritableIndexManager) CCorePlugin.getIndexManager()).getWritableIndex(indexer.getProject());
+ this.codeReaderFactory = new IndexBasedCodeReaderFactory(index);
}
public IPDOMIndexer getIndexer() {
@@ -53,33 +56,53 @@ public abstract class PDOMFastIndexerJob implements IPDOMIndexerTask {
}
protected void addTU(ITranslationUnit tu) throws InterruptedException, CoreException {
+ // we can do the same as for changing a tu
+ changeTU(tu);
+ }
+
+ protected void changeTU(ITranslationUnit tu) throws CoreException, InterruptedException {
ILanguage language = tu.getLanguage();
if (language == null)
return;
- // get the AST in a "Fast" way
- IASTTranslationUnit ast = language.getASTTranslationUnit(tu,
- codeReaderFactory,
- ILanguage.AST_USE_INDEX | ILanguage.AST_SKIP_IF_NO_BUILD_INFO);
- if (ast == null)
+ // skip if no scanner info
+ IScannerInfo scanner= tu.getScannerInfo(false);
+ if (scanner == null) {
return;
-
- // Clear the macros
- codeReaderFactory.clearMacros();
+ }
- pdom.acquireWriteLock();
+ IPath path = tu.getLocation();
+ if (path == null) {
+ return;
+ }
+
+ index.acquireReadLock();
try {
- addSymbols(language, ast);
- } finally {
- pdom.releaseWriteLock();
+ // get the AST in a "Fast" way
+ IASTTranslationUnit ast= language.getASTTranslationUnit(tu.getCodeReader(), scanner, codeReaderFactory, index);
+
+ index.acquireWriteLock(1);
+ try {
+ // Clear the macros
+ codeReaderFactory.clearMacros();
+
+ // Remove the old symbols in the tu
+ IIndexFragmentFile file= (IIndexFragmentFile) index.getFile(path);
+ if (file != null)
+ index.clearFile(file);
+
+ // Add the new symbols
+ addSymbols(ast);
+ } finally {
+ index.releaseWriteLock(1);
+ }
+ }
+ finally {
+ index.releaseReadLock();
}
}
- protected void addSymbols(ILanguage language, IASTTranslationUnit ast) throws InterruptedException, CoreException {
- final PDOMLinkage linkage = pdom.getLinkage(language);
- if (linkage == null)
- return;
-
+ protected void addSymbols(IASTTranslationUnit ast) throws InterruptedException, CoreException {
// Add in the includes
IASTPreprocessorIncludeStatement[] includes = ast.getIncludeDirectives();
for (int i = 0; i < includes.length; ++i) {
@@ -91,10 +114,10 @@ public abstract class PDOMFastIndexerJob implements IPDOMIndexerTask {
? sourceLoc.getFileName()
: ast.getFilePath(); // command-line includes
- PDOMFile sourceFile = codeReaderFactory.getCachedFile(sourcePath);
+ IIndexFragmentFile sourceFile = codeReaderFactory.createCachedFile(index, sourcePath);
String destPath = include.getPath();
- PDOMFile destFile = codeReaderFactory.getCachedFile(destPath);
- sourceFile.addIncludeTo(destFile);
+ IIndexFragmentFile destFile = codeReaderFactory.createCachedFile(index, destPath);
+ index.addInclude(sourceFile, destFile);
}
// Add in the macros
@@ -107,8 +130,8 @@ public abstract class PDOMFastIndexerJob implements IPDOMIndexerTask {
continue; // skip built-ins and command line macros
String filename = sourceLoc.getFileName();
- PDOMFile sourceFile = codeReaderFactory.getCachedFile(filename);
- sourceFile.addMacro(macro);
+ IIndexFragmentFile sourceFile = codeReaderFactory.createCachedFile(index, filename);
+ index.addMacro(sourceFile, macro);
}
// Add in the names
@@ -121,7 +144,7 @@ public abstract class PDOMFastIndexerJob implements IPDOMIndexerTask {
try {
IASTFileLocation nameLoc = name.getFileLocation();
if (nameLoc != null)
- linkage.addName(name, codeReaderFactory.getCachedFile(nameLoc.getFileName()));
+ index.addName(codeReaderFactory.createCachedFile(index, nameLoc.getFileName()), name);
return PROCESS_CONTINUE;
} catch (Throwable e) {
CCorePlugin.log(e);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/fast/PDOMFastReindex.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/fast/PDOMFastReindex.java
index 5a6b63c5b40..29a73915df7 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/fast/PDOMFastReindex.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/fast/PDOMFastReindex.java
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.indexer.fast;
@@ -57,7 +58,13 @@ public class PDOMFastReindex extends PDOMFastIndexerJob {
long start = System.currentTimeMillis();
// First clear the pdom
- pdom.clear();
+ index.acquireWriteLock(0);
+ try {
+ index.clear();
+ }
+ finally {
+ index.releaseWriteLock(0);
+ }
ISourceRoot[] roots = indexer.getProject().getAllSourceRoots();
for (int i = 0; i < roots.length; ++i)
@@ -66,11 +73,12 @@ public class PDOMFastReindex extends PDOMFastIndexerJob {
String showTimings = Platform.getDebugOption(CCorePlugin.PLUGIN_ID
+ "/debug/pdomtimings"); //$NON-NLS-1$
if (showTimings != null && showTimings.equalsIgnoreCase("true")) //$NON-NLS-1$
- System.out.println("PDOM Fast Reindex Time: " + (System.currentTimeMillis() - start)
+ System.out.println("PDOM Fast Reindex Time: " + (System.currentTimeMillis() - start) //$NON-NLS-1$
+ " " + indexer.getProject().getElementName()); //$NON-NLS-1$
} catch (CoreException e) {
CCorePlugin.log(e);
+ } catch (InterruptedException e) {
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/full/PDOMFullHandleDelta.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/full/PDOMFullHandleDelta.java
index 33bca5e6281..60e4f1d95b6 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/full/PDOMFullHandleDelta.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/full/PDOMFullHandleDelta.java
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.indexer.full;
@@ -18,13 +19,14 @@ import java.util.List;
import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexFile;
+import org.eclipse.cdt.core.index.IIndexInclude;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICElementDelta;
import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
+import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -142,16 +144,16 @@ public class PDOMFullHandleDelta extends PDOMFullIndexerJob {
protected void processTranslationUnit(ITranslationUnit tu) throws CoreException {
IPath path = tu.getUnderlyingResource().getLocation();
- PDOMFile pdomFile = pdom.getFile(path);
+ IIndexFile pdomFile= index.getFile(path);
boolean found = false;
if (pdomFile != null) {
// Look for all source units in the included list,
// If none, then add the header
- PDOMFile[] includedBy = pdomFile.getAllIncludedBy();
+ IIndexInclude[] includedBy = index.findIncludedBy(pdomFile, IIndex.DEPTH_INFINITE);
if (includedBy.length > 0) {
IProject project = tu.getCProject().getProject();
for (int i = 0; i < includedBy.length; ++i) {
- String incfilename = includedBy[i].getFileName().getString();
+ String incfilename = includedBy[i].getIncludedByLocation();
if (CoreModel.isValidSourceUnitName(project, incfilename)) {
if (changed.get(incfilename) == null) {
IFile[] rfiles = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path(incfilename));
@@ -170,44 +172,16 @@ public class PDOMFullHandleDelta extends PDOMFullIndexerJob {
if (!found)
changed.put(path.toOSString(), tu);
}
-
- protected void changeTU(ITranslationUnit tu) throws CoreException, InterruptedException {
- IASTTranslationUnit ast = parse(tu);
- if (ast == null)
- return;
-
- // Remove the old symbols in the tu and all the headers
- pdom.acquireWriteLock();
- try {
- IPath path = ((IFile)tu.getResource()).getLocation();
- PDOMFile file = pdom.getFile(path);
- if (file != null)
- file.clear();
-
- IASTPreprocessorIncludeStatement[] includes = ast.getIncludeDirectives();
- for (int i = 0; i < includes.length; ++i) {
- String incname = includes[i].getPath();
- PDOMFile incfile = pdom.getFile(incname);
- if (incfile != null)
- incfile.clear();
- }
-
- // Add the new symbols
- addSymbols(tu.getLanguage(), ast);
- } finally {
- pdom.releaseWriteLock();
- }
- }
protected void removeTU(ITranslationUnit tu) throws CoreException, InterruptedException {
- pdom.acquireWriteLock();
+ index.acquireWriteLock(0);
try {
IPath path = ((IFile)tu.getResource()).getLocation();
- PDOMFile file = pdom.getFile(path);
+ IIndexFragmentFile file = (IIndexFragmentFile) index.getFile(path);
if (file != null)
- file.clear();
+ index.clearFile(file);
} finally {
- pdom.releaseWriteLock();
+ index.releaseWriteLock(0);
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/full/PDOMFullIndexerJob.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/full/PDOMFullIndexerJob.java
index f0eb7303b90..d7c5b1b3d01 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/full/PDOMFullIndexerJob.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/full/PDOMFullIndexerJob.java
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.indexer.full;
@@ -20,12 +21,13 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
-import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.core.pdom.PDOM;
-import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
-import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
+import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
+import org.eclipse.cdt.internal.core.index.IWritableIndex;
+import org.eclipse.cdt.internal.core.index.IWritableIndexManager;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
/**
* @author Doug Schaefer
@@ -34,7 +36,7 @@ import org.eclipse.core.runtime.CoreException;
public abstract class PDOMFullIndexerJob implements IPDOMIndexerTask {
protected final PDOMFullIndexer indexer;
- protected final PDOM pdom;
+ protected final IWritableIndex index;
// Error count, bail when it gets too high
protected int errorCount;
@@ -42,49 +44,51 @@ public abstract class PDOMFullIndexerJob implements IPDOMIndexerTask {
public PDOMFullIndexerJob(PDOMFullIndexer indexer) throws CoreException {
this.indexer = indexer;
- this.pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(indexer.getProject());
+ this.index = ((IWritableIndexManager) CCorePlugin.getIndexManager()).getWritableIndex(indexer.getProject());
}
public IPDOMIndexer getIndexer() {
return indexer;
}
- protected IASTTranslationUnit parse(ITranslationUnit tu) throws CoreException {
- ILanguage language = tu.getLanguage();
- if (language == null)
- return null;
-
- // get the AST in the "Full" way, i.e. don't skip anything.
- return language.getASTTranslationUnit(tu, ILanguage.AST_SKIP_IF_NO_BUILD_INFO);
- }
-
protected void addTU(ITranslationUnit tu) throws InterruptedException, CoreException {
- IASTTranslationUnit ast = parse(tu);
+ changeTU(tu);
+ }
+
+ protected void changeTU(ITranslationUnit tu) throws CoreException, InterruptedException {
+ IPath path = tu.getLocation();
+ if (path == null) {
+ return;
+ }
+ IASTTranslationUnit ast= tu.getAST(null, ITranslationUnit.AST_SKIP_IF_NO_BUILD_INFO);
if (ast == null)
return;
- pdom.acquireWriteLock();
+ index.acquireWriteLock(0);
+
try {
- // First clear out the symbols in the includes
+ // Remove the old symbols in the tu
+ IIndexFragmentFile file = (IIndexFragmentFile) index.getFile(path);
+ if (file != null)
+ index.clearFile(file);
+
+ // Clear out the symbols in the includes
IASTPreprocessorIncludeStatement[] includes = ast.getIncludeDirectives();
for (int i = 0; i < includes.length; ++i) {
String incname = includes[i].getPath();
- PDOMFile incfile = pdom.getFile(incname);
- if (incfile != null)
- incfile.clear();
+ IIndexFragmentFile incfile = (IIndexFragmentFile) index.getFile(new Path(incname));
+ if (incfile != null) {
+ index.clearFile(incfile);
+ }
}
- addSymbols(tu.getLanguage(), ast);
+ addSymbols(ast);
} finally {
- pdom.releaseWriteLock();
+ index.releaseWriteLock(0);
}
}
- public void addSymbols(ILanguage language, IASTTranslationUnit ast) throws CoreException {
- final PDOMLinkage linkage = pdom.getLinkage(language);
- if (linkage == null)
- return;
-
+ protected void addSymbols(IASTTranslationUnit ast) throws CoreException {
// Add in the includes
IASTPreprocessorIncludeStatement[] includes = ast.getIncludeDirectives();
for (int i = 0; i < includes.length; ++i) {
@@ -96,12 +100,12 @@ public abstract class PDOMFullIndexerJob implements IPDOMIndexerTask {
? sourceLoc.getFileName()
: ast.getFilePath(); // command-line includes
- PDOMFile sourceFile = pdom.addFile(sourcePath);
+ IIndexFragmentFile sourceFile = index.addFile(sourcePath);
String destPath = include.getPath();
- PDOMFile destFile = pdom.addFile(destPath);
- sourceFile.addIncludeTo(destFile);
+ IIndexFragmentFile destFile = index.addFile(destPath);
+ index.addInclude(sourceFile, destFile);
}
-
+
// Add in the macros
IASTPreprocessorMacroDefinition[] macros = ast.getMacroDefinitions();
for (int i = 0; i < macros.length; ++i) {
@@ -110,33 +114,29 @@ public abstract class PDOMFullIndexerJob implements IPDOMIndexerTask {
IASTFileLocation sourceLoc = macro.getFileLocation();
if (sourceLoc == null)
continue; // skip built-ins and command line macros
-
- PDOMFile sourceFile = pdom.getFile(sourceLoc.getFileName());
- if (sourceFile != null) // not sure why this would be null
- sourceFile.addMacro(macro);
+
+ String filename = sourceLoc.getFileName();
+ IIndexFragmentFile sourceFile = index.addFile(filename);
+ index.addMacro(sourceFile, macro);
}
-
+
// Add in the names
ast.accept(new ASTVisitor() {
{
shouldVisitNames = true;
shouldVisitDeclarations = true;
}
-
public int visit(IASTName name) {
try {
- IASTFileLocation fileloc = name.getFileLocation();
- if (fileloc != null) {
- PDOMFile file = pdom.addFile(fileloc.getFileName());
- linkage.addName(name, file);
- }
+ IASTFileLocation nameLoc = name.getFileLocation();
+ if (nameLoc != null)
+ index.addName(index.addFile(nameLoc.getFileName()), name);
return PROCESS_CONTINUE;
} catch (Throwable e) {
CCorePlugin.log(e);
return ++errorCount > MAX_ERRORS ? PROCESS_ABORT : PROCESS_CONTINUE;
}
- };
- });;
+ }
+ });
}
-
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/full/PDOMFullReindex.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/full/PDOMFullReindex.java
index e9331fbc415..6ac21f924a6 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/full/PDOMFullReindex.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/full/PDOMFullReindex.java
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.indexer.full;
@@ -15,7 +16,6 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICElementVisitor;
import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -37,7 +37,7 @@ public class PDOMFullReindex extends PDOMFullIndexerJob {
long start = System.currentTimeMillis();
// First clear out the PDOM
- pdom.clear();
+ index.clear();
// First index all the source files (i.e. not headers)
indexer.getProject().accept(new ICElementVisitor() {
@@ -74,11 +74,9 @@ public class PDOMFullReindex extends PDOMFullIndexerJob {
case ICElement.C_UNIT:
ITranslationUnit tu = (ITranslationUnit)element;
if (tu.isHeaderUnit()) {
- IFile rfile = (IFile)tu.getUnderlyingResource();
- IPath fileLocation = rfile.getLocation();
+ IPath fileLocation = tu.getLocation();
if ( fileLocation != null ) {
- String filename = fileLocation.toOSString();
- if (pdom.getFile(filename) == null) {
+ if (index.getFile(fileLocation) == null) {
try {
addTU(tu);
} catch (InterruptedException e) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/nulli/PDOMNullIndexer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/nulli/PDOMNullIndexer.java
index b97a4f58991..47e1da9e7e6 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/nulli/PDOMNullIndexer.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/nulli/PDOMNullIndexer.java
@@ -7,20 +7,20 @@
*
* Contributors:
* QNX - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.indexer.nulli;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMIndexer;
+import org.eclipse.cdt.core.dom.IPDOMIndexerTask;
import org.eclipse.cdt.core.model.ICElementDelta;
import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.internal.core.pdom.PDOM;
+import org.eclipse.cdt.internal.core.index.IWritableIndex;
+import org.eclipse.cdt.internal.core.index.IWritableIndexManager;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
/**
* @author Doug Schaefer
@@ -29,7 +29,7 @@ import org.eclipse.core.runtime.jobs.Job;
*/
public class PDOMNullIndexer implements IPDOMIndexer {
- public static final String ID = "org.eclipse.cdt.core.nullindexer";
+ public static final String ID = "org.eclipse.cdt.core.nullindexer"; //$NON-NLS-1$
private ICProject project;
@@ -43,33 +43,32 @@ public class PDOMNullIndexer implements IPDOMIndexer {
public void handleDelta(ICElementDelta delta) {
}
-
- private class Reindex extends Job {
- public Reindex() {
- super("Null Reindex"); //$NON-NLS-1$
- setSystem(true);
+
+ private class PDOMNullReindex implements IPDOMIndexerTask {
+ public IPDOMIndexer getIndexer() {
+ return PDOMNullIndexer.this;
}
- protected IStatus run(IProgressMonitor monitor) {
+
+ public void run(IProgressMonitor monitor) {
try {
- PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(project);
+ IWritableIndex index= ((IWritableIndexManager) CCorePlugin.getIndexManager()).getWritableIndex(project);
+ index.acquireWriteLock(0);
try {
- pdom.acquireWriteLock();
- pdom.clear();
- return Status.OK_STATUS;
- } catch (CoreException e) {
- return e.getStatus();
- } catch (InterruptedException e) {
- return Status.CANCEL_STATUS;
- } finally {
- pdom.releaseWriteLock();
+ index.clear();
}
- } catch (CoreException e) {
- return e.getStatus();
+ finally {
+ index.releaseWriteLock(0);
+ }
+ }
+ catch (InterruptedException e) {
+ }
+ catch (CoreException e) {
+ CCorePlugin.log(e);
}
}
}
public void reindex() throws CoreException {
- new Reindex().schedule();
+ CCorePlugin.getPDOMManager().enqueue(new PDOMNullReindex());
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/messages.properties b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/messages.properties
new file mode 100644
index 00000000000..54995ed29ce
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/messages.properties
@@ -0,0 +1 @@
+WritablePDOM_error_unknownLinkage=AST specifies unknown linkage ''{0}''
diff --git a/core/org.eclipse.cdt.core/plugin.xml b/core/org.eclipse.cdt.core/plugin.xml
index f5bcf9c3f5d..5b9549da56c 100644
--- a/core/org.eclipse.cdt.core/plugin.xml
+++ b/core/org.eclipse.cdt.core/plugin.xml
@@ -567,6 +567,12 @@
name="GNU C++">
<contentType id="org.eclipse.cdt.core.cxxSource"/>
</language>
+ <pdomLinkageFactory
+ class="org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCLinkageFactory"
+ id="C"/>
+ <pdomLinkageFactory
+ class="org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPLinkageFactory"
+ id="C++"/>
</extension>
<extension
point="org.eclipse.core.runtime.adapters">
diff --git a/core/org.eclipse.cdt.core/schema/language.exsd b/core/org.eclipse.cdt.core/schema/language.exsd
index d61057489ef..971e4fae955 100644
--- a/core/org.eclipse.cdt.core/schema/language.exsd
+++ b/core/org.eclipse.cdt.core/schema/language.exsd
@@ -12,8 +12,11 @@
<element name="extension">
<complexType>
- <sequence>
- <element ref="language"/>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <choice>
+ <element ref="language"/>
+ <element ref="pdomLinkageFactory"/>
+ </choice>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
@@ -44,7 +47,7 @@
<element name="language">
<complexType>
- <sequence>
+ <sequence minOccurs="1" maxOccurs="unbounded">
<element ref="contentType"/>
</sequence>
<attribute name="id" type="string">
@@ -67,7 +70,7 @@
</documentation>
<appInfo>
- <meta.attribute kind="java" basedOn="org.eclipse.cdt.core.model.ILanguage"/>
+ <meta.attribute kind="java" basedOn="org.eclipse.cdt.core.model.AbstractLanguage"/>
</appInfo>
</annotation>
</attribute>
@@ -86,6 +89,28 @@
</complexType>
</element>
+ <element name="pdomLinkageFactory">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ The factory that creates linkage objects.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
<annotation>
<appInfo>
<meta.section type="since"/>
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java
index 7f725a4ac6c..96f0af9efc4 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java
@@ -26,6 +26,7 @@ import java.util.ResourceBundle;
import org.eclipse.cdt.core.dom.CDOM;
import org.eclipse.cdt.core.dom.IPDOMManager;
+import org.eclipse.cdt.core.index.IIndexManager;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
@@ -244,6 +245,10 @@ public class CCorePlugin extends Plugin {
return fgCPlugin;
}
+ public static void log(String e) {
+ log(createStatus(e));
+ }
+
public static void log(Throwable e) {
if ( e instanceof CoreException ) {
log(((CoreException)e).getStatus());
@@ -252,6 +257,14 @@ public class CCorePlugin extends Plugin {
}
}
+ public static IStatus createStatus(String msg) {
+ return createStatus(msg, null);
+ }
+
+ public static IStatus createStatus(String msg, Throwable e) {
+ return new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, msg, e);
+ }
+
public static void log(IStatus status) {
((Plugin) getDefault()).getLog().log(status);
}
@@ -638,9 +651,16 @@ public class CCorePlugin extends Plugin {
return fCoreModel;
}
+ /**
+ * deprecated, use getIndexManager()
+ */
public static IPDOMManager getPDOMManager() {
return getDefault().pdomManager;
}
+
+ public static IIndexManager getIndexManager() {
+ return getDefault().pdomManager;
+ }
public IPathEntryVariableManager getPathEntryVariableManager() {
return fPathEntryVariableManager;
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseTestCase.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseTestCase.java
index 321274d8fbd..3cbce55784e 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseTestCase.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseTestCase.java
@@ -30,17 +30,15 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.swt.widgets.Display;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexFile;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
import org.eclipse.cdt.ui.testplugin.CTestPlugin;
-import org.eclipse.cdt.internal.core.pdom.PDOM;
-import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
-
public class BaseTestCase extends TestCase {
private boolean fExpectFailure= false;
private int fBugnumber= 0;
@@ -144,31 +142,31 @@ public class BaseTestCase extends TestCase {
return TestSourceReader.createFile(container, new Path(fileName), contents);
}
- protected IASTTranslationUnit createPDOMBasedAST(ICProject project, IFile file) throws CModelException, CoreException {
+ protected IASTTranslationUnit createIndexBasedAST(IIndex index, ICProject project, IFile file) throws CModelException, CoreException {
ICElement elem= project.findElement(file.getFullPath());
if (elem instanceof ITranslationUnit) {
ITranslationUnit tu= (ITranslationUnit) elem;
if (tu != null) {
- return tu.getLanguage().getASTTranslationUnit(tu, ILanguage.AST_SKIP_INDEXED_HEADERS |ILanguage.AST_USE_INDEX);
+ return tu.getAST(index, ITranslationUnit.AST_SKIP_INDEXED_HEADERS);
}
}
fail("Could not create ast for " + file.getFullPath());
return null;
}
- protected void waitForIndexer(PDOM pdom, IFile file, int maxmillis) throws Exception {
+ protected void waitForIndexer(IIndex index, IFile file, int maxmillis) throws Exception {
long endTime= System.currentTimeMillis() + maxmillis;
do {
- pdom.acquireReadLock();
+ index.acquireReadLock();
try {
- PDOMFile pfile= pdom.getFile(file.getLocation());
+ IIndexFile pfile= index.getFile(file.getLocation());
// mstodo check timestamp
if (pfile != null) {
return;
}
}
finally {
- pdom.releaseReadLock();
+ index.releaseReadLock();
}
Thread.sleep(50);
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java
index 04f48b95a5f..b715f8dd1b9 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java
@@ -54,7 +54,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
private void doTestFunctions(String filename) throws IOException, Exception, PartInitException {
String content = readTaggedComment("testFunctions");
IFile file= createFile(getProject(), filename, content);
- waitForIndexer(fPdom, file, 1000);
+ waitForIndexer(fIndex, file, 1000);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
@@ -100,7 +100,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
private void doTestVariables(String filename) throws Exception {
String content = readTaggedComment("testVariables");
IFile file= createFile(getProject(), filename, content);
- waitForIndexer(fPdom, file, 1000);
+ waitForIndexer(fIndex, file, 1000);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
@@ -158,7 +158,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
private void doTestEnumerator(String filename, String contentTag) throws Exception {
String content = readTaggedComment(contentTag);
IFile file= createFile(getProject(), filename, content);
- waitForIndexer(fPdom, file, 1000);
+ waitForIndexer(fIndex, file, 1000);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
@@ -223,7 +223,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
private void doTestStructMembers(String filename) throws Exception {
String content = readTaggedComment("testStructMembers");
IFile file= createFile(getProject(), filename, content);
- waitForIndexer(fPdom, file, 1000);
+ waitForIndexer(fIndex, file, 1000);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
@@ -281,7 +281,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
private void doTestAnonymousStructMembers(String filename) throws Exception {
String content = readTaggedComment("testStructMembers");
IFile file= createFile(getProject(), filename, content);
- waitForIndexer(fPdom, file, 1000);
+ waitForIndexer(fIndex, file, 1000);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
@@ -355,7 +355,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
private void doTestUnionMembers(String filename) throws Exception {
String content = readTaggedComment("testUnionMembers");
IFile file= createFile(getProject(), filename, content);
- waitForIndexer(fPdom, file, 1000);
+ waitForIndexer(fIndex, file, 1000);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
@@ -413,7 +413,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
private void doTestAnonymousUnionMembers(String filename) throws Exception {
String content = readTaggedComment("testUnionMembers");
IFile file= createFile(getProject(), filename, content);
- waitForIndexer(fPdom, file, 1000);
+ waitForIndexer(fIndex, file, 1000);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCppCallHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCppCallHierarchyTest.java
index 1d53df65377..d19e4d4da9a 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCppCallHierarchyTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCppCallHierarchyTest.java
@@ -57,7 +57,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
public void testMethods() throws Exception {
String content = readTaggedComment("testMethods");
IFile file= createFile(getProject(), "testMethods.cpp", content);
- waitForIndexer(fPdom, file, MAX_TIME_INDEXER);
+ waitForIndexer(fIndex, file, MAX_TIME_INDEXER);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
@@ -141,7 +141,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
public void testStaticMethods() throws Exception {
String content = readTaggedComment("testStaticMethods");
IFile file= createFile(getProject(), "testStaticMethods.cpp", content);
- waitForIndexer(fPdom, file, MAX_TIME_INDEXER);
+ waitForIndexer(fIndex, file, MAX_TIME_INDEXER);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
@@ -230,7 +230,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
public void testFields() throws Exception {
String content = readTaggedComment("testFields");
IFile file= createFile(getProject(), "testFields.cpp", content);
- waitForIndexer(fPdom, file, MAX_TIME_INDEXER);
+ waitForIndexer(fIndex, file, MAX_TIME_INDEXER);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
@@ -305,7 +305,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
public void _testAutomaticConstructor_156668() throws Exception {
String content = readTaggedComment("testAutomaticConstructor");
IFile file= createFile(getProject(), "testConstructor.cpp", content);
- waitForIndexer(fPdom, file, MAX_TIME_INDEXER);
+ waitForIndexer(fIndex, file, MAX_TIME_INDEXER);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
@@ -335,7 +335,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
public void testConstructor() throws Exception {
String content = readTaggedComment("testConstructor");
IFile file= createFile(getProject(), "testConstructor.cpp", content);
- waitForIndexer(fPdom, file, MAX_TIME_INDEXER);
+ waitForIndexer(fIndex, file, MAX_TIME_INDEXER);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
@@ -349,7 +349,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
public void _testDestructor_156669() throws Exception {
String content = readTaggedComment("testConstructor");
IFile file= createFile(getProject(), "testConstructor.cpp", content);
- waitForIndexer(fPdom, file, MAX_TIME_INDEXER);
+ waitForIndexer(fIndex, file, MAX_TIME_INDEXER);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
@@ -385,7 +385,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
public void testNamespace() throws Exception {
String content = readTaggedComment("testNamespace");
IFile file= createFile(getProject(), "testNamespace.cpp", content);
- waitForIndexer(fPdom, file, MAX_TIME_INDEXER);
+ waitForIndexer(fIndex, file, MAX_TIME_INDEXER);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
@@ -443,7 +443,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
public void _testNamespacePart2_156519() throws Exception {
String content = readTaggedComment("testNamespace");
IFile file= createFile(getProject(), "testNamespace.cpp", content);
- waitForIndexer(fPdom, file, MAX_TIME_INDEXER);
+ waitForIndexer(fIndex, file, MAX_TIME_INDEXER);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java
index 38eb59573a5..588ad92f2af 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java
@@ -19,13 +19,13 @@ import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.dom.IPDOMIndexer;
+import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.tests.BaseTestCase;
-import org.eclipse.cdt.internal.core.pdom.PDOM;
-
import org.eclipse.cdt.internal.ui.callhierarchy.CHViewPart;
import org.eclipse.cdt.internal.ui.callhierarchy.CallHierarchyUI;
import org.eclipse.cdt.internal.ui.editor.CEditor;
@@ -33,7 +33,7 @@ import org.eclipse.cdt.internal.ui.editor.CEditor;
public class CallHierarchyBaseTest extends BaseTestCase {
private ICProject fCProject;
- public PDOM fPdom;
+ protected IIndex fIndex;
public CallHierarchyBaseTest(String name) {
super(name);
@@ -42,8 +42,14 @@ public class CallHierarchyBaseTest extends BaseTestCase {
protected void setUp() throws CoreException {
fCProject= CProjectHelper.createCProject("__chTest__", "bin");
CCorePlugin.getPDOMManager().setIndexerId(fCProject, "org.eclipse.cdt.core.fastIndexer");
- fPdom= (PDOM) CCorePlugin.getPDOMManager().getPDOM(fCProject);
- fPdom.clear();
+ IPDOMIndexer indexer = CCorePlugin.getPDOMManager().getIndexer(fCProject);
+ try {
+ indexer.reindex();
+ } catch (CoreException e) {
+ CUIPlugin.getDefault().log(e);
+ }
+
+ fIndex= CCorePlugin.getIndexManager().getIndex(fCProject);
}
protected void tearDown() throws CoreException {
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CppCallHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CppCallHierarchyTest.java
new file mode 100644
index 00000000000..8b5217169f6
--- /dev/null
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CppCallHierarchyTest.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui.tests.callhierarchy;
+
+import junit.framework.Test;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+
+
+public class CppCallHierarchyTest extends CallHierarchyBaseTest {
+
+ private static final int MAX_TIME_INDEXER = 1000;
+
+ public CppCallHierarchyTest(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ return suite(CppCallHierarchyTest.class);
+ }
+
+ // {testMethods.h}
+ // class MyClass {
+ // public:
+ // void method();
+ // void inline_method() {
+ // method(); // r1
+ // inline_method(); // r1
+ // }
+ // };
+
+ // {testMethods.cpp}
+ // #include "testMethods.h"
+ // void MyClass::method() {
+ // method(); // r2
+ // inline_method(); // r2
+ // }
+ //
+ // void func() {
+ // MyClass m, *n;
+ // m.method(); // r3
+ // n->inline_method(); // r3
+ // }
+ public void _testMethods() throws Exception {
+ String header= readTaggedComment("testMethods.h");
+ IFile headerFile= createFile(getProject(), "testMethods.h", header);
+ String source = readTaggedComment("testMethods.cpp");
+ IFile sourceFile= createFile(getProject(), "testMethods.cpp", source);
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ CEditor editor= (CEditor) IDE.openEditor(page, sourceFile);
+ waitForIndexer(fIndex, sourceFile, MAX_TIME_INDEXER);
+
+ editor.selectAndReveal(source.indexOf("method"), 2);
+ openCallHierarchy(editor);
+ Tree tree= getCHTree(page);
+
+ checkTreeNode(tree, 0, "MyClass::method()");
+ checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
+ checkTreeNode(tree, 0, 1, "MyClass::method()");
+ checkTreeNode(tree, 0, 2, "func()");
+
+ editor.selectAndReveal(source.indexOf("method(); // r2"), 2);
+ openCallHierarchy(editor);
+
+ checkTreeNode(tree, 0, "MyClass::method()");
+ checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
+ checkTreeNode(tree, 0, 1, "MyClass::method()");
+ checkTreeNode(tree, 0, 2, "func()");
+
+ editor.selectAndReveal(source.indexOf("inline_method(); // r2"), 2);
+ openCallHierarchy(editor);
+ checkTreeNode(tree, 0, "MyClass::inline_method()");
+ checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
+ checkTreeNode(tree, 0, 1, "MyClass::method()");
+ checkTreeNode(tree, 0, 2, "func()");
+
+ editor.selectAndReveal(source.indexOf("method(); // r3"), 2);
+ openCallHierarchy(editor);
+ checkTreeNode(tree, 0, "MyClass::method()");
+ checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
+ checkTreeNode(tree, 0, 1, "MyClass::method()");
+ checkTreeNode(tree, 0, 2, "func()");
+
+ editor.selectAndReveal(source.indexOf("inline_method(); // r3"), 2);
+ openCallHierarchy(editor);
+ checkTreeNode(tree, 0, "MyClass::inline_method()");
+ checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
+ checkTreeNode(tree, 0, 1, "MyClass::method()");
+ checkTreeNode(tree, 0, 2, "func()");
+ }
+}
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/InitializersInCallHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/InitializersInCallHierarchyTest.java
index 4e6e3d523ee..2811fb1ae93 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/InitializersInCallHierarchyTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/InitializersInCallHierarchyTest.java
@@ -37,7 +37,7 @@ public class InitializersInCallHierarchyTest extends CallHierarchyBaseTest {
public void testCIntVarInitializer() throws Exception {
String content = readTaggedComment("intvar");
IFile file= createFile(getProject(), "intvar.c", content);
- waitForIndexer(fPdom, file, 1000);
+ waitForIndexer(fIndex, file, 1000);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java
index c99d3a1cc4a..7ebb9842408 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java
@@ -214,7 +214,7 @@ public class BaseSelectionTestsIndexer extends TestCase {
if (sel instanceof ITextSelection) {
ITextSelection textSel = (ITextSelection)sel;
ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create(file);
- IASTTranslationUnit ast = tu.getLanguage().getASTTranslationUnit(tu, 0);
+ IASTTranslationUnit ast = tu.getAST();
IASTName[] names = tu.getLanguage().getSelectedNames(ast, textSel.getOffset(), textSel.getLength());
if (names == null || names.length == 0)
@@ -302,7 +302,7 @@ public class BaseSelectionTestsIndexer extends TestCase {
if (sel instanceof TextSelection) {
ITextSelection textSel = (ITextSelection)sel;
ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create(file);
- IASTTranslationUnit ast = tu.getLanguage().getASTTranslationUnit(tu, 0);
+ IASTTranslationUnit ast = tu.getAST();
IASTName[] names = tu.getLanguage().getSelectedNames(ast, textSel.getOffset(), textSel.getLength());
if (names == null || names.length == 0)
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java
index ee62ce39dd0..76f3d458a05 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java
@@ -236,7 +236,7 @@ public class CPPSelectionTestsNoIndexer extends TestCase {
if (sel instanceof TextSelection) {
ITextSelection textSel = (ITextSelection)sel;
ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create(file);
- IASTTranslationUnit ast = tu.getLanguage().getASTTranslationUnit(tu, 0);
+ IASTTranslationUnit ast = tu.getAST();
IASTName[] names = tu.getLanguage().getSelectedNames(ast, textSel.getOffset(), textSel.getLength());
if (names.length == 0) {
@@ -280,7 +280,7 @@ public class CPPSelectionTestsNoIndexer extends TestCase {
if (sel instanceof TextSelection) {
ITextSelection textSel = (ITextSelection)sel;
ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create(file);
- IASTTranslationUnit ast = tu.getLanguage().getASTTranslationUnit(tu, 0);
+ IASTTranslationUnit ast = tu.getAST();
IASTName[] names = tu.getLanguage().getSelectedNames(ast, textSel.getOffset(), textSel.getLength());
if (names == null || names.length == 0)
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java
index cd840eaf5ee..0317b3fbc87 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java
@@ -288,7 +288,7 @@ public class CSelectionTestsNoIndexer extends TestCase {
if (sel instanceof TextSelection) {
ITextSelection textSel = (ITextSelection)sel;
ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create(file);
- IASTTranslationUnit ast = tu.getLanguage().getASTTranslationUnit(tu, 0);
+ IASTTranslationUnit ast = tu.getAST();
IASTName[] names = tu.getLanguage().getSelectedNames(ast, textSel.getOffset(), textSel.getLength());
if (names == null || names.length == 0)
@@ -331,7 +331,7 @@ public class CSelectionTestsNoIndexer extends TestCase {
if (sel instanceof TextSelection) {
ITextSelection textSel = (ITextSelection)sel;
ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create(file);
- IASTTranslationUnit ast = tu.getLanguage().getASTTranslationUnit(tu, 0);
+ IASTTranslationUnit ast = tu.getAST();
IASTName[] names = tu.getLanguage().getSelectedNames(ast, textSel.getOffset(), textSel.getLength());
if (names == null || names.length == 0)
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/ResolveBindingTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/ResolveBindingTests.java
index 6845198d1e0..45357a05311 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/ResolveBindingTests.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/ResolveBindingTests.java
@@ -15,26 +15,28 @@ import junit.framework.Test;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.dom.IPDOMIndexer;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.testplugin.CProjectHelper;
+import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.tests.BaseTestCase;
-import org.eclipse.cdt.internal.core.pdom.PDOM;
-
public class ResolveBindingTests extends BaseTestCase {
private static final int WAIT_FOR_INDEXER = 5000;
private ICProject fCProject;
- private PDOM fPdom;
+ private IIndex fIndex;
public ResolveBindingTests(String name) {
super(name);
@@ -48,8 +50,13 @@ public class ResolveBindingTests extends BaseTestCase {
super.setUp();
fCProject= CProjectHelper.createCProject("ResolveBindingTests", "bin");
CCorePlugin.getPDOMManager().setIndexerId(fCProject, "org.eclipse.cdt.core.fastIndexer");
- fPdom= (PDOM) CCorePlugin.getPDOMManager().getPDOM(fCProject);
- fPdom.clear();
+ IPDOMIndexer indexer = CCorePlugin.getPDOMManager().getIndexer(fCProject);
+ try {
+ indexer.reindex();
+ } catch (CoreException e) {
+ CUIPlugin.getDefault().log(e);
+ }
+ fIndex= CCorePlugin.getIndexManager().getIndex(fCProject);
}
protected void tearDown() throws Exception {
@@ -90,33 +97,47 @@ public class ResolveBindingTests extends BaseTestCase {
public void testNamespaceVarBinding() throws Exception {
String content = readTaggedComment("namespace-var-test");
IFile file= createFile(fCProject.getProject(), "nsvar.cpp", content);
- waitForIndexer(fPdom, file, WAIT_FOR_INDEXER);
+ waitForIndexer(fIndex, file, WAIT_FOR_INDEXER);
- IASTTranslationUnit astTU= createPDOMBasedAST(fCProject, file);
- IASTName name= getSelectedName(astTU, content.indexOf("var"), 3);
- IBinding binding= name.resolveBinding();
- assertTrue(binding instanceof IVariable);
-
- name= getSelectedName(astTU, content.indexOf("var; // r1"), 3);
- checkBinding(name, IVariable.class);
-
- name= getSelectedName(astTU, content.indexOf("var; // r2"), 3);
- checkBinding(name, IVariable.class);
+ IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
+ index.acquireReadLock();
+ try {
+ IASTTranslationUnit astTU= createIndexBasedAST(index, fCProject, file);
+ IASTName name= getSelectedName(astTU, content.indexOf("var"), 3);
+ IBinding binding= name.resolveBinding();
+ assertTrue(binding instanceof IVariable);
+
+ name= getSelectedName(astTU, content.indexOf("var; // r1"), 3);
+ checkBinding(name, IVariable.class);
+
+ name= getSelectedName(astTU, content.indexOf("var; // r2"), 3);
+ checkBinding(name, IVariable.class);
+ }
+ finally {
+ index.releaseReadLock();
+ }
}
public void _testNamespaceVarBinding_156519() throws Exception {
String content = readTaggedComment("namespace-var-test");
IFile file= createFile(fCProject.getProject(), "nsvar.cpp", content);
- waitForIndexer(fPdom, file, WAIT_FOR_INDEXER);
+ waitForIndexer(fIndex, file, WAIT_FOR_INDEXER);
- IASTTranslationUnit astTU= createPDOMBasedAST(fCProject, file);
+ IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
+ index.acquireReadLock();
+ try {
+ IASTTranslationUnit astTU= createIndexBasedAST(index, fCProject, file);
- IASTName name= getSelectedName(astTU, content.indexOf("var; // r1"), 3);
- IBinding binding= name.resolveBinding();
- checkBinding(name, IVariable.class);
+ IASTName name= getSelectedName(astTU, content.indexOf("var; // r1"), 3);
+ IBinding binding= name.resolveBinding();
+ checkBinding(name, IVariable.class);
- name= getSelectedName(astTU, content.indexOf("var; // r2"), 3);
- checkBinding(name, IVariable.class);
+ name= getSelectedName(astTU, content.indexOf("var; // r2"), 3);
+ checkBinding(name, IVariable.class);
+ }
+ finally {
+ index.releaseReadLock();
+ }
}
// {testMethods.h}
@@ -141,22 +162,29 @@ public class ResolveBindingTests extends BaseTestCase {
IFile hfile= createFile(fCProject.getProject(), "testMethods.h", content);
content = readTaggedComment("testMethods.cpp");
IFile cppfile= createFile(fCProject.getProject(), "testMethods.cpp", content);
- waitForIndexer(fPdom, hfile, WAIT_FOR_INDEXER);
+ waitForIndexer(fIndex, hfile, WAIT_FOR_INDEXER);
- IASTTranslationUnit astTU= createPDOMBasedAST(fCProject, cppfile);
+ IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
+ index.acquireReadLock();
+ try {
+ IASTTranslationUnit astTU= createIndexBasedAST(index, fCProject, cppfile);
- IASTName name= getSelectedName(astTU, content.indexOf("method"), 6);
- IBinding binding= name.resolveBinding();
- checkBinding(name, ICPPMethod.class);
+ IASTName name= getSelectedName(astTU, content.indexOf("method"), 6);
+ IBinding binding= name.resolveBinding();
+ checkBinding(name, ICPPMethod.class);
- name= getSelectedName(astTU, content.indexOf("method(); // r1"), 6);
- checkBinding(name, ICPPMethod.class);
+ name= getSelectedName(astTU, content.indexOf("method(); // r1"), 6);
+ checkBinding(name, ICPPMethod.class);
- name= getSelectedName(astTU, content.indexOf("method(); // r2"), 6);
- checkBinding(name, ICPPMethod.class);
+ name= getSelectedName(astTU, content.indexOf("method(); // r2"), 6);
+ checkBinding(name, ICPPMethod.class);
- name= getSelectedName(astTU, content.indexOf("method(); // r3"), 6);
- checkBinding(name, ICPPMethod.class);
+ name= getSelectedName(astTU, content.indexOf("method(); // r3"), 6);
+ checkBinding(name, ICPPMethod.class);
+ }
+ finally {
+ index.releaseReadLock();
+ }
}
}

Back to the top