mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 368160: Dependent projects and SDKs.
This commit is contained in:
parent
fcb45b9659
commit
fa55d3662d
37 changed files with 1004 additions and 796 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -240,6 +240,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// void m2(const StrT<T> s) {}
|
||||
// };
|
||||
|
||||
// #include "header.h"
|
||||
// void main() {
|
||||
// C1<char> 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<char> 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<typename T3>
|
||||
// class D<A, T3> {};
|
||||
|
||||
// #include "header.h"
|
||||
// template<typename T3> class D<A, T3>; // harmless declaration for test purposes
|
||||
// template<typename T3>
|
||||
// class D<B, T3> {};
|
||||
// template<typename T3>
|
||||
// class D<C, T3> {};
|
||||
// template<typename T3> class D<B, T3> {};
|
||||
// template<typename T3> class D<C, T3> {};
|
||||
public void testClassPartialSpecializations() throws Exception {
|
||||
IBinding b0= getBindingFromASTName("D<A, T3>", 8);
|
||||
IBinding b1= getBindingFromASTName("D<B, T3>", 8);
|
||||
|
@ -1170,6 +1172,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// class B {};
|
||||
// };
|
||||
|
||||
// #include "header.h"
|
||||
// void refs() {
|
||||
// A<C>::B acb;
|
||||
// A<D>::B adb;
|
||||
|
|
|
@ -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();)
|
||||
|
|
|
@ -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<expectedTrace.size(); i++) {
|
||||
ICProject cproject = (ICProject) expectedTrace.get(i);
|
||||
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject);
|
||||
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
|
||||
}
|
||||
for (Class element : DPS)
|
||||
assertEquals(expectedTrace, DPT.getProjectsTrace(element));
|
||||
|
@ -143,13 +147,13 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
|||
try {
|
||||
String name = "P"+System.currentTimeMillis();
|
||||
cproject = CProjectHelper.createCProject(name, "bin", IPDOMManager.ID_NO_INDEXER);
|
||||
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject);
|
||||
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
|
||||
expectedTrace.add(cproject);
|
||||
assertEquals(expectedTrace, DPT.getProjectsTrace(DP1));
|
||||
|
||||
cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
|
||||
cproject = CProjectHelper.createCProject(name, "bin", IPDOMManager.ID_NO_INDEXER);
|
||||
index = CCorePlugin.getIndexManager().getIndex(cproject);
|
||||
index = CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
|
||||
expectedTrace.add(cproject);
|
||||
assertEquals(expectedTrace, DPT.getProjectsTrace(DP1));
|
||||
} finally {
|
||||
|
@ -172,7 +176,7 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
|||
try {
|
||||
String name = "P"+System.currentTimeMillis();
|
||||
cproject = CProjectHelper.createCProject(name, "bin", IPDOMManager.ID_NO_INDEXER);
|
||||
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject);
|
||||
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
|
||||
expectedTrace.add(cproject);
|
||||
assertEquals(expectedTrace, DPT.getProjectsTrace(DP1));
|
||||
|
||||
|
@ -182,7 +186,7 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
|||
description.setLocationURI(newLocation.toURI());
|
||||
cproject.getProject().move(description, IResource.FORCE | IResource.SHALLOW, new NullProgressMonitor());
|
||||
|
||||
index = CCorePlugin.getIndexManager().getIndex(cproject);
|
||||
index = CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
|
||||
assertEquals(expectedTrace, DPT.getProjectsTrace(DP1));
|
||||
} finally {
|
||||
if(cproject!=null) {
|
||||
|
@ -241,7 +245,7 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
|||
ipm.reset(VERSION_405); ipm.startup();
|
||||
ipm.addIndexProvider(provider1); ipm.addIndexProvider(provider2);
|
||||
|
||||
IIndexFragment[] actual = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
||||
IIndexFragment[] actual = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||
assertEquals(1, actual.length);
|
||||
assertFragmentPresent("contentID.contentA", "38", actual);
|
||||
} finally {
|
||||
|
@ -300,7 +304,7 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
|||
ipm.reset(VERSION_502); ipm.startup();
|
||||
ipm.addIndexProvider(provider1); ipm.addIndexProvider(provider2);
|
||||
|
||||
IIndexFragment[] actual = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
||||
IIndexFragment[] actual = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||
assertEquals(3, actual.length);
|
||||
assertFragmentPresent("contentID.foo", "90", actual);
|
||||
assertFragmentPresent("contentID.bar", "91", actual);
|
||||
|
@ -343,7 +347,7 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
|||
ICConfigurationDescription cfg2= newCfg(pd, "project", "config2");
|
||||
core.setProjectDescription(project, pd);
|
||||
|
||||
index= CCorePlugin.getIndexManager().getIndex(cproject);
|
||||
index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
|
||||
CCorePlugin.getIndexManager().joinIndexer(8000, npm());
|
||||
|
||||
DPT.reset(DP1);
|
||||
|
@ -353,14 +357,14 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
|||
|
||||
changeActiveConfiguration(project, cfg1);
|
||||
DPT.reset(DP1);
|
||||
index= CCorePlugin.getIndexManager().getIndex(cproject);
|
||||
index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
|
||||
assertEquals(0, DPT.getProjectsTrace(DP1).size());
|
||||
assertEquals(1, DPT.getCfgsTrace(DP1).size());
|
||||
assertEquals("project.config1", ((ICConfigurationDescription)DPT.getCfgsTrace(DP1).get(0)).getId());
|
||||
|
||||
changeActiveConfiguration(project, cfg2);
|
||||
DPT.reset(DP1);
|
||||
index= CCorePlugin.getIndexManager().getIndex(cproject);
|
||||
index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
|
||||
assertEquals(0, DPT.getProjectsTrace(DP1).size());
|
||||
assertEquals(1, DPT.getCfgsTrace(DP1).size());
|
||||
assertEquals("project.config2", ((ICConfigurationDescription)DPT.getCfgsTrace(DP1).get(0)).getId());
|
||||
|
@ -372,7 +376,7 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
|||
|
||||
changeActiveConfiguration(project, cfg1);
|
||||
DPT.reset(DP1);
|
||||
index= CCorePlugin.getIndexManager().getIndex(cproject);
|
||||
index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
|
||||
assertEquals(0, DPT.getProjectsTrace(DP1).size());
|
||||
assertEquals(1, DPT.getCfgsTrace(DP1).size());
|
||||
// should still be config2, as the change in active configuration does not matter
|
||||
|
@ -380,7 +384,7 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
|||
|
||||
changeActiveConfiguration(project, cfg2);
|
||||
DPT.reset(DP1);
|
||||
index= CCorePlugin.getIndexManager().getIndex(cproject);
|
||||
index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
|
||||
assertEquals(0, DPT.getProjectsTrace(DP1).size());
|
||||
assertEquals(1, DPT.getCfgsTrace(DP1).size());
|
||||
// there should be no change from the previous state (also config2)
|
||||
|
@ -407,29 +411,29 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
|||
|
||||
IIndexFragment[] fragments;
|
||||
mockState.setConfig(MockState.REL_V1_ID);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||
assertEquals(2, fragments.length);
|
||||
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[0]));
|
||||
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[0]));
|
||||
|
||||
mockState.setConfig(MockState.DBG_V2_ID);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||
assertEquals(2, fragments.length);
|
||||
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[3]));
|
||||
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[3]));
|
||||
|
||||
mockState.setConfig(MockState.DBG_V1_ID);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||
assertEquals(0, fragments.length);
|
||||
|
||||
mockState.setConfig(MockState.REL_V2_ID);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||
assertEquals(2, fragments.length);
|
||||
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[1]));
|
||||
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[1]));
|
||||
|
||||
mockState.setConfig(MockState.REL_V1_ID);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||
assertEquals(2, fragments.length);
|
||||
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[0]));
|
||||
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[0]));
|
||||
|
@ -437,29 +441,29 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
|||
provider1.invert();
|
||||
|
||||
mockState.setConfig(MockState.REL_V1_ID);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||
assertEquals(2, fragments.length);
|
||||
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[3]));
|
||||
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[0]));
|
||||
|
||||
mockState.setConfig(MockState.DBG_V2_ID);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||
assertEquals(2, fragments.length);
|
||||
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[0]));
|
||||
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[3]));
|
||||
|
||||
mockState.setConfig(MockState.DBG_V1_ID);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||
assertEquals(1, fragments.length);
|
||||
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[1]));
|
||||
|
||||
mockState.setConfig(MockState.REL_V2_ID);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||
assertEquals(1, fragments.length);
|
||||
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[1]));
|
||||
|
||||
mockState.setConfig(MockState.REL_V1_ID);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||
assertEquals(2, fragments.length);
|
||||
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[3]));
|
||||
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[0]));
|
||||
|
@ -467,29 +471,29 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
|||
provider2.invert();
|
||||
|
||||
mockState.setConfig(MockState.REL_V1_ID);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||
assertEquals(2, fragments.length);
|
||||
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[3]));
|
||||
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[3]));
|
||||
|
||||
mockState.setConfig(MockState.DBG_V2_ID);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||
assertEquals(2, fragments.length);
|
||||
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[0]));
|
||||
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[0]));
|
||||
|
||||
mockState.setConfig(MockState.DBG_V1_ID);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||
assertEquals(2, fragments.length);
|
||||
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[1]));
|
||||
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[1]));
|
||||
|
||||
mockState.setConfig(MockState.REL_V2_ID);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||
assertEquals(0, fragments.length);
|
||||
|
||||
mockState.setConfig(MockState.REL_V1_ID);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||
assertEquals(2, fragments.length);
|
||||
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[3]));
|
||||
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[3]));
|
||||
|
@ -500,6 +504,52 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
|||
}
|
||||
}
|
||||
|
||||
public void testProviderUsageFilter() throws Exception {
|
||||
// The provider 'Providers.Counter' is registered 7 times with different usage filters.
|
||||
ICProject cproject= null;
|
||||
try {
|
||||
cproject = CProjectHelper.createCProject("P"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
|
||||
|
||||
Providers.Counter.fCounter= 0;
|
||||
CCorePlugin.getIndexManager().getIndex(cproject, IIndexManager.ADD_EXTENSION_FRAGMENTS_ADD_IMPORT);
|
||||
assertEquals(7, Providers.Counter.fCounter);
|
||||
|
||||
Providers.Counter.fCounter= 0;
|
||||
CCorePlugin.getIndexManager().getIndex(cproject, IIndexManager.ADD_EXTENSION_FRAGMENTS_CALL_HIERARCHY);
|
||||
assertEquals(6, Providers.Counter.fCounter);
|
||||
|
||||
Providers.Counter.fCounter= 0;
|
||||
CCorePlugin.getIndexManager().getIndex(cproject, IIndexManager.ADD_EXTENSION_FRAGMENTS_CONTENT_ASSIST);
|
||||
assertEquals(5, Providers.Counter.fCounter);
|
||||
|
||||
Providers.Counter.fCounter= 0;
|
||||
CCorePlugin.getIndexManager().getIndex(cproject, IIndexManager.ADD_EXTENSION_FRAGMENTS_INCLUDE_BROWSER);
|
||||
assertEquals(4, Providers.Counter.fCounter);
|
||||
|
||||
Providers.Counter.fCounter= 0;
|
||||
CCorePlugin.getIndexManager().getIndex(cproject, IIndexManager.ADD_EXTENSION_FRAGMENTS_NAVIGATION);
|
||||
assertEquals(3, Providers.Counter.fCounter);
|
||||
|
||||
Providers.Counter.fCounter= 0;
|
||||
CCorePlugin.getIndexManager().getIndex(cproject, IIndexManager.ADD_EXTENSION_FRAGMENTS_SEARCH);
|
||||
assertEquals(2, Providers.Counter.fCounter);
|
||||
|
||||
Providers.Counter.fCounter= 0;
|
||||
CCorePlugin.getIndexManager().getIndex(cproject, IIndexManager.ADD_EXTENSION_FRAGMENTS_TYPE_HIERARCHY);
|
||||
assertEquals(1, Providers.Counter.fCounter);
|
||||
|
||||
Providers.Counter.fCounter= 0;
|
||||
CCorePlugin.getIndexManager().getIndex(cproject);
|
||||
assertEquals(0, Providers.Counter.fCounter);
|
||||
|
||||
} finally {
|
||||
if (cproject != null) {
|
||||
cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private ICConfigurationDescription newCfg(ICProjectDescription des, String project, String config) throws CoreException {
|
||||
CDefaultConfigurationData data= new CDefaultConfigurationData(project+"."+config, project+" "+config+" name", null);
|
||||
data.initEmptyData();
|
||||
|
|
|
@ -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
|
||||
|
@ -288,7 +288,7 @@ public class IndexSearchTest extends IndexTestBase {
|
|||
}
|
||||
|
||||
public void testSanityOfMayHaveChildren() throws CoreException {
|
||||
PDOM pdom= (PDOM) ((CIndex) fIndex).getPrimaryFragments()[0];
|
||||
PDOM pdom= (PDOM) ((CIndex) fIndex).getFragments()[0];
|
||||
pdom.accept(new IPDOMVisitor() {
|
||||
LinkedList stack= new LinkedList();
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2009 Symbian Software Systems and others.
|
||||
* Copyright (c) 2006, 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
|
||||
|
@ -63,7 +63,7 @@ public class PDOMPrettyPrinter implements IPDOMVisitor {
|
|||
*/
|
||||
public static void dumpLinkage(IIndex index, final int linkageID) {
|
||||
final IPDOMVisitor v= new PDOMPrettyPrinter();
|
||||
IIndexFragment[] frg= ((CIndex) index).getPrimaryFragments();
|
||||
IIndexFragment[] frg= ((CIndex) index).getFragments();
|
||||
for (IIndexFragment element : frg) {
|
||||
final PDOM pdom = (PDOM) element;
|
||||
dumpLinkage(pdom, linkageID, v);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* 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
|
||||
|
@ -21,6 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.index.IIndex;
|
||||
import org.eclipse.cdt.core.index.IIndexLocationConverter;
|
||||
import org.eclipse.cdt.core.index.IIndexManager;
|
||||
import org.eclipse.cdt.core.index.IndexFilter;
|
||||
import org.eclipse.cdt.core.index.ResourceContainerRelativeLocationConverter;
|
||||
import org.eclipse.cdt.core.index.URIRelativeLocationConverter;
|
||||
|
@ -44,6 +45,7 @@ import org.eclipse.core.runtime.Path;
|
|||
* Tests addition of external pdom's into the logical index
|
||||
*/
|
||||
public class PDOMProviderTests extends PDOMTestBase {
|
||||
private static final int A_FRAGMENT_OPTIONS = IIndexManager.ADD_EXTENSION_FRAGMENTS_ADD_IMPORT;
|
||||
|
||||
public static Test suite() {
|
||||
return suite(PDOMProviderTests.class);
|
||||
|
@ -57,7 +59,7 @@ public class PDOMProviderTests extends PDOMTestBase {
|
|||
TestSourceReader.createFile(cproject.getProject(), new Path("/this.h"), "class A {};\n\n");
|
||||
CCorePlugin.getIndexManager().joinIndexer(3000, npm());
|
||||
|
||||
IIndex index= CCorePlugin.getIndexManager().getIndex(cproject);
|
||||
IIndex index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTIONS);
|
||||
index.acquireReadLock();
|
||||
try {
|
||||
IBinding[] bindings= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
|
||||
|
@ -108,7 +110,7 @@ public class PDOMProviderTests extends PDOMTestBase {
|
|||
|
||||
}
|
||||
));
|
||||
IIndex index= CCorePlugin.getIndexManager().getIndex(cproject2);
|
||||
IIndex index= CCorePlugin.getIndexManager().getIndex(cproject2, A_FRAGMENT_OPTIONS);
|
||||
index.acquireReadLock();
|
||||
try {
|
||||
IBinding[] bindings= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
|
||||
|
@ -135,7 +137,7 @@ public class PDOMProviderTests extends PDOMTestBase {
|
|||
TestSourceReader.createFile(cproject.getProject(), new Path("/this.h"), "class A {};\n\n");
|
||||
CCorePlugin.getIndexManager().joinIndexer(3000, npm());
|
||||
|
||||
IIndex index= CCorePlugin.getIndexManager().getIndex(cproject);
|
||||
IIndex index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTIONS);
|
||||
index.acquireReadLock();
|
||||
try {
|
||||
IBinding[] bindings= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
|
||||
|
@ -192,7 +194,7 @@ public class PDOMProviderTests extends PDOMTestBase {
|
|||
));
|
||||
|
||||
{
|
||||
IIndex index= CCorePlugin.getIndexManager().getIndex(cproject2);
|
||||
IIndex index= CCorePlugin.getIndexManager().getIndex(cproject2, A_FRAGMENT_OPTIONS);
|
||||
index.acquireReadLock();
|
||||
try {
|
||||
IBinding[] bindings= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
|
||||
|
@ -212,7 +214,7 @@ public class PDOMProviderTests extends PDOMTestBase {
|
|||
}
|
||||
|
||||
{
|
||||
IIndex index= CCorePlugin.getIndexManager().getIndex(cproject3);
|
||||
IIndex index= CCorePlugin.getIndexManager().getIndex(cproject3, A_FRAGMENT_OPTIONS);
|
||||
index.acquireReadLock();
|
||||
try {
|
||||
IBinding[] bindings= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
|
||||
|
@ -232,7 +234,7 @@ public class PDOMProviderTests extends PDOMTestBase {
|
|||
}
|
||||
|
||||
{
|
||||
IIndex index= CCorePlugin.getIndexManager().getIndex(new ICProject[]{cproject2, cproject3});
|
||||
IIndex index= CCorePlugin.getIndexManager().getIndex(new ICProject[]{cproject2, cproject3}, A_FRAGMENT_OPTIONS);
|
||||
index.acquireReadLock();
|
||||
try {
|
||||
IBinding[] bindings= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
|
||||
|
@ -317,7 +319,7 @@ public class PDOMProviderTests extends PDOMTestBase {
|
|||
for(int i=0; i<3; i++) {
|
||||
// try several times in order to test the status is logged only once
|
||||
ICProjectDescription pd= CCorePlugin.getDefault().getProjectDescription(cproject2.getProject(), false);
|
||||
assertEquals(0, ipm.getProvidedIndexFragments(pd.getActiveConfiguration(), true).length);
|
||||
assertEquals(0, ipm.getProvidedIndexFragments(pd.getActiveConfiguration(), -1).length);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -149,6 +149,54 @@
|
|||
<ReadOnlyPDOMProvider
|
||||
class="org.eclipse.cdt.core.internal.index.provider.test.Providers$Dummy5">
|
||||
</ReadOnlyPDOMProvider>
|
||||
<ReadOnlyPDOMProvider
|
||||
class="org.eclipse.cdt.core.internal.index.provider.test.Providers$Counter">
|
||||
<FragmentProviderUsage
|
||||
add_import="true" call_hierarchy="true" content_assist="true" include_browser="true"
|
||||
navigation="true" search="true" type_hierarchy="true" />
|
||||
</ReadOnlyPDOMProvider>
|
||||
<ReadOnlyPDOMProvider
|
||||
class="org.eclipse.cdt.core.internal.index.provider.test.Providers$Counter">
|
||||
<FragmentProviderUsage
|
||||
add_import="true" call_hierarchy="true" content_assist="true" include_browser="true"
|
||||
navigation="true" search="true" type_hierarchy="false" />
|
||||
</ReadOnlyPDOMProvider>
|
||||
<ReadOnlyPDOMProvider
|
||||
class="org.eclipse.cdt.core.internal.index.provider.test.Providers$Counter">
|
||||
<FragmentProviderUsage
|
||||
add_import="true" call_hierarchy="true" content_assist="true" include_browser="true"
|
||||
navigation="true" search="false" type_hierarchy="false" />
|
||||
</ReadOnlyPDOMProvider>
|
||||
<ReadOnlyPDOMProvider
|
||||
class="org.eclipse.cdt.core.internal.index.provider.test.Providers$Counter">
|
||||
<FragmentProviderUsage
|
||||
add_import="true" call_hierarchy="true" content_assist="true" include_browser="true"
|
||||
navigation="false" search="false" type_hierarchy="false" />
|
||||
</ReadOnlyPDOMProvider>
|
||||
<ReadOnlyPDOMProvider
|
||||
class="org.eclipse.cdt.core.internal.index.provider.test.Providers$Counter">
|
||||
<FragmentProviderUsage
|
||||
add_import="true" call_hierarchy="true" content_assist="true" include_browser="false"
|
||||
navigation="false" search="false" type_hierarchy="false" />
|
||||
</ReadOnlyPDOMProvider>
|
||||
<ReadOnlyPDOMProvider
|
||||
class="org.eclipse.cdt.core.internal.index.provider.test.Providers$Counter">
|
||||
<FragmentProviderUsage
|
||||
add_import="true" call_hierarchy="true" content_assist="false" include_browser="false"
|
||||
navigation="false" search="false" type_hierarchy="false" />
|
||||
</ReadOnlyPDOMProvider>
|
||||
<ReadOnlyPDOMProvider
|
||||
class="org.eclipse.cdt.core.internal.index.provider.test.Providers$Counter">
|
||||
<FragmentProviderUsage
|
||||
add_import="true" call_hierarchy="false" content_assist="false" include_browser="false"
|
||||
navigation="false" search="false" type_hierarchy="false" />
|
||||
</ReadOnlyPDOMProvider>
|
||||
<ReadOnlyPDOMProvider
|
||||
class="org.eclipse.cdt.core.internal.index.provider.test.Providers$Counter">
|
||||
<FragmentProviderUsage
|
||||
add_import="false" call_hierarchy="false" content_assist="false" include_browser="false"
|
||||
navigation="false" search="false" type_hierarchy="false" />
|
||||
</ReadOnlyPDOMProvider>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.core.filesystem.filesystems">
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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<NameKey> encounteredNames = new HashSet<NameKey>();
|
||||
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<ISignificantMacros> handled = new HashSet<ISignificantMacros>();
|
||||
ArrayList<IIndexFragmentFile> result= new ArrayList<IIndexFragmentFile>();
|
||||
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<FileContentKey> keys = new HashSet<FileContentKey>();
|
||||
ArrayList<IIndexFragmentFile> result= new ArrayList<IIndexFragmentFile>();
|
||||
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<IIndexFile> nextLevel= depth != 0 ? new LinkedList<IIndexFile>() : 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<IIndexMacro> result = new ArrayList<IIndexMacro>();
|
||||
HashSet<IIndexFileLocation> handledIFLs= new HashSet<IIndexFileLocation>();
|
||||
monitor.beginTask(Messages.CIndex_FindBindingsTask_label, fFragments.length);
|
||||
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
||||
for (IIndexFragment fragment : fFragments) {
|
||||
HashSet<IIndexFile> allowedFiles= new HashSet<IIndexFile>();
|
||||
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;
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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<IProject, Integer> map= new HashMap<IProject, Integer>();
|
||||
Collection<ICProject> selectedProjects= getProjects(projects, addDependencies, addDependent,
|
||||
map, new Integer(1));
|
||||
Collection<ICProject> indexProjects=
|
||||
getProjects(projects, addDependencies, addDependent, new HashSet<IProject>());
|
||||
|
||||
HashMap<String, IIndexFragment> fragments= new LinkedHashMap<String, IIndexFragment>();
|
||||
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<IIndexFragment> 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<String, IIndexFragment> readOnlyFrag= new LinkedHashMap<String, IIndexFragment>();
|
||||
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<ICProject> selectedProjects= getProjects(new ICProject[] {project}, true, false,
|
||||
new HashMap<IProject, Integer>(), new Integer(1));
|
||||
selectedProjects.remove(project);
|
||||
|
||||
for (ICProject cproject : selectedProjects) {
|
||||
safeAddFragment(readOnlyFrag, fPDOMManager.getPDOM(cproject));
|
||||
}
|
||||
|
||||
Collection<IIndexFragment> readOnlyFragments= readOnlyFrag.values();
|
||||
return new WritableCIndex(pdom, readOnlyFragments.toArray(new IIndexFragment[readOnlyFragments.size()]));
|
||||
return new WritableCIndex(pdom);
|
||||
}
|
||||
|
||||
private Collection<ICProject> getProjects(ICProject[] projects, boolean addDependencies,
|
||||
boolean addDependent, HashMap<IProject, Integer> map, Integer markWith) {
|
||||
List<IProject> projectsToSearch= new ArrayList<IProject>();
|
||||
boolean addDependent, Set<IProject> handled) {
|
||||
List<ICProject> result= new ArrayList<ICProject>();
|
||||
|
||||
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<ICProject> result= new ArrayList<ICProject>();
|
||||
for (Map.Entry<IProject, Integer> 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<IProject, Integer> map,
|
||||
List<IProject> 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<IProject> handled, List<ICProject> 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<String, IIndexFragment> 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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<ProvisionMapKey, Boolean> provisionMap;
|
||||
private Set<String> 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<ProvisionMapKey, Boolean>();
|
||||
this.pdomVersionRange= pdomVersionRange;
|
||||
this.compatibleFragmentUnavailable= new HashSet<String>();
|
||||
}
|
||||
|
||||
public void startup() {
|
||||
List<IIndexFragmentProvider> pdomProviders = new ArrayList<IIndexFragmentProvider>();
|
||||
List<IIndexFragmentProvider> nonPDOMProviders = new ArrayList<IIndexFragmentProvider>();
|
||||
List<IIndexFragmentProvider> providers = new ArrayList<IIndexFragmentProvider>();
|
||||
List<IConfigurationElement[]> usageSpecifications= new ArrayList<IConfigurationElement[]>();
|
||||
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<IConfigurationElement[]> 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<String, IIndexFragment> id2fragment = new HashMap<String, IIndexFragment>();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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}.
|
||||
|
|
|
@ -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<String, IPDOMLinkageFactory> 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<String, IPDOMLinkageFactory> 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<String, IPDOMLinkageFactory> 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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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<String, IPDOMLinkageFactory> 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<String, IPDOMLinkageFactory> 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;
|
||||
}
|
||||
|
|
|
@ -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<LinkageTask> fRequestsPerLinkage= new ArrayList<LinkageTask>();
|
||||
private Map<IIndexFile, IndexFileContent> fIndexContentCache= new LRUCache<IIndexFile, IndexFileContent>(500);
|
||||
private Map<IIndexFileLocation, IIndexFile[]> fIndexFilesCache= new LRUCache<IIndexFileLocation, IIndexFile[]>(5000);
|
||||
private Map<IIndexFileLocation, IIndexFragmentFile[]> fIndexFilesCache= new LRUCache<IIndexFileLocation, IIndexFragmentFile[]>(5000);
|
||||
private Map<IIndexFileLocation, LocationTask> fOneLinkageTasks= new HashMap<IIndexFileLocation, AbstractIndexerTask.LocationTask>();
|
||||
|
||||
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;
|
||||
|
|
|
@ -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<IProject> referencing= new HashSet<IProject>();
|
||||
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<IProject> result) {
|
||||
LinkedList<IProject> projectsToSearch= new LinkedList<IProject>();
|
||||
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) {
|
||||
|
|
|
@ -1,250 +1,315 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!-- Schema file written by PDE -->
|
||||
<schema targetNamespace="org.eclipse.cdt.core" xmlns="http://www.w3.org/2001/XMLSchema">
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.schema plugin="org.eclipse.cdt.core" id="CIndex" name="CIndex"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
This extension point groups extensions to the index functionality in CDT
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<element name="extension">
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.element />
|
||||
</appInfo>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<choice minOccurs="1" maxOccurs="unbounded">
|
||||
<element ref="ExportProjectProvider"/>
|
||||
<element ref="ReadOnlyPDOMProvider"/>
|
||||
<element ref="ReadOnlyIndexFragmentProvider"/>
|
||||
</choice>
|
||||
<attribute name="point" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="id" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="name" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<meta.attribute translatable="true"/>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="ExportProjectProvider">
|
||||
<annotation>
|
||||
<documentation>
|
||||
<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>
|
||||
</documentation>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<attribute name="class" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
the fully qualified name of the IExportProjectProvider implementation to register
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<meta.attribute kind="java"/>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="ReadOnlyPDOMProvider">
|
||||
<annotation>
|
||||
<documentation>
|
||||
<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>
|
||||
</documentation>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<attribute name="class" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The fully qualified name of the IReadOnlyPDOMProvider implementation to register
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.core.index.provider.IReadOnlyPDOMProvider"/>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="ReadOnlyIndexFragmentProvider">
|
||||
<annotation>
|
||||
<documentation>
|
||||
<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.
|
||||
</documentation>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<attribute name="class" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The fully qualified name of a class implementing IIndexFragmentProvider interface.
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.internal.core.index.provider.IIndexFragmentProvider"/>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="apiInfo"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
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
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="since"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
4.0
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="examples"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
See subelement documentation
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="implementation"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
See subelement documentation
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="copyright"/>
|
||||
</appInfo>
|
||||
<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
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
</schema>
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!-- Schema file written by PDE -->
|
||||
<schema targetNamespace="org.eclipse.cdt.core" xmlns="http://www.w3.org/2001/XMLSchema">
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.schema plugin="org.eclipse.cdt.core" id="CIndex" name="CIndex"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
This extension point groups extensions to the index functionality in CDT
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<element name="extension">
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.element />
|
||||
</appInfo>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<choice minOccurs="1" maxOccurs="unbounded">
|
||||
<element ref="ExportProjectProvider"/>
|
||||
<element ref="ReadOnlyPDOMProvider"/>
|
||||
<element ref="ReadOnlyIndexFragmentProvider"/>
|
||||
</choice>
|
||||
<attribute name="point" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="id" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="name" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<meta.attribute translatable="true"/>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="ExportProjectProvider">
|
||||
<annotation>
|
||||
<documentation>
|
||||
<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>
|
||||
</documentation>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<attribute name="class" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
the fully qualified name of the IExportProjectProvider implementation to register
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<meta.attribute kind="java"/>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="ReadOnlyPDOMProvider">
|
||||
<annotation>
|
||||
<documentation>
|
||||
<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>
|
||||
</documentation>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<sequence minOccurs="0" maxOccurs="1">
|
||||
<element ref="FragmentProviderUsage"/>
|
||||
</sequence>
|
||||
<attribute name="class" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The fully qualified name of the IReadOnlyPDOMProvider implementation to register
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.core.index.provider.IReadOnlyPDOMProvider"/>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="ReadOnlyIndexFragmentProvider">
|
||||
<annotation>
|
||||
<documentation>
|
||||
<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.
|
||||
</documentation>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<sequence minOccurs="0" maxOccurs="1">
|
||||
<element ref="FragmentProviderUsage"/>
|
||||
</sequence>
|
||||
<attribute name="class" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The fully qualified name of a class implementing IIndexFragmentProvider interface.
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.internal.core.index.provider.IIndexFragmentProvider"/>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="FragmentProviderUsage">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Defines for which tools the fragment provider shall be used.
|
||||
</documentation>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<attribute name="navigation" type="boolean" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Whether the fragment provider shall be used for performing 'Open Declaration' and 'Open Element'.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="content_assist" type="boolean" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Whether the fragment provider shall be used for performing content-assist.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="add_import" type="boolean" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Whether the fragment provider shall be used for performing 'Add Import'.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="call_hierarchy" type="boolean" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Whether the fragment provider shall be used for populating the call hierarchy.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="type_hierarchy" type="boolean" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Whether the fragment provider shall be used for populating the type hierarchy.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="include_browser" type="boolean" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Whether the fragment provider shall be used for populating the include browser.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="search" type="boolean" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Whether the fragment provider shall be used for C/C++ searches.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="apiInfo"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
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
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="since"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
4.0
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="examples"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
See subelement documentation
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="implementation"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
See subelement documentation
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="copyright"/>
|
||||
</appInfo>
|
||||
<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
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
</schema>
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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<String, IncludeCandidate> candidatesMap= new HashMap<String, IncludeCandidate>();
|
||||
final IIndex index = ast.getIndex();
|
||||
final IndexFilter filter = IndexFilter.getDeclaredBindingFilter(ast.getLinkage().getLinkageID(), false);
|
||||
|
||||
List<IIndexBinding> bindings = new ArrayList<IIndexBinding>();
|
||||
|
|
|
@ -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<IBNode> result= new LinkedHashSet<IBNode>(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<IIndexInclude> list= new ArrayList<IIndexInclude>();
|
||||
HashSet<IIndexFileLocation> handled= new HashSet<IIndexFileLocation>();
|
||||
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<IIndexInclude> list= new ArrayList<IIndexInclude>();
|
||||
HashSet<IIndexFileLocation> handled= new HashSet<IIndexFileLocation>();
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<IIndexFileLocation> list= new ArrayList<IIndexFileLocation>();
|
||||
index.acquireReadLock();
|
||||
try {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue