diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/index/provider/test/Providers.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/index/provider/test/Providers.java index 4b0c4c8863f..ed7073e23a0 100644 --- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/index/provider/test/Providers.java +++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/index/provider/test/Providers.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Symbian Software Ltd. and others. + * Copyright (c) 2007, 2012 Symbian Software Ltd. 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 @@ -10,10 +10,22 @@ *******************************************************************************/ package org.eclipse.cdt.core.internal.index.provider.test; +import org.eclipse.cdt.core.index.provider.IPDOMDescriptor; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; + public class Providers { public static class Dummy1 extends AbstractDummyProvider {} public static class Dummy2 extends AbstractDummyProvider {} public static class Dummy3 extends AbstractDummyProvider {} public static class Dummy4 extends AbstractDummyProvider {} public static class Dummy5 extends AbstractDummyProvider {} + + public static class Counter extends AbstractDummyProvider{ + public static int fCounter; + @Override + public IPDOMDescriptor[] getDescriptors(ICConfigurationDescription config) { + fCounter++; + return super.getDescriptors(config); + } + } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java index 56972251173..8cca0127195 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java @@ -240,6 +240,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa // void m2(const StrT s) {} // }; + // #include "header.h" // void main() { // C1 c1; // c1.m1("aaa"); // OK @@ -274,6 +275,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa // public: void assign(const T* s) {} // }; + // #include "header.h" // void main() { // StrT x; // x.assign("aaa"); @@ -355,6 +357,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa // void m3(); // }; + // #include "header.h" // void C1::m3() { // m1("aaa"); // OK // m2("aaa"); // problem @@ -565,11 +568,10 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa // template // class D {}; + // #include "header.h" // template class D; // harmless declaration for test purposes - // template - // class D {}; - // template - // class D {}; + // template class D {}; + // template class D {}; public void testClassPartialSpecializations() throws Exception { IBinding b0= getBindingFromASTName("D", 8); IBinding b1= getBindingFromASTName("D", 8); @@ -1170,6 +1172,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa // class B {}; // }; + // #include "header.h" // void refs() { // A::B acb; // A::B adb; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCompositeTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCompositeTests.java index 3b052cc546d..c4459a9db25 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCompositeTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCompositeTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Symbian Software Systems and others. + * Copyright (c) 2007, 2012 Symbian 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 @@ -108,6 +108,7 @@ public class IndexCompositeTests extends BaseTestCase { // enum E {E1,E2}; // void foo(C1 c) {} + // #include "h3.h" // class B1 {}; // namespace X { class B2 {}; } // C1 c1; @@ -115,6 +116,7 @@ public class IndexCompositeTests extends BaseTestCase { // void foo(B1 c) {} // void foo(X::C2 c) {} + // #include "h2.h" // class A1 {}; // void foo(X::B2 c) {} // namespace X { class A2 {}; B2 b; C2 c; } @@ -140,68 +142,75 @@ public class IndexCompositeTests extends BaseTestCase { /* Defines Global, Defines Namespace, References Global, References Namespace * projC: 6, 2, 0, 0 - * projB: 6, 1, 1, 1 - * projA: 3, 3, 0, 2 + * projB: 6, 1, 1, 1 + projC + * projA: 3, 3, 0, 2 + projB + projC */ + final int gC= 6, aC= gC + 2; + final int gB= 6, aB= gB + 1; + final int gA= 3, aA= gA + 3; + + final int gBC= gB+gC-1, aBC= aB+aC-1; + final int gABC= gA+gBC-1, aABC= aA+aBC-1; + setIndex(cprojC, NONE); - assertBCount(6, 6 +2); assertNamespaceXMemberCount(1); + assertBCount(gC, aC); assertNamespaceXMemberCount(1); assertFieldCount("C1", 1); setIndex(cprojC, REFS); - assertBCount(6, 6 +2); + assertBCount(gC, aC); assertNamespaceXMemberCount(1); assertFieldCount("C1", 1); setIndex(cprojC, REFD); - assertBCount((6+(6-1)+(3-1)), (6+2)+(6+1-1)+(3+3-1)); + assertBCount(gABC, aABC); assertNamespaceXMemberCount(5); assertFieldCount("C1", 1); setIndex(cprojC, BOTH); - assertBCount((6+(6-1)+(3-1)), (6+2)+(6+1-1)+(3+3-1)); + assertBCount(gABC, aABC); assertNamespaceXMemberCount(5); assertFieldCount("C1", 1); setIndex(cprojB, NONE); - assertBCount(6+1, 6+1+1+1); + assertBCount(gBC, aBC); assertNamespaceXMemberCount(2); assertFieldCount("C1", 1); setIndex(cprojB, REFS); - assertBCount(6+1+6-1-1, (6+1+1+1)-1-1 + (6+2) -1); + assertBCount(gBC, aBC); assertNamespaceXMemberCount(2); assertFieldCount("C1", 1); setIndex(cprojB, REFD); - assertBCount(6+1+3-1, (6+1+1+1) + (3+3) -1); + assertBCount(gABC, aABC); assertNamespaceXMemberCount(5); assertFieldCount("C1", 1); setIndex(cprojB, BOTH); - assertBCount((6+1)-1+3+6 -2, (6+1+1+1)-1-1 + (3+3+2)-2 + (6+2) -2); + assertBCount(gABC, aABC); assertNamespaceXMemberCount(5); assertFieldCount("C1", 1); setIndex(cprojA, NONE); - assertBCount(3, 8); + assertBCount(gABC, aABC); assertNamespaceXMemberCount(5); // binding C1 is not referenced by cprojA setIndex(cprojA, REFS); - assertBCount(6+6+3-1-1, (6+1+1+1)-1-1 + (3+3+2)-2 + (6+2) -2); + assertBCount(gABC, aABC); assertNamespaceXMemberCount(5); assertFieldCount("C1", 1); setIndex(cprojA, REFD); - assertBCount(3, 8); + assertBCount(gABC, aABC); assertNamespaceXMemberCount(5); // binding C1 is not referenced by cprojA setIndex(cprojA, BOTH); - assertBCount(6+6+3-1-1, (6+1+1+1)-1-1 + (3+3+2)-2 + (6+2) -2); + assertBCount(gABC, aABC); assertNamespaceXMemberCount(5); assertFieldCount("C1", 1); } finally { @@ -210,40 +219,43 @@ public class IndexCompositeTests extends BaseTestCase { } } - // class C1 {}; - // namespace X { class C2 {}; B1 b; } - // enum E {E1,E2}; - // X::B2 cb; - // void foo(C1 c) {} - // class B1 {}; // namespace X { class B2 {}; } // void foo(B1 c) {} // void foo(X::B2 c, B1 c) {} + // #include "h2.h" // class A1 {}; // void foo(X::B2 c) {} // namespace X { class A2 {}; } // B1 ab; + + // #include "h2.h" + // class C1 {}; + // namespace X { class C2 {}; B1 b; } + // enum E {E1,E2}; + // X::B2 cb; + // void foo(C1 c) {} public void testTripleUpwardV() throws Exception { CharSequence[] contents = getContentsForTest(3); List projects = new ArrayList(); try { ProjectBuilder pb = new ProjectBuilder("projB"+System.currentTimeMillis(), true); - pb.addFile("h2.h", contents[1]); + pb.addFile("h2.h", contents[0]); ICProject cprojB = pb.create(); projects.add(cprojB); + pb = new ProjectBuilder("projA"+System.currentTimeMillis(), true); + pb.addFile("h1.h", contents[1]).addDependency(cprojB.getProject()); + ICProject cprojA = pb.create(); + projects.add(cprojA); + pb = new ProjectBuilder("projC"+System.currentTimeMillis(), true); - pb.addFile("h3.h", contents[0]).addDependency(cprojB.getProject()); + pb.addFile("h3.h", contents[2]).addDependency(cprojB.getProject()); ICProject cprojC = pb.create(); projects.add(cprojC); - pb = new ProjectBuilder("projB"+System.currentTimeMillis(), true); - pb.addFile("h1.h", contents[2]).addDependency(cprojB.getProject()); - ICProject cprojA = pb.create(); - projects.add(cprojA); /* A C | * \ / | Depends On / References @@ -254,44 +266,53 @@ public class IndexCompositeTests extends BaseTestCase { * projB: 4, 1, 0, 0 * projA: 4, 1, 1, 1 */ + + final int gC= 7, aC= gC + 2; + final int gB= 4, aB= gB + 1; + final int gA= 4, aA= gA + 1; + + final int gBC= gB+gC-1, aBC= aB+aC-1; + final int gAB= gA+gB-1, aAB= aA+aB-1; + final int gABC= gA+gBC-1, aABC= aA+aBC-1; + setIndex(cprojC, NONE); - assertBCount(7+1, 7+2+1+1); + assertBCount(gBC, aBC); assertNamespaceXMemberCount(3); setIndex(cprojC, REFS); - assertBCount(7+1+4-1-1, 7+1+1+2+4+1-1-2); + assertBCount(gBC, aBC); assertNamespaceXMemberCount(3); setIndex(cprojC, REFD); - assertBCount(7+1, 7+1+1+2); + assertBCount(gBC, aBC); assertNamespaceXMemberCount(3); setIndex(cprojC, BOTH); - assertBCount(7+4+4-2, 7+4+4-2 +2+1+1); + assertBCount(gABC, aABC); assertNamespaceXMemberCount(4); setIndex(cprojB, NONE); - assertBCount(4, 4+1); + assertBCount(gB, aB); assertNamespaceXMemberCount(1); setIndex(cprojB, REFS); - assertBCount(4, 4+1); + assertBCount(gB, aB); assertNamespaceXMemberCount(1); setIndex(cprojB, REFD); - assertBCount(7+4+4-2, 7+4+4-2 +2+1+1); + assertBCount(gABC, aABC); assertNamespaceXMemberCount(4); setIndex(cprojB, BOTH); - assertBCount(7+4+4-2, 7+4+4-2 +2+1+1); + assertBCount(gABC, aABC); assertNamespaceXMemberCount(4); setIndex(cprojA, NONE); - assertBCount(4+1, 4+1+1+1); + assertBCount(gAB, aAB); assertNamespaceXMemberCount(2); setIndex(cprojA, REFS); - assertBCount(4+1+4-1-1, 4+1+4-1-1 +1+1); + assertBCount(gAB, aAB); assertNamespaceXMemberCount(2); setIndex(cprojA, REFD); - assertBCount(4+1, 4+1+1+1); + assertBCount(gAB, aAB); assertNamespaceXMemberCount(2); setIndex(cprojA, BOTH); - assertBCount(7+4+4-2, 7+4+4-2 +2+1+1); + assertBCount(gABC, aABC); assertNamespaceXMemberCount(4); } finally { for (Iterator i = projects.iterator(); i.hasNext();) @@ -304,11 +325,13 @@ public class IndexCompositeTests extends BaseTestCase { // enum E {E1,E2}; // void foo(C1 c) {} + // #include "h3.h" + // #include "h1.h" // class B1 {}; // namespace X { class B2 {}; C1 c; } // void foo(A1 c) {} // void foo(X::A2 c, B1 c) {} - + // class A1 {}; // void foo(A1 a, A1 b) {} // namespace X { class A2 {}; } @@ -342,43 +365,51 @@ public class IndexCompositeTests extends BaseTestCase { * projA: 3, 1, 0, 0 */ + final int gC= 6, aC= gC + 1; + final int gB= 4, aB= gB + 2; + final int gA= 3, aA= gA + 1; + + final int gBC= gB+gC-1, aBC= aB+aC-1; + final int gAB= gA+gB-1, aAB= aA+aB-1; + final int gABC= gA+gBC-1, aABC= aA+aBC-1; + setIndex(cprojC, NONE); - assertBCount(6, 6+1); + assertBCount(gC, aC); assertNamespaceXMemberCount(1); setIndex(cprojC, REFS); - assertBCount(6, 6+1); + assertBCount(gC, aC); assertNamespaceXMemberCount(1); setIndex(cprojC, REFD); - assertBCount(6+4+1-1, 6+4+1-1 +1+1+1+1); + assertBCount(gABC, aABC); assertNamespaceXMemberCount(4); setIndex(cprojC, BOTH); - assertBCount(6+4+3-2, 6+4+3-2 +1+2+1); + assertBCount(gABC, aABC); assertNamespaceXMemberCount(4); setIndex(cprojB, NONE); - assertBCount(4+2, 4+2 +2+1); + assertBCount(gABC, aABC); assertNamespaceXMemberCount(4); setIndex(cprojB, REFS); - assertBCount(6+4+3-2, 6+4+3-2 +1+2+1); + assertBCount(gABC, aABC); assertNamespaceXMemberCount(4); setIndex(cprojB, REFD); - assertBCount(4+2, 4+2 +2+1); + assertBCount(gABC, aABC); assertNamespaceXMemberCount(4); setIndex(cprojB, BOTH); - assertBCount(6+4+3-2, 6+4+3-2 +1+2+1); + assertBCount(gABC, aABC); assertNamespaceXMemberCount(4); setIndex(cprojA, NONE); - assertBCount(3, 3 +1); + assertBCount(gA, aA); assertNamespaceXMemberCount(1); setIndex(cprojA, REFS); - assertBCount(3, 3 +1); + assertBCount(gA, aA); assertNamespaceXMemberCount(1); setIndex(cprojA, REFD); - assertBCount(4+2+3-1-1, 4+2+3-1-1 +2+1); + assertBCount(gABC, aABC); assertNamespaceXMemberCount(4); setIndex(cprojA, BOTH); - assertBCount(6+4+3-2, 6+4+3-2 +1+2+1); + assertBCount(gABC, aABC); assertNamespaceXMemberCount(4); } finally { for (Iterator i = projects.iterator(); i.hasNext();) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java index 74785d27b5f..1e963510c0e 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java @@ -1,12 +1,13 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Symbian Software Systems and others. + * Copyright (c) 2007, 2012 Symbian 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: - * Andrew Ferguson (Symbian) - Initial implementation + * Andrew Ferguson (Symbian) - Initial implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.index.tests; @@ -22,6 +23,7 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor; 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.index.provider.IIndexProvider; import org.eclipse.cdt.core.internal.index.provider.test.DummyProviderTraces; import org.eclipse.cdt.core.internal.index.provider.test.Providers; @@ -68,6 +70,8 @@ import org.eclipse.osgi.service.resolver.VersionRange; * Example usage and test for IIndexProvider */ public class IndexProviderManagerTest extends IndexTestBase { + private static final int A_FRAGMENT_OPTION = IIndexManager.ADD_EXTENSION_FRAGMENTS_NAVIGATION; + final static DummyProviderTraces DPT= DummyProviderTraces.getInstance(); final static Class DP1= Providers.Dummy1.class; final static Class DP2= Providers.Dummy2.class; @@ -115,7 +119,7 @@ public class IndexProviderManagerTest extends IndexTestBase { try { for(int i=0; i<3; i++) { ICProject cproject = CProjectHelper.createCProject("P"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER); - IIndex index = CCorePlugin.getIndexManager().getIndex(cproject); + IIndex index = CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION); cprojects.add(cproject); expectedTrace.add(cproject); } @@ -123,7 +127,7 @@ public class IndexProviderManagerTest extends IndexTestBase { assertEquals(expectedTrace, DPT.getProjectsTrace(element)); for(int i=0; i + + + + + + + + + + + + + + + + + + + + + + + + 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 d63bc6072f6..57eb60715b8 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 QNX Software Systems and others. + * Copyright (c) 2004, 2012 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 @@ -18,6 +18,7 @@ import org.eclipse.cdt.core.CCorePlugin; 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.IIndexManager; import org.eclipse.cdt.core.index.IndexFilter; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICElement; @@ -47,7 +48,7 @@ public class AllTypesCache { private static final boolean DEBUG = false; private static ITypeInfo[] getTypes(ICProject[] projects, final int[] kinds, IProgressMonitor monitor) throws CoreException { - IIndex index = CCorePlugin.getIndexManager().getIndex(projects); + IIndex index = CCorePlugin.getIndexManager().getIndex(projects, IIndexManager.ADD_EXTENSION_FRAGMENTS_NAVIGATION); try { index.acquireReadLock(); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTCache.java index 3738e9246db..8bfe0fde6af 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTCache.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTCache.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2007, 2012 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 @@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.core.model; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.index.IIndex; -import org.eclipse.cdt.core.index.IIndexManager; import org.eclipse.cdt.core.model.ILanguage; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit; @@ -205,7 +204,7 @@ public class ASTCache { ASTRunnable astRunnable) { IIndex index; try { - index = CCorePlugin.getIndexManager().getIndex(tUnit.getCProject(), IIndexManager.ADD_DEPENDENCIES); + index = CCorePlugin.getIndexManager().getIndex(tUnit.getCProject()); index.acquireReadLock(); } catch (CoreException e) { return e.getStatus(); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder2.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder2.java index 8b3966eb81b..5f1c040c119 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder2.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder2.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2011 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2012 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 @@ -121,7 +121,7 @@ public class CModelBuilder2 implements IContributedModelBuilder { @Override public void parse(boolean quickParseMode) throws Exception { final IIndexManager indexManager= CCorePlugin.getIndexManager(); - IIndex index= indexManager.getIndex(fTranslationUnit.getCProject(), IIndexManager.ADD_DEPENDENCIES); + IIndex index= indexManager.getIndex(fTranslationUnit.getCProject()); try { if (index != null) { 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 index 338b6b09f0b..34b00db01de 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2011 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2012 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 @@ -43,21 +43,74 @@ public interface IIndexManager extends IPDOMManager { public final static int ADD_DEPENDENT = 0x2; /** - * Constant for passing to getIndex methods. This constant, when set, indicates that the index - * content provided via the CIndex extension point should not be included in the resulting - * index, as it would have done otherwise. + * @deprecated Extension fragments are now used depending on their configuration. + * Use one of the ADD_EXTENSION_XX flags instead. */ + @Deprecated public final static int SKIP_PROVIDED = 0x4; /** - * Constant for passing to getIndex methods. This constant, when set, indicates that the index - * content provided via the ReadOnlyIndexFragmentProvider element of the CIndex extension point - * should be included in the resulting index. By default such index content is not included. - * This flag is ignored if SKIP_PROVIDED flag is set. + * Constant for passing to getIndex methods. This constant, when set, indicates that each index + * content provided via the ReadOnlyIndexFragmentProvider or ReadOnlyPDOMProvider, which is not + * disabled for navigation shall be included in the resulting index. * * @since 5.4 */ - public final static int ADD_EXTENSION_FRAGMENTS = 0x8; + public final static int ADD_EXTENSION_FRAGMENTS_NAVIGATION = 0x8; + + /** + * Constant for passing to getIndex methods. This constant, when set, indicates that the each index + * content provided via the ReadOnlyIndexFragmentProvider or ReadOnlyPDOMProvider, which is not + * disabled for content assist shall be included in the resulting index. + * + * @since 5.4 + */ + public final static int ADD_EXTENSION_FRAGMENTS_CONTENT_ASSIST = 0x10; + + /** + * Constant for passing to getIndex methods. This constant, when set, indicates that each index + * content provided via the ReadOnlyIndexFragmentProvider or ReadOnlyPDOMProvider, which is not + * disabled for add import shall be included in the resulting index. + * + * @since 5.4 + */ + public final static int ADD_EXTENSION_FRAGMENTS_ADD_IMPORT = 0x20; + + /** + * Constant for passing to getIndex methods. This constant, when set, indicates that each index + * content provided via the ReadOnlyIndexFragmentProvider or ReadOnlyPDOMProvider, which is not + * disabled for the call hierarchy shall be included in the resulting index. + * + * @since 5.4 + */ + public final static int ADD_EXTENSION_FRAGMENTS_CALL_HIERARCHY = 0x40; + + /** + * Constant for passing to getIndex methods. This constant, when set, indicates that each index + * content provided via the ReadOnlyIndexFragmentProvider or ReadOnlyPDOMProvider, which is not + * disabled for the type hierarchy shall be included in the resulting index. + * + * @since 5.4 + */ + public final static int ADD_EXTENSION_FRAGMENTS_TYPE_HIERARCHY = 0x80; + + /** + * Constant for passing to getIndex methods. This constant, when set, indicates that each index + * content provided via the ReadOnlyIndexFragmentProvider or ReadOnlyPDOMProvider, which is not + * disabled for the include browser shall be included in the resulting index. + * + * @since 5.4 + */ + public final static int ADD_EXTENSION_FRAGMENTS_INCLUDE_BROWSER = 0x100; + + /** + * Constant for passing to getIndex methods. This constant, when set, indicates that each index + * content provided via the ReadOnlyIndexFragmentProvider or ReadOnlyPDOMProvider, which is not + * disabled for the search shall be included in the resulting index. + * + * @since 5.4 + */ + public final static int ADD_EXTENSION_FRAGMENTS_SEARCH = 0x200; /** * Constant for indicating there is no time out period for joining the indexer job. 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 index 1d85f7fd0b1..30fd9d70b74 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2011 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2012 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 @@ -60,7 +60,6 @@ public class CIndex implements IIndex { private static final boolean SPECIALCASE_SINGLES = true; private final IIndexFragment[] fFragments; - private final int fPrimaryFragmentCount; private int fReadLock; private ICompositesFactory cppCF, cCF, fCF; @@ -69,16 +68,9 @@ public class CIndex implements IIndex { * * @param fragments Fragments constituting the index. If there are extended fragments, * they are located in the array after the PDOM fragments for the same project. - * @param primaryFragmentCount The number of primary index fragments. This number may include - * extended fragments. */ - public CIndex(IIndexFragment[] fragments, int primaryFragmentCount) { - fFragments= fragments; - fPrimaryFragmentCount= primaryFragmentCount; - } - public CIndex(IIndexFragment[] fragments) { - this(fragments, fragments.length); + fFragments= fragments; } @Override @@ -89,12 +81,12 @@ public class CIndex implements IIndex { if (SPECIALCASE_SINGLES && fFragments.length == 1) { return fFragments[0].findBinding((IASTName) name); } else { - for (int i = 0; i < fPrimaryFragmentCount; i++) { - IIndexFragmentBinding binding= fFragments[i].findBinding((IASTName) name); + for (IIndexFragment fragment : fFragments) { + IIndexFragmentBinding binding= fragment.findBinding((IASTName) name); if (binding != null) { return getCompositesFactory(binding.getLinkage().getLinkageID()).getCompositeBinding(binding); } - } + } } } return null; @@ -116,8 +108,8 @@ public class CIndex implements IIndex { ILinkage[] linkages = Linkage.getIndexerLinkages(); for (ILinkage linkage : linkages) { if (filter.acceptLinkage(linkage)) { - IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][]; - for (int i = 0; i < fPrimaryFragmentCount; i++) { + IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fFragments.length][]; + for (int i = 0; i < fFragments.length; i++) { try { IBinding[] part = fFragments[i].findBindings(patterns, isFullyQualified, retargetFilter(linkage, filter), monitor); @@ -146,8 +138,8 @@ public class CIndex implements IIndex { ILinkage[] linkages = Linkage.getIndexerLinkages(); for (ILinkage linkage : linkages) { if (filter.acceptLinkage(linkage)) { - IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][]; - for (int i = 0; i < fPrimaryFragmentCount; i++) { + IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fFragments.length][]; + for (int i = 0; i < fFragments.length; i++) { try { IBinding[] part = fFragments[i].findMacroContainers(pattern, retargetFilter(linkage, filter), monitor); @@ -186,13 +178,28 @@ public class CIndex implements IIndex { // Collect the names from all fragments. Since the same file may be represented by multiple // variants in one or more index fragments, we need to filter out duplicate names. - // See bug 192352. + // See bug 192352. + // Read only fragments can be superseded by what the indexer writes into + // a writable fragment. Therefore names from a read-only fragement are + // ignored if there is a match in a writable fragment. HashSet encounteredNames = new HashSet(); - for (int i = 0; i < fPrimaryFragmentCount; i++) { - final IIndexFragmentName[] names = fFragments[i].findNames(binding, flags); - for (IIndexFragmentName name : names) { - if (encounteredNames.add(new NameKey(name))) { - result.add(name); + for (IIndexFragment fragment : fFragments) { + if (fragment instanceof IWritableIndexFragment) { + final IIndexFragmentName[] names = fragment.findNames(binding, flags); + for (IIndexFragmentName name : names) { + if (encounteredNames.add(new NameKey(name, true))) { + result.add(name); + } + } + } + } + for (IIndexFragment fragment : fFragments) { + if (!(fragment instanceof IWritableIndexFragment)) { + final IIndexFragmentName[] names = fragment.findNames(binding, flags); + for (IIndexFragmentName name : names) { + if (encounteredNames.add(new NameKey(name, false))) { + result.add(name); + } } } } @@ -217,8 +224,8 @@ public class CIndex implements IIndex { @Override @Deprecated public IIndexFile getFile(int linkageID, IIndexFileLocation location) throws CoreException { - for (int i = 0; i < fPrimaryFragmentCount; i++) { - IIndexFragmentFile candidate= fFragments[i].getFile(linkageID, location); + for (IIndexFragment fragment : fFragments) { + IIndexFragmentFile candidate= fragment.getFile(linkageID, location); if (candidate != null && candidate.hasContent()) { return candidate; } @@ -229,8 +236,8 @@ public class CIndex implements IIndex { @Override public IIndexFile getFile(int linkageID, IIndexFileLocation location, ISignificantMacros significantMacros) throws CoreException { - for (int i = 0; i < fPrimaryFragmentCount; i++) { - IIndexFragmentFile candidate= fFragments[i].getFile(linkageID, location, significantMacros); + for (IIndexFragment fragment : fFragments) { + IIndexFragmentFile candidate= fragment.getFile(linkageID, location, significantMacros); if (candidate != null && candidate.hasContent()) { return candidate; } @@ -245,8 +252,8 @@ public class CIndex implements IIndex { } Set handled = new HashSet(); ArrayList result= new ArrayList(); - for (int i = 0; i < fPrimaryFragmentCount; i++) { - IIndexFragmentFile[] candidates= fFragments[i].getFiles(linkageID, location); + for (IIndexFragment fragment : fFragments) { + IIndexFragmentFile[] candidates= fragment.getFiles(linkageID, location); for (IIndexFragmentFile candidate : candidates) { if (candidate.hasContent()) { ISignificantMacros macroKey = candidate.getSignificantMacros(); @@ -269,8 +276,8 @@ public class CIndex implements IIndex { } Set keys = new HashSet(); ArrayList result= new ArrayList(); - for (int i = 0; i < fPrimaryFragmentCount; i++) { - IIndexFragmentFile[] candidates= fFragments[i].getFiles(location); + for (IIndexFragment fragment : fFragments) { + IIndexFragmentFile[] candidates= fragment.getFiles(location); for (IIndexFragmentFile candidate : candidates) { if (candidate.hasContent()) { if (keys.add(new FileContentKey(candidate.getLinkageID(), candidate.getLocation(), candidate.getSignificantMacros()))) { @@ -317,8 +324,8 @@ public class CIndex implements IIndex { List nextLevel= depth != 0 ? new LinkedList() : null; for (IIndexFile iIndexFile : in) { IIndexFragmentFile file = (IIndexFragmentFile) iIndexFile; - for (int j = 0; j < fPrimaryFragmentCount; j++) { - IIndexInclude[] includedBy= fFragments[j].findIncludedBy(file); + for (IIndexFragment fragment : fFragments) { + IIndexInclude[] includedBy= fragment.findIncludedBy(file); for (IIndexInclude include : includedBy) { final IIndexFile includer = include.getIncludedBy(); FileContentKey key= new FileContentKey(linkageID, includer.getLocation(), includer.getSignificantMacros()); @@ -452,8 +459,8 @@ public class CIndex implements IIndex { monitor.beginTask(Messages.CIndex_FindBindingsTask_label, fFragments.length * linkages.length); for (ILinkage linkage : linkages) { if (filter.acceptLinkage(linkage)) { - IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][]; - for (int i = 0; i < fPrimaryFragmentCount; i++) { + IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fFragments.length][]; + for (int i = 0; i < fFragments.length; i++) { try { IBinding[] part = fFragments[i].findBindings(names, retargetFilter(linkage, filter), new SubProgressMonitor(monitor, 1)); @@ -479,8 +486,8 @@ public class CIndex implements IIndex { if (SPECIALCASE_SINGLES && fFragments.length == 1) { return fFragments[0].adaptBinding(binding); } else { - for (int i = 0; i < fPrimaryFragmentCount; i++) { - IIndexFragmentBinding adaptedBinding= fFragments[i].adaptBinding(binding); + for (IIndexFragment fragment : fFragments) { + IIndexFragmentBinding adaptedBinding= fragment.adaptBinding(binding); if (adaptedBinding != null) { return getCompositesFactory(binding.getLinkage().getLinkageID()).getCompositeBinding(adaptedBinding); } @@ -517,10 +524,8 @@ public class CIndex implements IIndex { return result; } - public IIndexFragment[] getPrimaryFragments() { - IIndexFragment[] result= new IIndexFragment[fPrimaryFragmentCount]; - System.arraycopy(fFragments, 0, result, 0, fPrimaryFragmentCount); - return result; + public IIndexFragment[] getFragments() { + return fFragments; } public IIndexFragmentBinding[] findEquivalentBindings(IBinding binding) throws CoreException { @@ -538,19 +543,19 @@ public class CIndex implements IIndex { switch (linkageID) { case ILinkage.CPP_LINKAGE_ID: if (cppCF == null) { - cppCF = new CPPCompositesFactory(new CIndex(fFragments, fFragments.length)); + cppCF = new CPPCompositesFactory(this); } return cppCF; case ILinkage.C_LINKAGE_ID: if (cCF == null) { - cCF = new CCompositesFactory(new CIndex(fFragments, fFragments.length)); + cCF = new CCompositesFactory(this); } return cCF; case ILinkage.FORTRAN_LINKAGE_ID: if (fCF == null) { - fCF = new CCompositesFactory(new CIndex(fFragments, fFragments.length)); + fCF = new CCompositesFactory(this); } // This is a placeholder - it will throw CompositingNotImplementedError // if non-empty (non-c) results are returned by a fragment @@ -582,8 +587,8 @@ public class CIndex implements IIndex { ILinkage[] linkages = Linkage.getIndexerLinkages(); for (ILinkage linkage : linkages) { if (filter.acceptLinkage(linkage)) { - IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][]; - for (int i = 0; i < fPrimaryFragmentCount; i++) { + IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fFragments.length][]; + for (int i = 0; i < fFragments.length; i++) { try { IBinding[] part = fFragments[i].findBindingsForPrefix(prefix, filescope, retargetFilter(linkage, filter), monitor); @@ -612,8 +617,8 @@ public class CIndex implements IIndex { ILinkage[] linkages = Linkage.getIndexerLinkages(); for (ILinkage linkage : linkages) { if (filter.acceptLinkage(linkage)) { - IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][]; - for (int i = 0; i < fPrimaryFragmentCount; i++) { + IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fFragments.length][]; + for (int i = 0; i < fFragments.length; i++) { try { IBinding[] part = fFragments[i].findBindingsForContentAssist(prefix, filescope, retargetFilter(linkage, filter), monitor); @@ -642,8 +647,8 @@ public class CIndex implements IIndex { ILinkage[] linkages = Linkage.getIndexerLinkages(); for (ILinkage linkage : linkages) { if (filter.acceptLinkage(linkage)) { - IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][]; - for (int i = 0; i < fPrimaryFragmentCount; i++) { + IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fFragments.length][]; + for (int i = 0; i < fFragments.length; i++) { try { IBinding[] part = fFragments[i].findBindings(name, filescope, retargetFilter(linkage, filter), monitor); @@ -683,10 +688,10 @@ public class CIndex implements IIndex { List result = new ArrayList(); HashSet handledIFLs= new HashSet(); monitor.beginTask(Messages.CIndex_FindBindingsTask_label, fFragments.length); - for (int i = 0; i < fPrimaryFragmentCount; i++) { + for (IIndexFragment fragment : fFragments) { HashSet allowedFiles= new HashSet(); try { - IIndexMacro[] macros= fFragments[i].findMacros(name, isPrefix, caseSensitive, filter, + IIndexMacro[] macros= fragment.findMacros(name, isPrefix, caseSensitive, filter, new SubProgressMonitor(monitor, 1)); for (IIndexMacro indexMacro : macros) { IIndexFile file= indexMacro.getFile(); @@ -759,8 +764,8 @@ public class CIndex implements IIndex { return fFragments[0].getInlineNamespaces(); } - IIndexFragmentBinding[][] preresult = new IIndexFragmentBinding[fPrimaryFragmentCount][]; - for (int i = 0; i < fPrimaryFragmentCount; i++) { + IIndexFragmentBinding[][] preresult = new IIndexFragmentBinding[fFragments.length][]; + for (int i = 0; i < fFragments.length; i++) { IIndexScope[] raw = fFragments[i].getInlineNamespaces(); IIndexFragmentBinding[] arr = preresult[i] = new IIndexFragmentBinding[raw.length]; for (int j = 0; j < raw.length; j++) { @@ -784,17 +789,19 @@ public class CIndex implements IIndex { private final IIndexFileLocation location; private final int linkageID; private final int offset; + private final boolean inWritableFragment; - NameKey(IIndexFragmentName name) throws CoreException { + NameKey(IIndexFragmentName name, boolean writable) throws CoreException { IIndexFile file = name.getFile(); location = file.getLocation(); linkageID = file.getLinkageID(); offset = name.getNodeOffset(); + inWritableFragment= writable; } @Override public int hashCode() { - return (location.hashCode() * 31 + linkageID) * 31 + offset; + return location.hashCode() * 31 + linkageID; } @Override @@ -806,7 +813,8 @@ public class CIndex implements IIndex { if (getClass() != obj.getClass()) return false; NameKey other = (NameKey) obj; - if (offset != other.offset) + // Offset is significant only if matches are from same kind of fragment + if (inWritableFragment == other.inWritableFragment && offset != other.offset) return false; if (linkageID != other.linkageID) return false; 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 index b0833880aae..3ee2a3f7d21 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2012 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 @@ -16,7 +16,6 @@ import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement; import org.eclipse.cdt.core.index.IIndex; -import org.eclipse.cdt.core.index.IIndexFile; import org.eclipse.cdt.core.index.IIndexFileLocation; import org.eclipse.cdt.core.parser.ISignificantMacros; import org.eclipse.cdt.internal.core.pdom.ASTFilePathResolver; @@ -47,11 +46,6 @@ public interface IWritableIndex extends IIndex { } } - /** - * Checks whether the given file can be written to in this index. - */ - boolean isWritableFile(IIndexFile file); - /** * Returns a writable file for the given location, linkage, and the set of macro definitions, * or null. This method returns file objects without content, also. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFactory.java index 4f53ea73de6..d1bae72aef7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2012 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 @@ -13,12 +13,16 @@ package org.eclipse.cdt.internal.core.index; +import static org.eclipse.cdt.core.index.IIndexManager.*; + import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Set; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.index.IIndex; @@ -40,11 +44,11 @@ import org.eclipse.osgi.util.NLS; * @since 4.0 */ public class IndexFactory { - private static final int ADD_DEPENDENCIES = IIndexManager.ADD_DEPENDENCIES; - private static final int ADD_DEPENDENT = IIndexManager.ADD_DEPENDENT; - private static final int SKIP_PROVIDED = IIndexManager.SKIP_PROVIDED; - private static final int ADD_EXTENSION_FRAGMENTS = IIndexManager.ADD_EXTENSION_FRAGMENTS; - + private static final int ALL_FRAGMENT_OPTIONS = ADD_EXTENSION_FRAGMENTS_ADD_IMPORT + | ADD_EXTENSION_FRAGMENTS_CALL_HIERARCHY | ADD_EXTENSION_FRAGMENTS_CONTENT_ASSIST + | ADD_EXTENSION_FRAGMENTS_INCLUDE_BROWSER | ADD_EXTENSION_FRAGMENTS_NAVIGATION + | ADD_EXTENSION_FRAGMENTS_SEARCH | ADD_EXTENSION_FRAGMENTS_TYPE_HIERARCHY; + private PDOMManager fPDOMManager; public IndexFactory(PDOMManager manager) { @@ -56,21 +60,18 @@ public class IndexFactory { boolean addDependencies= (options & ADD_DEPENDENCIES) != 0; boolean addDependent= (options & ADD_DEPENDENT) != 0; - boolean skipProvided= (options & SKIP_PROVIDED) != 0; - boolean addExtensionFragments= (options & ADD_EXTENSION_FRAGMENTS) != 0; + int fragmentUsage= options & ALL_FRAGMENT_OPTIONS; - HashMap map= new HashMap(); - Collection selectedProjects= getProjects(projects, addDependencies, addDependent, - map, new Integer(1)); + Collection indexProjects= + getProjects(projects, addDependencies, addDependent, new HashSet()); HashMap fragments= new LinkedHashMap(); - for (ICProject cproject : selectedProjects) { + for (ICProject cproject : indexProjects) { IIndexFragment pdom= fPDOMManager.getPDOM(cproject); if (pdom != null) { safeAddFragment(fragments, pdom); - - if (!skipProvided) { - safeAddProvidedFragments(cproject, fragments, addExtensionFragments); + if (fragmentUsage != 0) { + safeAddProvidedFragments(cproject, fragments, fragmentUsage); } } } @@ -78,105 +79,58 @@ public class IndexFactory { return EmptyCIndex.INSTANCE; } - int primaryFragmentCount= fragments.size(); - - if (!addDependencies) { - projects= 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 (ICProject cproject : selectedProjects) { - IIndexFragment pdom= fPDOMManager.getPDOM(cproject); - safeAddFragment(fragments, pdom); - - if (!skipProvided) { - safeAddProvidedFragments(cproject, fragments, addExtensionFragments); - } - } - } - Collection pdoms= fragments.values(); - return new CIndex(pdoms.toArray(new IIndexFragment[pdoms.size()]), primaryFragmentCount); + return new CIndex(pdoms.toArray(new IIndexFragment[pdoms.size()])); } public IWritableIndex getWritableIndex(ICProject project) throws CoreException { - Map readOnlyFrag= new LinkedHashMap(); IWritableIndexFragment pdom= (IWritableIndexFragment) fPDOMManager.getPDOM(project); if (pdom == null) { throw new CoreException(CCorePlugin.createStatus( NLS.bind(Messages.IndexFactory_errorNoSuchPDOM0, project.getElementName()))); } - safeAddProvidedFragments(project, readOnlyFrag, false); - - Collection selectedProjects= getProjects(new ICProject[] {project}, true, false, - new HashMap(), new Integer(1)); - selectedProjects.remove(project); - - for (ICProject cproject : selectedProjects) { - safeAddFragment(readOnlyFrag, fPDOMManager.getPDOM(cproject)); - } - - Collection readOnlyFragments= readOnlyFrag.values(); - return new WritableCIndex(pdom, readOnlyFragments.toArray(new IIndexFragment[readOnlyFragments.size()])); + return new WritableCIndex(pdom); } private Collection getProjects(ICProject[] projects, boolean addDependencies, - boolean addDependent, HashMap map, Integer markWith) { - List projectsToSearch= new ArrayList(); + boolean addDependent, Set handled) { + List result= new ArrayList(); for (ICProject cproject : projects) { - IProject project= cproject.getProject(); - checkAddProject(project, map, projectsToSearch, markWith); - projectsToSearch.add(project); + checkAddProject(cproject, handled, result); } if (addDependencies || addDependent) { - for (int i= 0; i < projectsToSearch.size(); i++) { - IProject project= projectsToSearch.get(i); - IProject[] nextLevel; + final CoreModel cm= CoreModel.getDefault(); + for (int i= 0; i < result.size(); i++) { + ICProject cproject= result.get(i); + IProject project= cproject.getProject(); try { if (addDependencies) { - nextLevel = project.getReferencedProjects(); - for (int j = 0; j < nextLevel.length; j++) { - checkAddProject(nextLevel[j], map, projectsToSearch, markWith); + for (IProject rp : project.getReferencedProjects()) { + checkAddProject(cm.create(rp), handled, result); } } if (addDependent) { - nextLevel= project.getReferencingProjects(); - for (int j = 0; j < nextLevel.length; j++) { - checkAddProject(nextLevel[j], map, projectsToSearch, markWith); + for (IProject rp : project.getReferencingProjects()) { + checkAddProject(cm.create(rp), handled, result); } } } catch (CoreException e) { // silently ignore - map.put(project, new Integer(0)); - } - } - } - - CoreModel cm= CoreModel.getDefault(); - Collection result= new ArrayList(); - for (Map.Entry entry : map.entrySet()) { - if (entry.getValue() == markWith) { - ICProject cproject= cm.create(entry.getKey()); - if (cproject != null) { - result.add(cproject); + handled.add(project); } } } 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)); - } - } + private void checkAddProject(ICProject cproject, Set handled, List target) { + if (cproject != null) { + IProject project= cproject.getProject(); + if (handled.add(project) && project.isOpen()) + target.add(cproject); + } } /** @@ -208,17 +162,17 @@ public class IndexFactory { * the CIndex extension point for the specified ICProject. * @param cproject The project to get the provided index fragments for. * @param fragments - * @param includeNonPDOMFragments + * @param usage the usage of the fragments in terms of {@link IIndexManager#ADD_EXTENSION_FRAGMENTS_ADD_IMPORT}, ... */ private void safeAddProvidedFragments(ICProject cproject, Map fragments, - boolean includeNonPDOMFragments) { + int usage) { ICProjectDescription pd= CoreModel.getDefault().getProjectDescription(cproject.getProject(), false); if (pd != null) { IndexProviderManager ipm = CCoreInternals.getPDOMManager().getIndexProviderManager(); ICConfigurationDescription cfg= pd.getDefaultSettingConfiguration(); if (cfg != null) { try { - IIndexFragment[] pFragments= ipm.getProvidedIndexFragments(cfg, includeNonPDOMFragments); + IIndexFragment[] pFragments= ipm.getProvidedIndexFragments(cfg, usage); for (IIndexFragment fragment : pFragments) { safeAddFragment(fragments, fragment); } 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 index dca03afd456..4772a4f8c92 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2012 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 @@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.core.index; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement; -import org.eclipse.cdt.core.index.IIndexFile; import org.eclipse.cdt.core.index.IIndexFileLocation; import org.eclipse.cdt.core.parser.ISignificantMacros; import org.eclipse.cdt.internal.core.pdom.ASTFilePathResolver; @@ -22,106 +21,79 @@ import org.eclipse.cdt.internal.core.pdom.YieldableIndexLock; import org.eclipse.core.runtime.CoreException; public class WritableCIndex extends CIndex implements IWritableIndex { - final private IWritableIndexFragment fWritableFragment; private boolean fIsWriteLocked= false; private Object fThread; - public WritableCIndex(IWritableIndexFragment writable, IIndexFragment[] readonly) { - super(concat(writable, readonly)); - fWritableFragment= writable; - } - - private static IIndexFragment[] concat(IIndexFragment writable, IIndexFragment[] readonly) { - IIndexFragment[] result= new IIndexFragment[1 + readonly.length]; - result[0]= writable; - System.arraycopy(readonly, 0, result, 1, readonly.length); - return result; + public WritableCIndex(IWritableIndexFragment writable) { + super(new IWritableIndexFragment[] {writable}); } @Override public IWritableIndexFragment getWritableFragment() { - return fWritableFragment; + return (IWritableIndexFragment) getFragments()[0]; } @Override public IIndexFragmentFile getWritableFile(int linkageID, IIndexFileLocation location, ISignificantMacros macroDictionary) throws CoreException { - return fWritableFragment.getFile(linkageID, location, macroDictionary); + return (IIndexFragmentFile) super.getFile(linkageID, location, macroDictionary); } @Override public IIndexFragmentFile[] getWritableFiles(int linkageID, IIndexFileLocation location) throws CoreException { - return fWritableFragment.getFiles(linkageID, location); + return getWritableFragment().getFiles(linkageID, location); } @Override public IIndexFragmentFile[] getWritableFiles(IIndexFileLocation location) throws CoreException { - return fWritableFragment.getFiles(location); + return getWritableFragment().getFiles(location); } @Override public IIndexFragmentFile addFile(int linkageID, IIndexFileLocation location, ISignificantMacros macroDictionary) throws CoreException { - return fWritableFragment.addFile(linkageID, location, macroDictionary); + return getWritableFragment().addFile(linkageID, location, macroDictionary); } @Override public IIndexFragmentFile addUncommittedFile(int linkageID, IIndexFileLocation location, ISignificantMacros macroDictionary) throws CoreException { - return fWritableFragment.addUncommittedFile(linkageID, location, macroDictionary); + return getWritableFragment().addUncommittedFile(linkageID, location, macroDictionary); } @Override public IIndexFragmentFile commitUncommittedFile() throws CoreException { - return fWritableFragment.commitUncommittedFile(); + return getWritableFragment().commitUncommittedFile(); } @Override public void clearUncommittedFile() throws CoreException { - fWritableFragment.clearUncommittedFile(); - } - - private boolean isWritableFragment(IIndexFragment frag) { - return frag == fWritableFragment; + getWritableFragment().clearUncommittedFile(); } @Override public void setFileContent(IIndexFragmentFile file, int linkageID, IncludeInformation[] includes, IASTPreprocessorStatement[] macros, IASTName[][] names, ASTFilePathResolver resolver, YieldableIndexLock lock) throws CoreException, InterruptedException { - IIndexFragment indexFragment = file.getIndexFragment(); - if (!isWritableFragment(indexFragment)) { - assert false : "Attempt to update file of read-only fragment"; //$NON-NLS-1$ - } else { - for (IncludeInformation include : includes) { - if (include.fLocation != null) { - include.fTargetFile= addFile(linkageID, include.fLocation, - include.fSignificantMacros); - } + assert getWritableFragment() == file.getIndexFragment(); + + for (IncludeInformation include : includes) { + if (include.fLocation != null) { + include.fTargetFile= addFile(linkageID, include.fLocation, + include.fSignificantMacros); } - ((IWritableIndexFragment) indexFragment).addFileContent(file, includes, macros, names, resolver, lock); } + getWritableFragment().addFileContent(file, includes, macros, names, resolver, lock); } @Override public void clear() throws CoreException { - fWritableFragment.clear(); + getWritableFragment().clear(); } - @Override - public boolean isWritableFile(IIndexFile file) { - return file instanceof IIndexFragmentFile && - isWritableFragment(((IIndexFragmentFile)file).getIndexFragment()); - } - @Override public void clearFile(IIndexFragmentFile file) throws CoreException { - IIndexFragment indexFragment = file.getIndexFragment(); - if (!isWritableFragment(indexFragment)) { - assert false : "Attempt to clear file of read-only fragment"; //$NON-NLS-1$ - } else { - ((IWritableIndexFragment) indexFragment).clearFile(file); - } + getWritableFragment().clearFile(file); } @Override @@ -145,7 +117,7 @@ public class WritableCIndex extends CIndex implements IWritableIndex { checkThread(); assert !fIsWriteLocked: "Multiple write locks is not allowed"; //$NON-NLS-1$ - fWritableFragment.acquireWriteLock(getReadLockCount()); + getWritableFragment().acquireWriteLock(getReadLockCount()); fIsWriteLocked= true; } @@ -167,7 +139,7 @@ public class WritableCIndex extends CIndex implements IWritableIndex { } fIsWriteLocked= false; - fWritableFragment.releaseWriteLock(establishReadlockCount, flush); + getWritableFragment().releaseWriteLock(establishReadlockCount, flush); if (establishReadlockCount == 0) { fThread= null; @@ -191,17 +163,17 @@ public class WritableCIndex extends CIndex implements IWritableIndex { @Override public void flush() throws CoreException { assert !fIsWriteLocked; - fWritableFragment.flush(); + getWritableFragment().flush(); } @Override public long getDatabaseSizeBytes() { - return fWritableFragment.getDatabaseSizeBytes(); + return getWritableFragment().getDatabaseSizeBytes(); } @Override public void transferIncluders(IIndexFragmentFile source, IIndexFragmentFile target) throws CoreException { - if (source == null || target == null || !isWritableFile(source) || !isWritableFile(target)) + if (source == null || target == null) throw new IllegalArgumentException(); if (source.equals(target)) return; @@ -210,7 +182,7 @@ public class WritableCIndex extends CIndex implements IWritableIndex { @Override public void transferContext(IIndexFragmentFile source, IIndexFragmentFile target) throws CoreException { - if (source == null || target == null || !isWritableFile(source) || !isWritableFile(target)) + if (source == null || target == null) throw new IllegalArgumentException(); if (source.equals(target)) return; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/IndexProviderManager.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/IndexProviderManager.java index a9b09520c36..c073bc00782 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/IndexProviderManager.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/IndexProviderManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Symbian Software Systems and others. + * Copyright (c) 2007, 2012 Symbian 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 @@ -12,7 +12,15 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.index.provider; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.index.IIndexManager; import org.eclipse.cdt.core.index.provider.IIndexProvider; import org.eclipse.cdt.core.index.provider.IReadOnlyPDOMProvider; import org.eclipse.cdt.core.model.CoreModel; @@ -21,7 +29,6 @@ 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.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.internal.core.index.IIndexFragment; import org.eclipse.cdt.internal.core.pdom.PDOM; @@ -38,13 +45,6 @@ import org.eclipse.osgi.service.resolver.VersionRange; import org.eclipse.osgi.util.NLS; import org.osgi.framework.Version; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - /** * The IndexProviderManager is responsible for maintaining the set of index * fragments contributed via the CIndex extension point. @@ -66,10 +66,21 @@ import java.util.Set; public final class IndexProviderManager implements IElementChangedListener { private static final String ELEMENT_RO_PDOM_PROVIDER= "ReadOnlyPDOMProvider"; //$NON-NLS-1$ private static final String ELEMENT_RO_INDEX_FRAGMENT_PROVIDER= "ReadOnlyIndexFragmentProvider"; //$NON-NLS-1$ - private static final String ATTRIBUTE_CLASS = "class"; //$NON-NLS-1$ + private static final String ELEMENT_PROVIDER_USAGE= "FragmentProviderUsage"; //$NON-NLS-1$ + @SuppressWarnings("nls") + private static final String + ATTRIBUTE_CLASS = "class", + ATTRIBUTE_NAVIGATION = "navigation", + ATTRIBUTE_CONTENT_ASSIST = "content_assist", + ATTRIBUTE_ADD_IMPORT = "add_import", + ATTRIBUTE_CALL_HIERARCHY = "call_hierarchy", + ATTRIBUTE_TYPE_HIERARCHY = "type_hierarchy", + ATTRIBUTE_INCLUDE_BROWSER = "include_browser", + ATTRIBUTE_SEARCH = "search"; - private IIndexFragmentProvider[] pdomFragmentProviders; - private IIndexFragmentProvider[] nonPDOMFragmentProviders; + + private IIndexFragmentProvider[] fragmentProviders; + private int[] fragmentProviderUsage; private Map provisionMap; private Set compatibleFragmentUnavailable; private VersionRange pdomVersionRange; @@ -92,15 +103,15 @@ public final class IndexProviderManager implements IElementChangedListener { * @param pdomVersionRange */ public void reset(VersionRange pdomVersionRange) { - this.pdomFragmentProviders= new IIndexFragmentProvider[0]; + this.fragmentProviders= new IIndexFragmentProvider[0]; this.provisionMap= new HashMap(); this.pdomVersionRange= pdomVersionRange; this.compatibleFragmentUnavailable= new HashSet(); } public void startup() { - List pdomProviders = new ArrayList(); - List nonPDOMProviders = new ArrayList(); + List providers = new ArrayList(); + List usageSpecifications= new ArrayList(); IExtensionRegistry registry = Platform.getExtensionRegistry(); IExtensionPoint indexProviders = registry.getExtensionPoint(CCorePlugin.INDEX_UNIQ_ID); for (IExtension extension : indexProviders.getExtensions()) { @@ -108,9 +119,9 @@ public final class IndexProviderManager implements IElementChangedListener { for (IConfigurationElement element : extension.getConfigurationElements()) { if (ELEMENT_RO_PDOM_PROVIDER.equals(element.getName())) { Object provider = element.createExecutableExtension(ATTRIBUTE_CLASS); - if (provider instanceof IReadOnlyPDOMProvider) { - pdomProviders.add(new ReadOnlyPDOMProviderBridge((IReadOnlyPDOMProvider) provider)); + providers.add(new ReadOnlyPDOMProviderBridge((IReadOnlyPDOMProvider) provider)); + usageSpecifications.add(element.getChildren(ELEMENT_PROVIDER_USAGE)); } else { CCorePlugin.log(NLS.bind(Messages.IndexProviderManager_0, extension.getContributor().getName())); @@ -119,12 +130,13 @@ public final class IndexProviderManager implements IElementChangedListener { Object provider = element.createExecutableExtension(ATTRIBUTE_CLASS); if (provider instanceof IIndexFragmentProvider) { - nonPDOMProviders.add((IIndexFragmentProvider) provider); + providers.add((IIndexFragmentProvider) provider); + usageSpecifications.add(element.getChildren(ELEMENT_PROVIDER_USAGE)); } else { CCorePlugin.log(NLS.bind(Messages.IndexProviderManager_0, extension.getContributor().getName())); } - } + } } } catch (CoreException e) { CCorePlugin.log(e); @@ -132,8 +144,41 @@ public final class IndexProviderManager implements IElementChangedListener { } CoreModel.getDefault().addElementChangedListener(this); - this.pdomFragmentProviders = pdomProviders.toArray(new IIndexFragmentProvider[pdomProviders.size()]); - this.nonPDOMFragmentProviders = nonPDOMProviders.toArray(new IIndexFragmentProvider[nonPDOMProviders.size()]); + this.fragmentProviders = providers.toArray(new IIndexFragmentProvider[providers.size()]); + this.fragmentProviderUsage= computeProviderUsage(usageSpecifications); + assert fragmentProviders.length == fragmentProviderUsage.length; + } + + private int[] computeProviderUsage(List usageFilters) { + int[] usage= new int[usageFilters.size()]; + for (int i = 0; i < usage.length; i++) { + IConfigurationElement[] usageFilter= usageFilters.get(i); + usage[i]= computeProviderUsage(usageFilter); + } + return usage; + } + + private int computeProviderUsage(IConfigurationElement[] usageFilter) { + if (usageFilter == null || usageFilter.length == 0) + return -1; // Allow usage for all tools. + + int result = 0; + IConfigurationElement elem= usageFilter[0]; + result |= getOption(elem, ATTRIBUTE_ADD_IMPORT, IIndexManager.ADD_EXTENSION_FRAGMENTS_ADD_IMPORT); + result |= getOption(elem, ATTRIBUTE_CALL_HIERARCHY, IIndexManager.ADD_EXTENSION_FRAGMENTS_CALL_HIERARCHY); + result |= getOption(elem, ATTRIBUTE_CONTENT_ASSIST, IIndexManager.ADD_EXTENSION_FRAGMENTS_CONTENT_ASSIST); + result |= getOption(elem, ATTRIBUTE_INCLUDE_BROWSER, IIndexManager.ADD_EXTENSION_FRAGMENTS_INCLUDE_BROWSER); + result |= getOption(elem, ATTRIBUTE_NAVIGATION, IIndexManager.ADD_EXTENSION_FRAGMENTS_NAVIGATION); + result |= getOption(elem, ATTRIBUTE_SEARCH, IIndexManager.ADD_EXTENSION_FRAGMENTS_SEARCH); + result |= getOption(elem, ATTRIBUTE_TYPE_HIERARCHY, IIndexManager.ADD_EXTENSION_FRAGMENTS_TYPE_HIERARCHY); + + return result; + } + + public int getOption(IConfigurationElement elem, String attributeName, int option) { + if ("true".equals(elem.getAttribute(attributeName))) //$NON-NLS-1$ + return option; + return 0; } /** @@ -144,16 +189,13 @@ public final class IndexProviderManager implements IElementChangedListener { * @param config * @return the array of IIndexFragment objects for the current state */ - public IIndexFragment[] getProvidedIndexFragments(ICConfigurationDescription config, - boolean includeNonPDOMFragments) throws CoreException { + public IIndexFragment[] getProvidedIndexFragments(ICConfigurationDescription config, int usage) throws CoreException { Map id2fragment = new HashMap(); IProject project= config.getProjectDescription().getProject(); - IIndexFragmentProvider[][] groups = includeNonPDOMFragments ? - new IIndexFragmentProvider[][] { pdomFragmentProviders, nonPDOMFragmentProviders } : - new IIndexFragmentProvider[][] { pdomFragmentProviders }; - for (IIndexFragmentProvider[] group : groups) { - for (IIndexFragmentProvider provider : group) { + for (int i = 0; i < fragmentProviders.length; i++) { + if ((fragmentProviderUsage[i] & usage) != 0) { + IIndexFragmentProvider provider= fragmentProviders[i]; try { if (providesForProject(provider, project)) { IIndexFragment[] fragments= provider.getIndexFragments(config); @@ -180,7 +222,8 @@ public final class IndexProviderManager implements IElementChangedListener { String key= entry.getKey(); if (!compatibleFragmentUnavailable.contains(key)) { String msg= NLS.bind( - Messages.IndexProviderManager_NoCompatibleFragmentsAvailable, key); + Messages.IndexProviderManager_NoCompatibleFragmentsAvailable, key, + collectVersions(config, project, usage, key)); CCorePlugin.log(new Status(IStatus.WARNING, CCorePlugin.PLUGIN_ID, msg)); compatibleFragmentUnavailable.add(key); } @@ -191,6 +234,45 @@ public final class IndexProviderManager implements IElementChangedListener { return preresult.toArray(new IIndexFragment[preresult.size()]); } + /** + * Used for logging a problem. + */ + private String collectVersions(ICConfigurationDescription config, IProject project, int usage, String fragid) { + StringBuilder result= new StringBuilder(); + for (int i = 0; i < fragmentProviders.length; i++) { + if ((fragmentProviderUsage[i] & usage) != 0) { + IIndexFragmentProvider provider= fragmentProviders[i]; + try { + if (providesForProject(provider, project)) { + IIndexFragment[] fragments= provider.getIndexFragments(config); + for (IIndexFragment fragment : fragments) { + try { + fragment.acquireReadLock(); + try { + if (fragid.equals(fragment.getProperty(IIndexFragment.PROPERTY_FRAGMENT_ID))){ + String csver = fragment.getProperty(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_VERSION); + if (csver != null) { + if (result.length() > 0) + result.append(", "); //$NON-NLS-1$ + result.append(csver); + } + } + } finally { + fragment.releaseReadLock(); + } + } catch (Exception e) { + // No logging, we are generating a msg for the log. + } + } + } + } catch (CoreException e) { + // No logging, we are generating a msg for the log. + } + } + } + return result.toString(); + } + /** * Returns the version range supported by the format identified by the specified formatID. * @param formatID @@ -276,10 +358,17 @@ public final class IndexProviderManager implements IElementChangedListener { return; } - IIndexFragmentProvider[] newAllProviders = new IIndexFragmentProvider[pdomFragmentProviders.length + 1]; - System.arraycopy(pdomFragmentProviders, 0, newAllProviders, 0, pdomFragmentProviders.length); - newAllProviders[pdomFragmentProviders.length] = (IIndexFragmentProvider) provider; - pdomFragmentProviders = newAllProviders; + final int length = fragmentProviders.length; + + IIndexFragmentProvider[] newProviders = new IIndexFragmentProvider[length + 1]; + System.arraycopy(fragmentProviders, 0, newProviders, 0, length); + newProviders[length] = (IIndexFragmentProvider) provider; + fragmentProviders = newProviders; + + int[] newFilters = new int[length + 1]; + System.arraycopy(fragmentProviderUsage, 0, newFilters, 0, length); + newFilters[length] = -1; + fragmentProviderUsage = newFilters; } /** @@ -290,11 +379,20 @@ public final class IndexProviderManager implements IElementChangedListener { * @param provider */ public void removeIndexProvider(IIndexProvider provider) { - ArrayUtil.remove(pdomFragmentProviders, provider); - if (pdomFragmentProviders[pdomFragmentProviders.length - 1] == null) { - IIndexFragmentProvider[] newAllProviders = new IIndexFragmentProvider[pdomFragmentProviders.length - 1]; - System.arraycopy(pdomFragmentProviders, 0, newAllProviders, 0, pdomFragmentProviders.length - 1); - pdomFragmentProviders= newAllProviders; + for (int i = 0; i < fragmentProviders.length; i++) { + if (fragmentProviders[i] == provider) { + final int length = fragmentProviders.length; + IIndexFragmentProvider[] newProviders = new IIndexFragmentProvider[length - 1]; + System.arraycopy(fragmentProviders, 0, newProviders, 0, i); + System.arraycopy(fragmentProviders, i+1, newProviders, i, length-i-1); + fragmentProviders = newProviders; + + int[] newFilters = new int[length - 1]; + System.arraycopy(fragmentProviderUsage, 0, newFilters, 0, i); + System.arraycopy(fragmentProviderUsage, i+1, newFilters, i, length-i-1); + fragmentProviderUsage = newFilters; + return; + } } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/messages.properties b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/messages.properties index a8140b7dc0e..c294f9f55a5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/messages.properties +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/messages.properties @@ -9,4 +9,4 @@ # Symbian Software Limited - initial API and implementation ############################################################################### IndexProviderManager_0=Ignoring unrecognized implementation of IIndexProvider contributed by {0} -IndexProviderManager_NoCompatibleFragmentsAvailable=No compatible index fragment found for fragment id: {0} +IndexProviderManager_NoCompatibleFragmentsAvailable=No compatible index fragment found for fragment id: {0}, found versions {1}. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneFastIndexer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneFastIndexer.java index 67cd9374a3f..8a205df546c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneFastIndexer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneFastIndexer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2010 QNX Software Systems and others. + * Copyright (c) 2006, 2012 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 @@ -20,7 +20,6 @@ import java.util.Map; import org.eclipse.cdt.core.index.IIndexLocationConverter; import org.eclipse.cdt.core.parser.IParserLogService; import org.eclipse.cdt.core.parser.IScannerInfo; -import org.eclipse.cdt.internal.core.index.IIndexFragment; import org.eclipse.cdt.internal.core.index.WritableCIndex; import org.eclipse.cdt.internal.core.pdom.WritablePDOM; import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory; @@ -55,7 +54,7 @@ public class StandaloneFastIndexer extends StandaloneIndexer { @Deprecated public StandaloneFastIndexer(File writableIndexFile, IIndexLocationConverter converter, Map linkageFactoryMappings, IScannerInfo scanner, FileEncodingRegistry fileEncodingRegistry, ILanguageMapper mapper, IParserLogService log) throws CoreException { - super(new WritableCIndex(new WritablePDOM(writableIndexFile, converter, linkageFactoryMappings),new IIndexFragment[0]), + super(new WritableCIndex(new WritablePDOM(writableIndexFile, converter, linkageFactoryMappings)), false, mapper, log, scanner, fileEncodingRegistry); } @@ -72,7 +71,7 @@ public class StandaloneFastIndexer extends StandaloneIndexer { */ public StandaloneFastIndexer(File writableIndexFile, IIndexLocationConverter converter, Map linkageFactoryMappings, IStandaloneScannerInfoProvider scannerProvider, FileEncodingRegistry fileEncodingRegistry, ILanguageMapper mapper, IParserLogService log) throws CoreException { - super(new WritableCIndex(new WritablePDOM(writableIndexFile, converter, linkageFactoryMappings),new IIndexFragment[0]), + super(new WritableCIndex(new WritablePDOM(writableIndexFile, converter, linkageFactoryMappings)), false, mapper, log, scannerProvider, fileEncodingRegistry); } @@ -88,7 +87,7 @@ public class StandaloneFastIndexer extends StandaloneIndexer { */ public StandaloneFastIndexer(File writableIndexFile, IIndexLocationConverter converter, Map linkageFactoryMappings, FileEncodingRegistry fileEncodingRegistry, ILanguageMapper mapper, IParserLogService log) throws CoreException { - super(new WritableCIndex(new WritablePDOM(writableIndexFile, converter, linkageFactoryMappings),new IIndexFragment[0]), + super(new WritableCIndex(new WritablePDOM(writableIndexFile, converter, linkageFactoryMappings)), false, mapper, log, (IStandaloneScannerInfoProvider)null, fileEncodingRegistry); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneFullIndexer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneFullIndexer.java index 4199f024620..5a6f8fec1b8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneFullIndexer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneFullIndexer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2010 QNX Software Systems and others. + * Copyright (c) 2006, 2012 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 @@ -21,7 +21,6 @@ import org.eclipse.cdt.core.index.IIndexLocationConverter; import org.eclipse.cdt.core.parser.IParserLogService; import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.internal.core.dom.AbstractCodeReaderFactory; -import org.eclipse.cdt.internal.core.index.IIndexFragment; import org.eclipse.cdt.internal.core.index.WritableCIndex; import org.eclipse.cdt.internal.core.pdom.WritablePDOM; import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory; @@ -61,7 +60,7 @@ public class StandaloneFullIndexer extends StandaloneIndexer{ @Deprecated public StandaloneFullIndexer(File writableIndexFile, IIndexLocationConverter converter, Map linkageFactoryMappings, IScannerInfo scanner, FileEncodingRegistry fileEncodingRegistry, ILanguageMapper mapper, IParserLogService log, AbstractCodeReaderFactory codeReaderFactory) throws CoreException { - super(new WritableCIndex(new WritablePDOM(writableIndexFile, converter, linkageFactoryMappings),new IIndexFragment[0]), + super(new WritableCIndex(new WritablePDOM(writableIndexFile, converter, linkageFactoryMappings)), false, mapper, log, scanner, fileEncodingRegistry); fCodeReaderFactory = codeReaderFactory; } @@ -80,7 +79,7 @@ public class StandaloneFullIndexer extends StandaloneIndexer{ */ public StandaloneFullIndexer(File writableIndexFile, IIndexLocationConverter converter, Map linkageFactoryMappings, IStandaloneScannerInfoProvider scannerProvider, FileEncodingRegistry fileEncodingRegistry, ILanguageMapper mapper, IParserLogService log, AbstractCodeReaderFactory codeReaderFactory) throws CoreException { - super(new WritableCIndex(new WritablePDOM(writableIndexFile, converter, linkageFactoryMappings),new IIndexFragment[0]), + super(new WritableCIndex(new WritablePDOM(writableIndexFile, converter, linkageFactoryMappings)), false, mapper, log, scannerProvider, fileEncodingRegistry); fCodeReaderFactory = codeReaderFactory; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java index 2f68dfe2484..d99c50908ee 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2012 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 @@ -287,7 +287,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter { private boolean fIndexFilesWithoutConfiguration= true; private List fRequestsPerLinkage= new ArrayList(); private Map fIndexContentCache= new LRUCache(500); - private Map fIndexFilesCache= new LRUCache(5000); + private Map fIndexFilesCache= new LRUCache(5000); private Map fOneLinkageTasks= new HashMap(); private Object[] fFilesToUpdate; @@ -951,8 +951,8 @@ public abstract class AbstractIndexerTask extends PDOMWriter { return ctxFile; IIndexFragmentFile nextCtx= (IIndexFragmentFile) ctxInclude.getIncludedBy(); - if (!fIndex.isWritableFile(nextCtx)) - return ctxFile; + if (nextCtx == null) + return nextCtx; // Found a recursion if (!safeGuard.add(nextCtx)) @@ -1148,13 +1148,11 @@ public abstract class AbstractIndexerTask extends PDOMWriter { collectOrderedFileKeys(linkageID, inclusion, enteredFiles, orderedFileKeys); } - IIndexFile newFile= selectIndexFile(linkageID, topIfl, ast.getSignificantMacros()); + IIndexFragmentFile newFile= selectIndexFile(linkageID, topIfl, ast.getSignificantMacros()); if (ctx != null) { orderedFileKeys.add(new FileInAST(null, topKey, fileContentsHash)); - if (newFile != null && fIndex.isWritableFile(newFile)) { - // File can be reused - ctx.fNewFile= (IIndexFragmentFile) newFile; - } + // File can be reused + ctx.fNewFile= newFile; } else if (newFile == null) { orderedFileKeys.add(new FileInAST(null, topKey, fileContentsHash)); } @@ -1233,7 +1231,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter { return fc; } - IIndexFile selectIndexFile(int linkageID, IIndexFileLocation ifl, ISignificantMacros sigMacros) throws CoreException { + IIndexFragmentFile selectIndexFile(int linkageID, IIndexFileLocation ifl, ISignificantMacros sigMacros) throws CoreException { LinkageTask map = findRequestMap(linkageID); if (map != null) { LocationTask locTask= map.find(ifl); @@ -1245,8 +1243,8 @@ public abstract class AbstractIndexerTask extends PDOMWriter { } } - IIndexFile[] files = getAvailableIndexFiles(linkageID, ifl); - for (IIndexFile file : files) { + IIndexFragmentFile[] files = getAvailableIndexFiles(linkageID, ifl); + for (IIndexFragmentFile file : files) { if (sigMacros.equals(file.getSignificantMacros())) return file; } @@ -1278,30 +1276,25 @@ public abstract class AbstractIndexerTask extends PDOMWriter { return null; } - public IIndexFile[] getAvailableIndexFiles(int linkageID, IIndexFileLocation ifl) + public IIndexFragmentFile[] getAvailableIndexFiles(int linkageID, IIndexFileLocation ifl) throws CoreException { - IIndexFile[] files= fIndexFilesCache.get(ifl); + IIndexFragmentFile[] files= fIndexFilesCache.get(ifl); if (files == null) { - if (fResolver.canBePartOfSDK(ifl)) { - // Check for a version in potentially another pdom. - files= fIndex.getFiles(linkageID, ifl); - } else { - IIndexFragmentFile[] fragFiles = fIndex.getWritableFiles(linkageID, ifl); - int j= 0; - for (int i = 0; i < fragFiles.length; i++) { - if (fragFiles[i].hasContent()) { - if (j != i) - fragFiles[j]= fragFiles[i]; - j++; - } + IIndexFragmentFile[] fragFiles = fIndex.getWritableFiles(linkageID, ifl); + int j= 0; + for (int i = 0; i < fragFiles.length; i++) { + if (fragFiles[i].hasContent()) { + if (j != i) + fragFiles[j]= fragFiles[i]; + j++; } - if (j == fragFiles.length) { - files= fragFiles; - } else { - files= new IIndexFile[j]; - System.arraycopy(fragFiles, 0, files, 0, j); - } } + if (j == fragFiles.length) { + files= fragFiles; + } else { + files= new IIndexFragmentFile[j]; + System.arraycopy(fragFiles, 0, files, 0, j); + } fIndexFilesCache.put(ifl, files); } return files; 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 86efbcc310a..40f4c30e0dc 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2011 QNX Software Systems and others. + * Copyright (c) 2005, 2012 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 @@ -22,7 +22,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.nio.channels.FileChannel; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -672,45 +671,20 @@ public class PDOMManager implements IWritableIndexManager, IListener { } public void enqueue(IPDOMIndexerTask subjob) { - final HashSet referencing= new HashSet(); - final IPDOMIndexer indexer = subjob.getIndexer(); - if (indexer != null) { - getReferencingProjects(indexer.getProject().getProject(), referencing); - } synchronized (fTaskQueue) { if (fCurrentTask != null && fCurrentTask.acceptUrgentTask(subjob)) { return; } - int i= 0; for (IPDOMIndexerTask task : fTaskQueue) { if (task.acceptUrgentTask(subjob)) { return; } - final IPDOMIndexer ti = task.getIndexer(); - if (ti != null && referencing.contains(ti.getProject().getProject())) { - fTaskQueue.add(i, subjob); - break; - } - i++; } - if (i == fTaskQueue.size()) { - fTaskQueue.addLast(subjob); - } + fTaskQueue.addLast(subjob); fIndexerJob.schedule(); } } - private void getReferencingProjects(IProject prj, HashSet result) { - LinkedList projectsToSearch= new LinkedList(); - projectsToSearch.add(prj); - while (!projectsToSearch.isEmpty()) { - prj= projectsToSearch.removeFirst(); - if (result.add(prj)) { - projectsToSearch.addAll(Arrays.asList(prj.getReferencingProjects())); - } - } - } - IPDOMIndexerTask getNextTask() { IPDOMIndexerTask result= null; synchronized (fTaskQueue) { diff --git a/core/org.eclipse.cdt.core/schema/CIndex.exsd b/core/org.eclipse.cdt.core/schema/CIndex.exsd index f35783e15cd..137314485d9 100644 --- a/core/org.eclipse.cdt.core/schema/CIndex.exsd +++ b/core/org.eclipse.cdt.core/schema/CIndex.exsd @@ -1,250 +1,315 @@ - - - - - - - - - This extension point groups extensions to the index functionality in CDT - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <h2>ExportProjectProvider</h2> -<p> -This subelement of CIndex allows contribution of alternate IExportProjectProvider implementations. These can then be referenced by fully qualified class name in the command line tool (see option -pprovider). -<p> -<b>Invoking the application as a headless application</b> - -This example ant file shows how to invoke the tool headlessly, the same approach would work from a shell or batch file. - -<pre> -<project name="Generate PDOM" default="generate"> - <target name="generate"> - <!-- This script shows how to invoke the default project provider (ExternalExportProjectProvider) --> - <property name="pprovider" value="org.eclipse.cdt.core.index.export.ExternalExportProjectProvider"/> - <property name="target" value="C:\ExportedPDOMs\acmeSDK_2_5.pdom"/> <!-- Where the output pdom is to go --> - <property name="source" value="E:\AcmeSDK\v2.5\inc"/> <!-- e.g. the directory to source content from --> - <property name="id" value="com.acme.mysdk.v2.5"/> <!-- the id to store in the generate pdom --> - - <property name="eclipse.home" value="C:\eclipse"/> <!-- e.g. The eclipse installation to use. This installation must contain CDT 4.0+ plugins --> - - <java classname="org.eclipse.equinox.launcher.Main"> - <classpath> - <fileset dir="${eclipse.home}/plugins"> - <include name="*equinox.launcher*.jar"/> - </fileset> - </classpath> - <arg value="-nosplash"/> - <arg value="-exitdata"/> - <arg value="-application"/><arg value="org.eclipse.cdt.core.GeneratePDOM"/> - <arg value="-pprovider"/><arg value="${pprovider}"/> - <arg value="-source"/><arg value="${source}"/> - <arg value="-target"/><arg value="${target}"/> - <arg value="-id"/><arg value="${id}"/> - </java> - </target> -</project> -</pre> -<p> -<b>Invoking the tool via an Eclipse Launch Configuration</b> -<p> -Specify "org.eclipse.cdt.core.GeneratePDOM" as the application to launch -<p> -In the Argument tabs provide (for example) - -target C:\ExportedPDOMs\acmeSDK_2_5.pdom -source E:\AcmeSDK\v2.5\inc -include E:\this.h -id com.acme.mysdk.v2.5 -<p> - - - - - - - the fully qualified name of the IExportProjectProvider implementation to register - - - - - - - - - - - - - <h2>ReadOnlyPDOMProvider</h2> -<p> -This subelement of CIndex allows ISVs to contribute read-only prebuilt PDOM files to the CDT Index. The only information needed is the fully qualified class name of an implementatin of org.eclipse.cdt.core.index.IOfflinePDOMProvider. This implementation will be consulted during the eclipse session for the appropriate read-only content to make add to the logical index. The logical index is accessible via the org.eclipse.core.index.IIndex API. - - An example of contributing a prebuilt read-only pdom: -<pre> -<CIndex> - <ReadOnlyPDOMProvider class="com.acme.ide.index.AcmeSDKProvider"/> -</CIndex> -</pre> - -and the corresponding implementation - -<pre> -package com.acme.ide.index.sdk; - -import org.eclipse.core.index.provider.IReadOnlyPDOMProvider; -import org.eclipse.core.index.provider.IPDOMDescriptor; -import org.eclipse.core.index.IIndexLocationConverter; -import org.eclipse.core.index.URIRelativeLocationConverter; - -public class AcmeSDKProvider implements IReadOnlyPDOMProvider { - public boolean providesFor(ICProject project) { - // e.g. decide by looking for acme project nature - return AcmeNature.isAcmeProject(project); - } - - public IPDOMDescriptor[] getDescriptors(ICConfigurationDescription config) { - final IPath sdkBase = AcmeSDKAPI.getSDKBase(config); - return new IPDOMDescriptor[] { new IPDOMDescriptor() { - public IIndexLocationConverter getIndexLocationConverter() { - return new URIRelativeLocationConverter(URIUtil.toURI(sdkBase)); - } - public IPath getLocation() { - IPath path = sdkBase.append(AcmeSDKAPI.getPrebuiltPDOMFilename(config)); - return path; - } - }}; - } -} -</pre> - - - - - - - The fully qualified name of the IReadOnlyPDOMProvider implementation to register - - - - - - - - - - - - - <h2>ReadOnlyIndexFragmentProvider</h2> -<p> -This subelement of CIndex allows ISVs to contribute read-only index fragments to the CDT Index. This extension point imposes no limitations on how the index information is collected and stored. The index fragments may, for example, be based on data dynamically fetched from a remote server. -<p> -The only information needed for this extension point is the fully qualified name of a class implementing the org.eclipse.cdt.core.index.IIndexFragmentProvider interface. This class will be consulted during the eclipse session for the appropriate read-only content to add to the logical index. The logical index is accessible via the org.eclipse.core.index.IIndex API. - - - - - - - The fully qualified name of a class implementing IIndexFragmentProvider interface. - - - - - - - - - - - - - - - Index content provided by ISVs under this extension point will be accessible via the logical index org.eclipse.core.index.IIndex API - -For export functionality, see package org.eclipse.cdt.core.index.export - - - - - - - - - 4.0 - - - - - - - - - See subelement documentation - - - - - - - - - See subelement documentation - - - - - - - - - Copyright (c) 2007, 2011 Symbian 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 - - - - + + + + + + + + + This extension point groups extensions to the index functionality in CDT + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <h2>ExportProjectProvider</h2> +<p> +This subelement of CIndex allows contribution of alternate IExportProjectProvider implementations. These can then be referenced by fully qualified class name in the command line tool (see option -pprovider). +<p> +<b>Invoking the application as a headless application</b> + +This example ant file shows how to invoke the tool headlessly, the same approach would work from a shell or batch file. + +<pre> +<project name="Generate PDOM" default="generate"> + <target name="generate"> + <!-- This script shows how to invoke the default project provider (ExternalExportProjectProvider) --> + <property name="pprovider" value="org.eclipse.cdt.core.index.export.ExternalExportProjectProvider"/> + <property name="target" value="C:\ExportedPDOMs\acmeSDK_2_5.pdom"/> <!-- Where the output pdom is to go --> + <property name="source" value="E:\AcmeSDK\v2.5\inc"/> <!-- e.g. the directory to source content from --> + <property name="id" value="com.acme.mysdk.v2.5"/> <!-- the id to store in the generate pdom --> + + <property name="eclipse.home" value="C:\eclipse"/> <!-- e.g. The eclipse installation to use. This installation must contain CDT 4.0+ plugins --> + + <java classname="org.eclipse.equinox.launcher.Main"> + <classpath> + <fileset dir="${eclipse.home}/plugins"> + <include name="*equinox.launcher*.jar"/> + </fileset> + </classpath> + <arg value="-nosplash"/> + <arg value="-exitdata"/> + <arg value="-application"/><arg value="org.eclipse.cdt.core.GeneratePDOM"/> + <arg value="-pprovider"/><arg value="${pprovider}"/> + <arg value="-source"/><arg value="${source}"/> + <arg value="-target"/><arg value="${target}"/> + <arg value="-id"/><arg value="${id}"/> + </java> + </target> +</project> +</pre> +<p> +<b>Invoking the tool via an Eclipse Launch Configuration</b> +<p> +Specify "org.eclipse.cdt.core.GeneratePDOM" as the application to launch +<p> +In the Argument tabs provide (for example) + -target C:\ExportedPDOMs\acmeSDK_2_5.pdom -source E:\AcmeSDK\v2.5\inc -include E:\this.h -id com.acme.mysdk.v2.5 +<p> + + + + + + + the fully qualified name of the IExportProjectProvider implementation to register + + + + + + + + + + + + + <h2>ReadOnlyPDOMProvider</h2> +<p> +This subelement of CIndex allows ISVs to contribute read-only prebuilt PDOM files to the CDT Index. The only information needed is the fully qualified class name of an implementatin of org.eclipse.cdt.core.index.IOfflinePDOMProvider. This implementation will be consulted during the eclipse session for the appropriate read-only content to make add to the logical index. The logical index is accessible via the org.eclipse.core.index.IIndex API. + + An example of contributing a prebuilt read-only pdom: +<pre> +<CIndex> + <ReadOnlyPDOMProvider class="com.acme.ide.index.AcmeSDKProvider"/> +</CIndex> +</pre> + +and the corresponding implementation + +<pre> +package com.acme.ide.index.sdk; + +import org.eclipse.core.index.provider.IReadOnlyPDOMProvider; +import org.eclipse.core.index.provider.IPDOMDescriptor; +import org.eclipse.core.index.IIndexLocationConverter; +import org.eclipse.core.index.URIRelativeLocationConverter; + +public class AcmeSDKProvider implements IReadOnlyPDOMProvider { + public boolean providesFor(ICProject project) { + // e.g. decide by looking for acme project nature + return AcmeNature.isAcmeProject(project); + } + + public IPDOMDescriptor[] getDescriptors(ICConfigurationDescription config) { + final IPath sdkBase = AcmeSDKAPI.getSDKBase(config); + return new IPDOMDescriptor[] { new IPDOMDescriptor() { + public IIndexLocationConverter getIndexLocationConverter() { + return new URIRelativeLocationConverter(URIUtil.toURI(sdkBase)); + } + public IPath getLocation() { + IPath path = sdkBase.append(AcmeSDKAPI.getPrebuiltPDOMFilename(config)); + return path; + } + }}; + } +} +</pre> + + + + + + + + + + The fully qualified name of the IReadOnlyPDOMProvider implementation to register + + + + + + + + + + + + + <h2>ReadOnlyIndexFragmentProvider</h2> +<p> +This subelement of CIndex allows ISVs to contribute read-only index fragments to the CDT Index. This extension point imposes no limitations on how the index information is collected and stored. The index fragments may, for example, be based on data dynamically fetched from a remote server. +<p> +The only information needed for this extension point is the fully qualified name of a class implementing the org.eclipse.cdt.core.index.IIndexFragmentProvider interface. This class will be consulted during the eclipse session for the appropriate read-only content to add to the logical index. The logical index is accessible via the org.eclipse.core.index.IIndex API. + + + + + + + + + + The fully qualified name of a class implementing IIndexFragmentProvider interface. + + + + + + + + + + + + + Defines for which tools the fragment provider shall be used. + + + + + + + Whether the fragment provider shall be used for performing 'Open Declaration' and 'Open Element'. + + + + + + + Whether the fragment provider shall be used for performing content-assist. + + + + + + + Whether the fragment provider shall be used for performing 'Add Import'. + + + + + + + Whether the fragment provider shall be used for populating the call hierarchy. + + + + + + + Whether the fragment provider shall be used for populating the type hierarchy. + + + + + + + Whether the fragment provider shall be used for populating the include browser. + + + + + + + Whether the fragment provider shall be used for C/C++ searches. + + + + + + + + + + + + Index content provided by ISVs under this extension point will be accessible via the logical index org.eclipse.core.index.IIndex API + +For export functionality, see package org.eclipse.cdt.core.index.export + + + + + + + + + 4.0 + + + + + + + + + See subelement documentation + + + + + + + + + See subelement documentation + + + + + + + + + Copyright (c) 2007, 2011 Symbian 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 + + + + diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AbstractSemanticHighlightingTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AbstractSemanticHighlightingTest.java index 051d96e76e5..eb0cee5e43e 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AbstractSemanticHighlightingTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AbstractSemanticHighlightingTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2012 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 @@ -12,16 +12,13 @@ package org.eclipse.cdt.ui.tests.text; import java.io.File; -import java.net.URI; +import java.io.FileOutputStream; import junit.extensions.TestSetup; import junit.framework.Test; import junit.framework.TestCase; import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.text.BadLocationException; @@ -30,27 +27,16 @@ import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.Position; import org.eclipse.jface.text.source.SourceViewer; -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.dom.IPDOMManager; -import org.eclipse.cdt.core.index.IIndexLocationConverter; -import org.eclipse.cdt.core.index.ResourceContainerRelativeLocationConverter; -import org.eclipse.cdt.core.index.URIRelativeLocationConverter; -import org.eclipse.cdt.core.index.provider.IPDOMDescriptor; -import org.eclipse.cdt.core.index.provider.IReadOnlyPDOMProvider; import org.eclipse.cdt.core.model.ICProject; -import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.testplugin.CProjectHelper; -import org.eclipse.cdt.core.testplugin.util.TestSourceReader; +import org.eclipse.cdt.core.testplugin.TestScannerProvider; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.cdt.ui.testplugin.Accessor; import org.eclipse.cdt.ui.testplugin.EditorTestHelper; import org.eclipse.cdt.ui.testplugin.ResourceTestHelper; -import org.eclipse.cdt.internal.core.CCoreInternals; -import org.eclipse.cdt.internal.core.index.provider.IndexProviderManager; -import org.eclipse.cdt.internal.core.index.provider.ReadOnlyPDOMProviderBridge; - import org.eclipse.cdt.internal.ui.editor.CEditor; import org.eclipse.cdt.internal.ui.editor.SemanticHighlighting; import org.eclipse.cdt.internal.ui.editor.SemanticHighlightingManager; @@ -68,7 +54,7 @@ public class AbstractSemanticHighlightingTest extends TestCase { private ICProject fCProject; private final String fTestFilename; - private File fSdkFile; + private File fExternalFile; public SemanticHighlightingTestSetup(Test test, String testFilename) { super(test); @@ -83,65 +69,25 @@ public class AbstractSemanticHighlightingTest extends TestCase { "void SDKFunction();\n"+ "class SDKClass { public: void SDKMethod(); };\n\n"; - fSdkFile= createExternalSDK(sdkCode); - assertNotNull(fSdkFile); - fSdkFile.deleteOnExit(); - - fCProject= EditorTestHelper.createCProject(PROJECT, LINKED_FOLDER); - - importExternalSDK(fSdkFile, fCProject); + fExternalFile= createExternalFile(sdkCode); + assertNotNull(fExternalFile); + // Load the file using option -include to make it part of the index. + TestScannerProvider.sIncludeFiles= new String[] {fExternalFile.getAbsolutePath()}; + fCProject= EditorTestHelper.createCProject(PROJECT, LINKED_FOLDER, false, true); + BaseTestCase.waitForIndexer(fCProject); fEditor= (CEditor) EditorTestHelper.openInEditor(ResourceTestHelper.findFile(fTestFilename), true); fSourceViewer= EditorTestHelper.getSourceViewer(fEditor); assertTrue(EditorTestHelper.joinReconciler(fSourceViewer, 500, 10000, 100)); EditorTestHelper.joinBackgroundActivities(); } - private static void importExternalSDK(final File sdk, final ICProject associatedProject) { - final URI baseURI= new File("c:/ExternalSDK/").toURI(); - IndexProviderManager ipm= CCoreInternals.getPDOMManager().getIndexProviderManager(); - ipm.addIndexProvider(new ReadOnlyPDOMProviderBridge( - new IReadOnlyPDOMProvider() { - @Override - public IPDOMDescriptor[] getDescriptors( - ICConfigurationDescription config) { - return new IPDOMDescriptor[] { - new IPDOMDescriptor() { - @Override - public IIndexLocationConverter getIndexLocationConverter() { - return new URIRelativeLocationConverter(baseURI); - } - - @Override - public IPath getLocation() { - return new Path(sdk.getAbsolutePath()); - } - - } - }; - } - @Override - public boolean providesFor(ICProject project) - throws CoreException { - return associatedProject.equals(project); - } - } - )); - } - - private static File createExternalSDK(final String code) throws Exception { - final File sdk= File.createTempFile("foo", "bar"); - - ICProject cproject= CProjectHelper.createCCProject("foo"+System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER); - TestSourceReader.createFile(cproject.getProject(), new Path("/this.h"), code); - CCorePlugin.getIndexManager().joinIndexer(5000, new NullProgressMonitor()); - - ResourceContainerRelativeLocationConverter cvr= new ResourceContainerRelativeLocationConverter(cproject.getProject()); - CCoreInternals.getPDOMManager().exportProjectPDOM(cproject, sdk, cvr); - assertTrue(sdk.exists()); - - CProjectHelper.delete(cproject); - return sdk; + private static File createExternalFile(final String code) throws Exception { + File dest = File.createTempFile("external", ".h"); + FileOutputStream fos = new FileOutputStream(dest); + fos.write(code.getBytes()); + fos.close(); + return dest; } protected String getTestFilename() { @@ -165,9 +111,11 @@ public class AbstractSemanticHighlightingTest extends TestCase { if (fCProject != null) CProjectHelper.delete(fCProject); - if (fSdkFile != null) { - fSdkFile.delete(); + if (fExternalFile != null) { + fExternalFile.delete(); } + + TestScannerProvider.sIncludeFiles= null; super.tearDown(); } } diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java index 3a7a4a4995c..196e17a5b75 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2012 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 @@ -44,6 +44,7 @@ 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.IIndexMacro; +import org.eclipse.cdt.core.index.IIndexManager; import org.eclipse.cdt.core.index.IndexFilter; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICElement; @@ -301,7 +302,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog { } }; try { - IIndex index = CCorePlugin.getIndexManager().getIndex(CoreModel.getDefault().getCModel().getCProjects()); + IIndex index = CCorePlugin.getIndexManager().getIndex(CoreModel.getDefault().getCModel().getCProjects(), IIndexManager.ADD_EXTENSION_FRAGMENTS_NAVIGATION); index.acquireReadLock(); try { IIndexBinding[] bindings= index.findBindingsForPrefix(prefix, false, filter, monitor); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.java index fbe8d3c8488..5d9d6b37cc2 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2011 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2012 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 @@ -112,7 +112,7 @@ public class CHContentProvider extends AsyncTreeContentProvider { } private Object[] asyncComputeRoot(final ICElement input) throws CoreException, InterruptedException { - IIndex index= CCorePlugin.getIndexManager().getIndex(input.getCProject()); + IIndex index= CCorePlugin.getIndexManager().getIndex(input.getCProject(), CallHierarchyUI.INDEX_SEARCH_OPTION); index.acquireReadLock(); try { ICElement element= input; @@ -154,7 +154,7 @@ public class CHContentProvider extends AsyncTreeContentProvider { private Object[] asyncronouslyComputeReferencedBy(CHNode parent) throws CoreException, InterruptedException { ICProject[] scope= CoreModel.getDefault().getCModel().getCProjects(); - IIndex index= CCorePlugin.getIndexManager().getIndex(scope, IIndexManager.ADD_EXTENSION_FRAGMENTS); + IIndex index= CCorePlugin.getIndexManager().getIndex(scope, IIndexManager.ADD_EXTENSION_FRAGMENTS_CALL_HIERARCHY); index.acquireReadLock(); try { return CHQueries.findCalledBy(this, parent, index, NPM); @@ -165,7 +165,7 @@ public class CHContentProvider extends AsyncTreeContentProvider { private Object[] asyncronouslyComputeRefersTo(CHNode parent) throws CoreException, InterruptedException { ICProject[] scope= CoreModel.getDefault().getCModel().getCProjects(); - IIndex index= CCorePlugin.getIndexManager().getIndex(scope, IIndexManager.ADD_EXTENSION_FRAGMENTS); + IIndex index= CCorePlugin.getIndexManager().getIndex(scope, IIndexManager.ADD_EXTENSION_FRAGMENTS_CALL_HIERARCHY); index.acquireReadLock(); try { return CHQueries.findCalls(this, parent, index, NPM); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java index a4789d369b5..abf26e06653 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2011 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2012 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 @@ -60,6 +60,8 @@ import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; import org.eclipse.cdt.internal.ui.viewsupport.IndexUI; public class CallHierarchyUI { + static final int INDEX_SEARCH_OPTION = IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT + | IIndexManager.ADD_EXTENSION_FRAGMENTS_CALL_HIERARCHY; private static final ICElement[] NO_ELEMENTS = {}; private static boolean sIsJUnitTest= false; @@ -187,9 +189,7 @@ public class CallHierarchyUI { private static ICElement[] findDefinitions(ICProject project, IEditorInput editorInput, ITextSelection sel) throws CoreException { try { - IIndex index= CCorePlugin.getIndexManager().getIndex(project, - IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT); - + IIndex index= CCorePlugin.getIndexManager().getIndex(project, INDEX_SEARCH_OPTION); index.acquireReadLock(); try { IASTName name= IndexUI.getSelectedName(editorInput, sel); @@ -275,8 +275,7 @@ public class CallHierarchyUI { final ITranslationUnit tu= CModelUtil.getTranslationUnit(input); if (tu != null) { final ICProject project= tu.getCProject(); - final IIndex index= CCorePlugin.getIndexManager().getIndex(project, - IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT); + final IIndex index = CCorePlugin.getIndexManager().getIndex(project, INDEX_SEARCH_OPTION); index.acquireReadLock(); try { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction.java index 15ba197aa8f..d9148c3f94b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2012 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 @@ -72,6 +72,7 @@ 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.IIndexMacro; +import org.eclipse.cdt.core.index.IIndexManager; import org.eclipse.cdt.core.index.IIndexName; import org.eclipse.cdt.core.index.IndexFilter; import org.eclipse.cdt.core.model.ILanguage; @@ -170,11 +171,11 @@ public class AddIncludeOnSelectionAction extends TextEditorAction { } final String[] lookupName = new String[1]; - + final IIndex index= CCorePlugin.getIndexManager().getIndex(fTu.getCProject(), IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_EXTENSION_FRAGMENTS_ADD_IMPORT); SharedASTJob job = new SharedASTJob(CEditorMessages.AddIncludeOnSelection_label, fTu) { @Override public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException { - deduceInclude((ITextSelection) selection, ast, lookupName); + deduceInclude((ITextSelection) selection, index, ast, lookupName); return Status.OK_STATUS; } }; @@ -198,6 +199,8 @@ public class AddIncludeOnSelectionAction extends TextEditorAction { } } catch (InterruptedException e) { Thread.currentThread().interrupt(); + } catch (CoreException e) { + CUIPlugin.log("Cannot perform 'Add Include'", e); //$NON-NLS-1$ } } @@ -208,7 +211,7 @@ public class AddIncludeOnSelectionAction extends TextEditorAction { * @param ast an AST. * @param lookupName a one-element array used to return the selected name. */ - private void deduceInclude(ITextSelection selection, IASTTranslationUnit ast, String[] lookupName) + private void deduceInclude(ITextSelection selection, IIndex index, IASTTranslationUnit ast, String[] lookupName) throws CoreException { IASTNodeSelector selector = ast.getNodeSelector(fTu.getLocation().toOSString()); IASTName name = selector.findEnclosingName(selection.getOffset(), selection.getLength()); @@ -232,7 +235,6 @@ public class AddIncludeOnSelectionAction extends TextEditorAction { } final Map candidatesMap= new HashMap(); - final IIndex index = ast.getIndex(); final IndexFilter filter = IndexFilter.getDeclaredBindingFilter(ast.getLinkage().getLinkageID(), false); List bindings = new ArrayList(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBContentProvider.java index 96a8383a060..9d12a633631 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBContentProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBContentProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2012 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 @@ -25,6 +25,7 @@ import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndexFile; import org.eclipse.cdt.core.index.IIndexFileLocation; import org.eclipse.cdt.core.index.IIndexInclude; +import org.eclipse.cdt.core.index.IIndexManager; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ITranslationUnit; @@ -84,7 +85,7 @@ public class IBContentProvider extends AsyncTreeContentProvider { IIndex index; try { ICProject[] scope= CoreModel.getDefault().getCModel().getCProjects(); - index= CCorePlugin.getIndexManager().getIndex(scope); + index= CCorePlugin.getIndexManager().getIndex(scope, IIndexManager.ADD_EXTENSION_FRAGMENTS_INCLUDE_BROWSER); index.acquireReadLock(); } catch (CoreException e) { CUIPlugin.log(e); @@ -105,8 +106,7 @@ public class IBContentProvider extends AsyncTreeContentProvider { } if (includes.length > 0) { Set result= new LinkedHashSet(includes.length); - for (int i = 0; i < includes.length; i++) { - IIndexInclude include = includes[i]; + for (IIndexInclude include : includes) { try { if (fComputeIncludedBy) { directiveFile= targetFile= new IBFile(project, include.getIncludedByLocation()); @@ -158,10 +158,9 @@ public class IBContentProvider extends AsyncTreeContentProvider { if (files.length > 0) { ArrayList list= new ArrayList(); HashSet handled= new HashSet(); - for (int i = 0; i < files.length; i++) { - final IIndexInclude[] includes = index.findIncludedBy(files[i]); - for (int j = 0; j < includes.length; j++) { - IIndexInclude indexInclude = includes[j]; + for (IIndexFile file : files) { + final IIndexInclude[] includes = index.findIncludedBy(file); + for (IIndexInclude indexInclude : includes) { if (handled.add(indexInclude.getIncludedByLocation())) { list.add(indexInclude); } @@ -186,10 +185,9 @@ public class IBContentProvider extends AsyncTreeContentProvider { if (files.length > 0) { ArrayList list= new ArrayList(); HashSet handled= new HashSet(); - for (int i = 0; i < files.length; i++) { - final IIndexInclude[] includes = index.findIncludes(files[i]); - for (int j = 0; j < includes.length; j++) { - IIndexInclude indexInclude = includes[j]; + for (IIndexFile file : files) { + final IIndexInclude[] includes = index.findIncludes(file); + for (IIndexInclude indexInclude : includes) { if (handled.add(indexInclude.getIncludesLocation())) { list.add(indexInclude); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/OpenDefinitionAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/OpenDefinitionAction.java index 751ee9b2c7f..cf9ad826c09 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/OpenDefinitionAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/OpenDefinitionAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 QNX Software Systems and others. + * Copyright (c) 2006, 2012 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 @@ -26,6 +26,7 @@ import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndexBinding; +import org.eclipse.cdt.core.index.IIndexManager; import org.eclipse.cdt.core.index.IIndexName; import org.eclipse.cdt.core.index.IndexLocationFactory; import org.eclipse.cdt.core.model.CModelException; @@ -72,7 +73,7 @@ public class OpenDefinitionAction extends IndexAction { if (cproject != null) { IIndex index= CCorePlugin.getIndexManager().getIndex(cproject); if (!openDefinition(cproject, bindingNode, index)) { - index= CCorePlugin.getIndexManager().getIndex(CoreModel.getDefault().getCModel().getCProjects()); + index= CCorePlugin.getIndexManager().getIndex(CoreModel.getDefault().getCModel().getCProjects(), IIndexManager.ADD_EXTENSION_FRAGMENTS_NAVIGATION); openDefinition(cproject, bindingNode, index); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java index e0c673ee6d0..c534bd7ea9d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2011 QNX Software Systems and others. + * Copyright (c) 2006, 2012 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 @@ -493,8 +493,8 @@ public abstract class CSearchQuery implements ISearchQuery { result.setIndexerBusy(!CCorePlugin.getIndexManager().isIndexerIdle()); try { - IIndex index= CCorePlugin.getIndexManager().getIndex(projects, - IIndexManager.ADD_EXTENSION_FRAGMENTS); + IIndex index = CCorePlugin.getIndexManager().getIndex(projects, + IIndexManager.ADD_EXTENSION_FRAGMENTS_SEARCH); try { index.acquireReadLock(); } catch (InterruptedException e) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java index 836adeeb7e9..c3e8ccc8064 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2009, 2012 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 @@ -134,7 +134,7 @@ class OpenDeclarationsJob extends Job implements ASTRunnable { fMonitor= monitor; fIndex= CCorePlugin.getIndexManager().getIndex(fTranslationUnit.getCProject(), - IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT); + IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT | IIndexManager.ADD_EXTENSION_FRAGMENTS_NAVIGATION); try { fIndex.acquireReadLock(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistInvocationContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistInvocationContext.java index cad2f2bb5d3..0399e672b7b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistInvocationContext.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistInvocationContext.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2012 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 @@ -147,7 +147,7 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont try { IIndexManager manager= CCorePlugin.getIndexManager(); - fIndex = manager.getIndex(proj, IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT); + fIndex = manager.getIndex(proj, IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_EXTENSION_FRAGMENTS_CONTENT_ASSIST); try { fIndex.acquireReadLock(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHierarchyModel.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHierarchyModel.java index 67e0c3da9b8..2ecd3ca3c43 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHierarchyModel.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHierarchyModel.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2012 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 @@ -149,7 +149,7 @@ class THHierarchyModel { THGraph graph= new THGraph(); try { ICProject[] scope= CoreModel.getDefault().getCModel().getCProjects(); - IIndex index= CCorePlugin.getIndexManager().getIndex(scope, IIndexManager.ADD_EXTENSION_FRAGMENTS); + IIndex index= CCorePlugin.getIndexManager().getIndex(scope, IIndexManager.ADD_EXTENSION_FRAGMENTS_TYPE_HIERARCHY); index.acquireReadLock(); try { if (monitor.isCanceled()) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/TypeHierarchyUI.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/TypeHierarchyUI.java index aad3c9cb15f..50b3bd3a15b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/TypeHierarchyUI.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/TypeHierarchyUI.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2012 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 @@ -50,6 +50,9 @@ import org.eclipse.cdt.internal.ui.util.StatusLineHandler; import org.eclipse.cdt.internal.ui.viewsupport.IndexUI; public class TypeHierarchyUI { + private static final int INDEX_SEARCH_OPTION = IIndexManager.ADD_DEPENDENCIES + | IIndexManager.ADD_DEPENDENT | IIndexManager.ADD_EXTENSION_FRAGMENTS_TYPE_HIERARCHY; + public static THViewPart open(ICElement input, IWorkbenchWindow window) { if (!isValidInput(input)) { return null; @@ -141,7 +144,7 @@ public class TypeHierarchyUI { private static ICElement[] findInput(ICProject project, IEditorInput editorInput, IRegion sel) throws CoreException { try { - IIndex index= CCorePlugin.getIndexManager().getIndex(project, IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT); + IIndex index= CCorePlugin.getIndexManager().getIndex(project, INDEX_SEARCH_OPTION); index.acquireReadLock(); try { @@ -180,7 +183,7 @@ public class TypeHierarchyUI { private static ICElement[] findInput(ICElement member) { ICProject project= member.getCProject(); try { - IIndex index= CCorePlugin.getIndexManager().getIndex(project, IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT); + IIndex index= CCorePlugin.getIndexManager().getIndex(project, INDEX_SEARCH_OPTION); index.acquireReadLock(); try { IIndexName name= IndexUI.elementToName(index, member); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesCache.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesCache.java index f45f641a6d8..e2949a29500 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesCache.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesCache.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2012 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 @@ -119,7 +119,7 @@ class IndexedFilesCache implements IIndexChangeListener, IIndexerStateListener, } final protected void initialize(ICProject prj) throws CoreException, InterruptedException { - IIndex index= CCorePlugin.getIndexManager().getIndex(prj, 0); + IIndex index= CCorePlugin.getIndexManager().getIndex(prj); List list= new ArrayList(); index.acquireReadLock(); try { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java index 55f57d0c7f9..9cf4a4b5a72 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 QNX Software Systems and others. + * Copyright (c) 2005, 2012 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 @@ -45,6 +45,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace; import org.eclipse.cdt.core.index.IIndex; +import org.eclipse.cdt.core.index.IIndexManager; import org.eclipse.cdt.core.index.IndexFilter; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CoreModel; @@ -360,7 +361,7 @@ public class NewClassWizardUtil { IIndex index= null; try { if (project != null) { - index = CCorePlugin.getIndexManager().getIndex(project); + index = CCorePlugin.getIndexManager().getIndex(project, IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT | IIndexManager.ADD_EXTENSION_FRAGMENTS_NAVIGATION); index.acquireReadLock(); } } catch (CoreException e) {