mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-05 08:46:02 +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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -10,10 +10,22 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.internal.index.provider.test;
|
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 class Providers {
|
||||||
public static class Dummy1 extends AbstractDummyProvider {}
|
public static class Dummy1 extends AbstractDummyProvider {}
|
||||||
public static class Dummy2 extends AbstractDummyProvider {}
|
public static class Dummy2 extends AbstractDummyProvider {}
|
||||||
public static class Dummy3 extends AbstractDummyProvider {}
|
public static class Dummy3 extends AbstractDummyProvider {}
|
||||||
public static class Dummy4 extends AbstractDummyProvider {}
|
public static class Dummy4 extends AbstractDummyProvider {}
|
||||||
public static class Dummy5 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) {}
|
// void m2(const StrT<T> s) {}
|
||||||
// };
|
// };
|
||||||
|
|
||||||
|
// #include "header.h"
|
||||||
// void main() {
|
// void main() {
|
||||||
// C1<char> c1;
|
// C1<char> c1;
|
||||||
// c1.m1("aaa"); // OK
|
// c1.m1("aaa"); // OK
|
||||||
|
@ -274,6 +275,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
||||||
// public: void assign(const T* s) {}
|
// public: void assign(const T* s) {}
|
||||||
// };
|
// };
|
||||||
|
|
||||||
|
// #include "header.h"
|
||||||
// void main() {
|
// void main() {
|
||||||
// StrT<char> x;
|
// StrT<char> x;
|
||||||
// x.assign("aaa");
|
// x.assign("aaa");
|
||||||
|
@ -355,6 +357,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
||||||
// void m3();
|
// void m3();
|
||||||
// };
|
// };
|
||||||
|
|
||||||
|
// #include "header.h"
|
||||||
// void C1::m3() {
|
// void C1::m3() {
|
||||||
// m1("aaa"); // OK
|
// m1("aaa"); // OK
|
||||||
// m2("aaa"); // problem
|
// m2("aaa"); // problem
|
||||||
|
@ -565,11 +568,10 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
||||||
// template<typename T3>
|
// template<typename T3>
|
||||||
// class D<A, 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<A, T3>; // harmless declaration for test purposes
|
||||||
// template<typename T3>
|
// template<typename T3> class D<B, T3> {};
|
||||||
// class D<B, T3> {};
|
// template<typename T3> class D<C, T3> {};
|
||||||
// template<typename T3>
|
|
||||||
// class D<C, T3> {};
|
|
||||||
public void testClassPartialSpecializations() throws Exception {
|
public void testClassPartialSpecializations() throws Exception {
|
||||||
IBinding b0= getBindingFromASTName("D<A, T3>", 8);
|
IBinding b0= getBindingFromASTName("D<A, T3>", 8);
|
||||||
IBinding b1= getBindingFromASTName("D<B, T3>", 8);
|
IBinding b1= getBindingFromASTName("D<B, T3>", 8);
|
||||||
|
@ -1170,6 +1172,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
||||||
// class B {};
|
// class B {};
|
||||||
// };
|
// };
|
||||||
|
|
||||||
|
// #include "header.h"
|
||||||
// void refs() {
|
// void refs() {
|
||||||
// A<C>::B acb;
|
// A<C>::B acb;
|
||||||
// A<D>::B adb;
|
// 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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -108,6 +108,7 @@ public class IndexCompositeTests extends BaseTestCase {
|
||||||
// enum E {E1,E2};
|
// enum E {E1,E2};
|
||||||
// void foo(C1 c) {}
|
// void foo(C1 c) {}
|
||||||
|
|
||||||
|
// #include "h3.h"
|
||||||
// class B1 {};
|
// class B1 {};
|
||||||
// namespace X { class B2 {}; }
|
// namespace X { class B2 {}; }
|
||||||
// C1 c1;
|
// C1 c1;
|
||||||
|
@ -115,6 +116,7 @@ public class IndexCompositeTests extends BaseTestCase {
|
||||||
// void foo(B1 c) {}
|
// void foo(B1 c) {}
|
||||||
// void foo(X::C2 c) {}
|
// void foo(X::C2 c) {}
|
||||||
|
|
||||||
|
// #include "h2.h"
|
||||||
// class A1 {};
|
// class A1 {};
|
||||||
// void foo(X::B2 c) {}
|
// void foo(X::B2 c) {}
|
||||||
// namespace X { class A2 {}; B2 b; C2 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
|
/* Defines Global, Defines Namespace, References Global, References Namespace
|
||||||
* projC: 6, 2, 0, 0
|
* projC: 6, 2, 0, 0
|
||||||
* projB: 6, 1, 1, 1
|
* projB: 6, 1, 1, 1 + projC
|
||||||
* projA: 3, 3, 0, 2
|
* 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);
|
setIndex(cprojC, NONE);
|
||||||
assertBCount(6, 6 +2); assertNamespaceXMemberCount(1);
|
assertBCount(gC, aC); assertNamespaceXMemberCount(1);
|
||||||
assertFieldCount("C1", 1);
|
assertFieldCount("C1", 1);
|
||||||
|
|
||||||
setIndex(cprojC, REFS);
|
setIndex(cprojC, REFS);
|
||||||
assertBCount(6, 6 +2);
|
assertBCount(gC, aC);
|
||||||
assertNamespaceXMemberCount(1);
|
assertNamespaceXMemberCount(1);
|
||||||
assertFieldCount("C1", 1);
|
assertFieldCount("C1", 1);
|
||||||
|
|
||||||
setIndex(cprojC, REFD);
|
setIndex(cprojC, REFD);
|
||||||
assertBCount((6+(6-1)+(3-1)), (6+2)+(6+1-1)+(3+3-1));
|
assertBCount(gABC, aABC);
|
||||||
assertNamespaceXMemberCount(5);
|
assertNamespaceXMemberCount(5);
|
||||||
assertFieldCount("C1", 1);
|
assertFieldCount("C1", 1);
|
||||||
|
|
||||||
setIndex(cprojC, BOTH);
|
setIndex(cprojC, BOTH);
|
||||||
assertBCount((6+(6-1)+(3-1)), (6+2)+(6+1-1)+(3+3-1));
|
assertBCount(gABC, aABC);
|
||||||
assertNamespaceXMemberCount(5);
|
assertNamespaceXMemberCount(5);
|
||||||
assertFieldCount("C1", 1);
|
assertFieldCount("C1", 1);
|
||||||
|
|
||||||
|
|
||||||
setIndex(cprojB, NONE);
|
setIndex(cprojB, NONE);
|
||||||
assertBCount(6+1, 6+1+1+1);
|
assertBCount(gBC, aBC);
|
||||||
assertNamespaceXMemberCount(2);
|
assertNamespaceXMemberCount(2);
|
||||||
assertFieldCount("C1", 1);
|
assertFieldCount("C1", 1);
|
||||||
|
|
||||||
setIndex(cprojB, REFS);
|
setIndex(cprojB, REFS);
|
||||||
assertBCount(6+1+6-1-1, (6+1+1+1)-1-1 + (6+2) -1);
|
assertBCount(gBC, aBC);
|
||||||
assertNamespaceXMemberCount(2);
|
assertNamespaceXMemberCount(2);
|
||||||
assertFieldCount("C1", 1);
|
assertFieldCount("C1", 1);
|
||||||
|
|
||||||
setIndex(cprojB, REFD);
|
setIndex(cprojB, REFD);
|
||||||
assertBCount(6+1+3-1, (6+1+1+1) + (3+3) -1);
|
assertBCount(gABC, aABC);
|
||||||
assertNamespaceXMemberCount(5);
|
assertNamespaceXMemberCount(5);
|
||||||
assertFieldCount("C1", 1);
|
assertFieldCount("C1", 1);
|
||||||
|
|
||||||
setIndex(cprojB, BOTH);
|
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);
|
assertNamespaceXMemberCount(5);
|
||||||
assertFieldCount("C1", 1);
|
assertFieldCount("C1", 1);
|
||||||
|
|
||||||
|
|
||||||
setIndex(cprojA, NONE);
|
setIndex(cprojA, NONE);
|
||||||
assertBCount(3, 8);
|
assertBCount(gABC, aABC);
|
||||||
assertNamespaceXMemberCount(5);
|
assertNamespaceXMemberCount(5);
|
||||||
// binding C1 is not referenced by cprojA
|
// binding C1 is not referenced by cprojA
|
||||||
|
|
||||||
setIndex(cprojA, REFS);
|
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);
|
assertNamespaceXMemberCount(5);
|
||||||
assertFieldCount("C1", 1);
|
assertFieldCount("C1", 1);
|
||||||
|
|
||||||
setIndex(cprojA, REFD);
|
setIndex(cprojA, REFD);
|
||||||
assertBCount(3, 8);
|
assertBCount(gABC, aABC);
|
||||||
assertNamespaceXMemberCount(5);
|
assertNamespaceXMemberCount(5);
|
||||||
// binding C1 is not referenced by cprojA
|
// binding C1 is not referenced by cprojA
|
||||||
|
|
||||||
setIndex(cprojA, BOTH);
|
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);
|
assertNamespaceXMemberCount(5);
|
||||||
assertFieldCount("C1", 1);
|
assertFieldCount("C1", 1);
|
||||||
} finally {
|
} 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 {};
|
// class B1 {};
|
||||||
// namespace X { class B2 {}; }
|
// namespace X { class B2 {}; }
|
||||||
// void foo(B1 c) {}
|
// void foo(B1 c) {}
|
||||||
// void foo(X::B2 c, B1 c) {}
|
// void foo(X::B2 c, B1 c) {}
|
||||||
|
|
||||||
|
// #include "h2.h"
|
||||||
// class A1 {};
|
// class A1 {};
|
||||||
// void foo(X::B2 c) {}
|
// void foo(X::B2 c) {}
|
||||||
// namespace X { class A2 {}; }
|
// namespace X { class A2 {}; }
|
||||||
// B1 ab;
|
// 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 {
|
public void testTripleUpwardV() throws Exception {
|
||||||
CharSequence[] contents = getContentsForTest(3);
|
CharSequence[] contents = getContentsForTest(3);
|
||||||
List projects = new ArrayList();
|
List projects = new ArrayList();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ProjectBuilder pb = new ProjectBuilder("projB"+System.currentTimeMillis(), true);
|
ProjectBuilder pb = new ProjectBuilder("projB"+System.currentTimeMillis(), true);
|
||||||
pb.addFile("h2.h", contents[1]);
|
pb.addFile("h2.h", contents[0]);
|
||||||
ICProject cprojB = pb.create();
|
ICProject cprojB = pb.create();
|
||||||
projects.add(cprojB);
|
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 = 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();
|
ICProject cprojC = pb.create();
|
||||||
projects.add(cprojC);
|
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 |
|
/* A C |
|
||||||
* \ / | Depends On / References
|
* \ / | Depends On / References
|
||||||
|
@ -254,44 +266,53 @@ public class IndexCompositeTests extends BaseTestCase {
|
||||||
* projB: 4, 1, 0, 0
|
* projB: 4, 1, 0, 0
|
||||||
* projA: 4, 1, 1, 1
|
* 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);
|
setIndex(cprojC, NONE);
|
||||||
assertBCount(7+1, 7+2+1+1);
|
assertBCount(gBC, aBC);
|
||||||
assertNamespaceXMemberCount(3);
|
assertNamespaceXMemberCount(3);
|
||||||
setIndex(cprojC, REFS);
|
setIndex(cprojC, REFS);
|
||||||
assertBCount(7+1+4-1-1, 7+1+1+2+4+1-1-2);
|
assertBCount(gBC, aBC);
|
||||||
assertNamespaceXMemberCount(3);
|
assertNamespaceXMemberCount(3);
|
||||||
setIndex(cprojC, REFD);
|
setIndex(cprojC, REFD);
|
||||||
assertBCount(7+1, 7+1+1+2);
|
assertBCount(gBC, aBC);
|
||||||
assertNamespaceXMemberCount(3);
|
assertNamespaceXMemberCount(3);
|
||||||
setIndex(cprojC, BOTH);
|
setIndex(cprojC, BOTH);
|
||||||
assertBCount(7+4+4-2, 7+4+4-2 +2+1+1);
|
assertBCount(gABC, aABC);
|
||||||
assertNamespaceXMemberCount(4);
|
assertNamespaceXMemberCount(4);
|
||||||
|
|
||||||
setIndex(cprojB, NONE);
|
setIndex(cprojB, NONE);
|
||||||
assertBCount(4, 4+1);
|
assertBCount(gB, aB);
|
||||||
assertNamespaceXMemberCount(1);
|
assertNamespaceXMemberCount(1);
|
||||||
setIndex(cprojB, REFS);
|
setIndex(cprojB, REFS);
|
||||||
assertBCount(4, 4+1);
|
assertBCount(gB, aB);
|
||||||
assertNamespaceXMemberCount(1);
|
assertNamespaceXMemberCount(1);
|
||||||
setIndex(cprojB, REFD);
|
setIndex(cprojB, REFD);
|
||||||
assertBCount(7+4+4-2, 7+4+4-2 +2+1+1);
|
assertBCount(gABC, aABC);
|
||||||
assertNamespaceXMemberCount(4);
|
assertNamespaceXMemberCount(4);
|
||||||
setIndex(cprojB, BOTH);
|
setIndex(cprojB, BOTH);
|
||||||
assertBCount(7+4+4-2, 7+4+4-2 +2+1+1);
|
assertBCount(gABC, aABC);
|
||||||
assertNamespaceXMemberCount(4);
|
assertNamespaceXMemberCount(4);
|
||||||
|
|
||||||
setIndex(cprojA, NONE);
|
setIndex(cprojA, NONE);
|
||||||
assertBCount(4+1, 4+1+1+1);
|
assertBCount(gAB, aAB);
|
||||||
assertNamespaceXMemberCount(2);
|
assertNamespaceXMemberCount(2);
|
||||||
setIndex(cprojA, REFS);
|
setIndex(cprojA, REFS);
|
||||||
assertBCount(4+1+4-1-1, 4+1+4-1-1 +1+1);
|
assertBCount(gAB, aAB);
|
||||||
assertNamespaceXMemberCount(2);
|
assertNamespaceXMemberCount(2);
|
||||||
setIndex(cprojA, REFD);
|
setIndex(cprojA, REFD);
|
||||||
assertBCount(4+1, 4+1+1+1);
|
assertBCount(gAB, aAB);
|
||||||
assertNamespaceXMemberCount(2);
|
assertNamespaceXMemberCount(2);
|
||||||
setIndex(cprojA, BOTH);
|
setIndex(cprojA, BOTH);
|
||||||
assertBCount(7+4+4-2, 7+4+4-2 +2+1+1);
|
assertBCount(gABC, aABC);
|
||||||
assertNamespaceXMemberCount(4);
|
assertNamespaceXMemberCount(4);
|
||||||
} finally {
|
} finally {
|
||||||
for (Iterator i = projects.iterator(); i.hasNext();)
|
for (Iterator i = projects.iterator(); i.hasNext();)
|
||||||
|
@ -304,11 +325,13 @@ public class IndexCompositeTests extends BaseTestCase {
|
||||||
// enum E {E1,E2};
|
// enum E {E1,E2};
|
||||||
// void foo(C1 c) {}
|
// void foo(C1 c) {}
|
||||||
|
|
||||||
|
// #include "h3.h"
|
||||||
|
// #include "h1.h"
|
||||||
// class B1 {};
|
// class B1 {};
|
||||||
// namespace X { class B2 {}; C1 c; }
|
// namespace X { class B2 {}; C1 c; }
|
||||||
// void foo(A1 c) {}
|
// void foo(A1 c) {}
|
||||||
// void foo(X::A2 c, B1 c) {}
|
// void foo(X::A2 c, B1 c) {}
|
||||||
|
|
||||||
// class A1 {};
|
// class A1 {};
|
||||||
// void foo(A1 a, A1 b) {}
|
// void foo(A1 a, A1 b) {}
|
||||||
// namespace X { class A2 {}; }
|
// namespace X { class A2 {}; }
|
||||||
|
@ -342,43 +365,51 @@ public class IndexCompositeTests extends BaseTestCase {
|
||||||
* projA: 3, 1, 0, 0
|
* 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);
|
setIndex(cprojC, NONE);
|
||||||
assertBCount(6, 6+1);
|
assertBCount(gC, aC);
|
||||||
assertNamespaceXMemberCount(1);
|
assertNamespaceXMemberCount(1);
|
||||||
setIndex(cprojC, REFS);
|
setIndex(cprojC, REFS);
|
||||||
assertBCount(6, 6+1);
|
assertBCount(gC, aC);
|
||||||
assertNamespaceXMemberCount(1);
|
assertNamespaceXMemberCount(1);
|
||||||
setIndex(cprojC, REFD);
|
setIndex(cprojC, REFD);
|
||||||
assertBCount(6+4+1-1, 6+4+1-1 +1+1+1+1);
|
assertBCount(gABC, aABC);
|
||||||
assertNamespaceXMemberCount(4);
|
assertNamespaceXMemberCount(4);
|
||||||
setIndex(cprojC, BOTH);
|
setIndex(cprojC, BOTH);
|
||||||
assertBCount(6+4+3-2, 6+4+3-2 +1+2+1);
|
assertBCount(gABC, aABC);
|
||||||
assertNamespaceXMemberCount(4);
|
assertNamespaceXMemberCount(4);
|
||||||
|
|
||||||
setIndex(cprojB, NONE);
|
setIndex(cprojB, NONE);
|
||||||
assertBCount(4+2, 4+2 +2+1);
|
assertBCount(gABC, aABC);
|
||||||
assertNamespaceXMemberCount(4);
|
assertNamespaceXMemberCount(4);
|
||||||
setIndex(cprojB, REFS);
|
setIndex(cprojB, REFS);
|
||||||
assertBCount(6+4+3-2, 6+4+3-2 +1+2+1);
|
assertBCount(gABC, aABC);
|
||||||
assertNamespaceXMemberCount(4);
|
assertNamespaceXMemberCount(4);
|
||||||
setIndex(cprojB, REFD);
|
setIndex(cprojB, REFD);
|
||||||
assertBCount(4+2, 4+2 +2+1);
|
assertBCount(gABC, aABC);
|
||||||
assertNamespaceXMemberCount(4);
|
assertNamespaceXMemberCount(4);
|
||||||
setIndex(cprojB, BOTH);
|
setIndex(cprojB, BOTH);
|
||||||
assertBCount(6+4+3-2, 6+4+3-2 +1+2+1);
|
assertBCount(gABC, aABC);
|
||||||
assertNamespaceXMemberCount(4);
|
assertNamespaceXMemberCount(4);
|
||||||
|
|
||||||
setIndex(cprojA, NONE);
|
setIndex(cprojA, NONE);
|
||||||
assertBCount(3, 3 +1);
|
assertBCount(gA, aA);
|
||||||
assertNamespaceXMemberCount(1);
|
assertNamespaceXMemberCount(1);
|
||||||
setIndex(cprojA, REFS);
|
setIndex(cprojA, REFS);
|
||||||
assertBCount(3, 3 +1);
|
assertBCount(gA, aA);
|
||||||
assertNamespaceXMemberCount(1);
|
assertNamespaceXMemberCount(1);
|
||||||
setIndex(cprojA, REFD);
|
setIndex(cprojA, REFD);
|
||||||
assertBCount(4+2+3-1-1, 4+2+3-1-1 +2+1);
|
assertBCount(gABC, aABC);
|
||||||
assertNamespaceXMemberCount(4);
|
assertNamespaceXMemberCount(4);
|
||||||
setIndex(cprojA, BOTH);
|
setIndex(cprojA, BOTH);
|
||||||
assertBCount(6+4+3-2, 6+4+3-2 +1+2+1);
|
assertBCount(gABC, aABC);
|
||||||
assertNamespaceXMemberCount(4);
|
assertNamespaceXMemberCount(4);
|
||||||
} finally {
|
} finally {
|
||||||
for (Iterator i = projects.iterator(); i.hasNext();)
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Ferguson (Symbian) - Initial implementation
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.index.tests;
|
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.cdtvariables.ICdtVariablesContributor;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
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.index.provider.IIndexProvider;
|
||||||
import org.eclipse.cdt.core.internal.index.provider.test.DummyProviderTraces;
|
import org.eclipse.cdt.core.internal.index.provider.test.DummyProviderTraces;
|
||||||
import org.eclipse.cdt.core.internal.index.provider.test.Providers;
|
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
|
* Example usage and test for IIndexProvider
|
||||||
*/
|
*/
|
||||||
public class IndexProviderManagerTest extends IndexTestBase {
|
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 DummyProviderTraces DPT= DummyProviderTraces.getInstance();
|
||||||
final static Class DP1= Providers.Dummy1.class;
|
final static Class DP1= Providers.Dummy1.class;
|
||||||
final static Class DP2= Providers.Dummy2.class;
|
final static Class DP2= Providers.Dummy2.class;
|
||||||
|
@ -115,7 +119,7 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
||||||
try {
|
try {
|
||||||
for(int i=0; i<3; i++) {
|
for(int i=0; i<3; i++) {
|
||||||
ICProject cproject = CProjectHelper.createCProject("P"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
|
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);
|
cprojects.add(cproject);
|
||||||
expectedTrace.add(cproject);
|
expectedTrace.add(cproject);
|
||||||
}
|
}
|
||||||
|
@ -123,7 +127,7 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
||||||
assertEquals(expectedTrace, DPT.getProjectsTrace(element));
|
assertEquals(expectedTrace, DPT.getProjectsTrace(element));
|
||||||
for(int i=0; i<expectedTrace.size(); i++) {
|
for(int i=0; i<expectedTrace.size(); i++) {
|
||||||
ICProject cproject = (ICProject) expectedTrace.get(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)
|
for (Class element : DPS)
|
||||||
assertEquals(expectedTrace, DPT.getProjectsTrace(element));
|
assertEquals(expectedTrace, DPT.getProjectsTrace(element));
|
||||||
|
@ -143,13 +147,13 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
||||||
try {
|
try {
|
||||||
String name = "P"+System.currentTimeMillis();
|
String name = "P"+System.currentTimeMillis();
|
||||||
cproject = CProjectHelper.createCProject(name, "bin", IPDOMManager.ID_NO_INDEXER);
|
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);
|
expectedTrace.add(cproject);
|
||||||
assertEquals(expectedTrace, DPT.getProjectsTrace(DP1));
|
assertEquals(expectedTrace, DPT.getProjectsTrace(DP1));
|
||||||
|
|
||||||
cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
|
cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
|
||||||
cproject = CProjectHelper.createCProject(name, "bin", IPDOMManager.ID_NO_INDEXER);
|
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);
|
expectedTrace.add(cproject);
|
||||||
assertEquals(expectedTrace, DPT.getProjectsTrace(DP1));
|
assertEquals(expectedTrace, DPT.getProjectsTrace(DP1));
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -172,7 +176,7 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
||||||
try {
|
try {
|
||||||
String name = "P"+System.currentTimeMillis();
|
String name = "P"+System.currentTimeMillis();
|
||||||
cproject = CProjectHelper.createCProject(name, "bin", IPDOMManager.ID_NO_INDEXER);
|
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);
|
expectedTrace.add(cproject);
|
||||||
assertEquals(expectedTrace, DPT.getProjectsTrace(DP1));
|
assertEquals(expectedTrace, DPT.getProjectsTrace(DP1));
|
||||||
|
|
||||||
|
@ -182,7 +186,7 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
||||||
description.setLocationURI(newLocation.toURI());
|
description.setLocationURI(newLocation.toURI());
|
||||||
cproject.getProject().move(description, IResource.FORCE | IResource.SHALLOW, new NullProgressMonitor());
|
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));
|
assertEquals(expectedTrace, DPT.getProjectsTrace(DP1));
|
||||||
} finally {
|
} finally {
|
||||||
if(cproject!=null) {
|
if(cproject!=null) {
|
||||||
|
@ -241,7 +245,7 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
||||||
ipm.reset(VERSION_405); ipm.startup();
|
ipm.reset(VERSION_405); ipm.startup();
|
||||||
ipm.addIndexProvider(provider1); ipm.addIndexProvider(provider2);
|
ipm.addIndexProvider(provider1); ipm.addIndexProvider(provider2);
|
||||||
|
|
||||||
IIndexFragment[] actual = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
IIndexFragment[] actual = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||||
assertEquals(1, actual.length);
|
assertEquals(1, actual.length);
|
||||||
assertFragmentPresent("contentID.contentA", "38", actual);
|
assertFragmentPresent("contentID.contentA", "38", actual);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -300,7 +304,7 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
||||||
ipm.reset(VERSION_502); ipm.startup();
|
ipm.reset(VERSION_502); ipm.startup();
|
||||||
ipm.addIndexProvider(provider1); ipm.addIndexProvider(provider2);
|
ipm.addIndexProvider(provider1); ipm.addIndexProvider(provider2);
|
||||||
|
|
||||||
IIndexFragment[] actual = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
IIndexFragment[] actual = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||||
assertEquals(3, actual.length);
|
assertEquals(3, actual.length);
|
||||||
assertFragmentPresent("contentID.foo", "90", actual);
|
assertFragmentPresent("contentID.foo", "90", actual);
|
||||||
assertFragmentPresent("contentID.bar", "91", actual);
|
assertFragmentPresent("contentID.bar", "91", actual);
|
||||||
|
@ -343,7 +347,7 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
||||||
ICConfigurationDescription cfg2= newCfg(pd, "project", "config2");
|
ICConfigurationDescription cfg2= newCfg(pd, "project", "config2");
|
||||||
core.setProjectDescription(project, pd);
|
core.setProjectDescription(project, pd);
|
||||||
|
|
||||||
index= CCorePlugin.getIndexManager().getIndex(cproject);
|
index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
|
||||||
CCorePlugin.getIndexManager().joinIndexer(8000, npm());
|
CCorePlugin.getIndexManager().joinIndexer(8000, npm());
|
||||||
|
|
||||||
DPT.reset(DP1);
|
DPT.reset(DP1);
|
||||||
|
@ -353,14 +357,14 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
||||||
|
|
||||||
changeActiveConfiguration(project, cfg1);
|
changeActiveConfiguration(project, cfg1);
|
||||||
DPT.reset(DP1);
|
DPT.reset(DP1);
|
||||||
index= CCorePlugin.getIndexManager().getIndex(cproject);
|
index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
|
||||||
assertEquals(0, DPT.getProjectsTrace(DP1).size());
|
assertEquals(0, DPT.getProjectsTrace(DP1).size());
|
||||||
assertEquals(1, DPT.getCfgsTrace(DP1).size());
|
assertEquals(1, DPT.getCfgsTrace(DP1).size());
|
||||||
assertEquals("project.config1", ((ICConfigurationDescription)DPT.getCfgsTrace(DP1).get(0)).getId());
|
assertEquals("project.config1", ((ICConfigurationDescription)DPT.getCfgsTrace(DP1).get(0)).getId());
|
||||||
|
|
||||||
changeActiveConfiguration(project, cfg2);
|
changeActiveConfiguration(project, cfg2);
|
||||||
DPT.reset(DP1);
|
DPT.reset(DP1);
|
||||||
index= CCorePlugin.getIndexManager().getIndex(cproject);
|
index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
|
||||||
assertEquals(0, DPT.getProjectsTrace(DP1).size());
|
assertEquals(0, DPT.getProjectsTrace(DP1).size());
|
||||||
assertEquals(1, DPT.getCfgsTrace(DP1).size());
|
assertEquals(1, DPT.getCfgsTrace(DP1).size());
|
||||||
assertEquals("project.config2", ((ICConfigurationDescription)DPT.getCfgsTrace(DP1).get(0)).getId());
|
assertEquals("project.config2", ((ICConfigurationDescription)DPT.getCfgsTrace(DP1).get(0)).getId());
|
||||||
|
@ -372,7 +376,7 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
||||||
|
|
||||||
changeActiveConfiguration(project, cfg1);
|
changeActiveConfiguration(project, cfg1);
|
||||||
DPT.reset(DP1);
|
DPT.reset(DP1);
|
||||||
index= CCorePlugin.getIndexManager().getIndex(cproject);
|
index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
|
||||||
assertEquals(0, DPT.getProjectsTrace(DP1).size());
|
assertEquals(0, DPT.getProjectsTrace(DP1).size());
|
||||||
assertEquals(1, DPT.getCfgsTrace(DP1).size());
|
assertEquals(1, DPT.getCfgsTrace(DP1).size());
|
||||||
// should still be config2, as the change in active configuration does not matter
|
// 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);
|
changeActiveConfiguration(project, cfg2);
|
||||||
DPT.reset(DP1);
|
DPT.reset(DP1);
|
||||||
index= CCorePlugin.getIndexManager().getIndex(cproject);
|
index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
|
||||||
assertEquals(0, DPT.getProjectsTrace(DP1).size());
|
assertEquals(0, DPT.getProjectsTrace(DP1).size());
|
||||||
assertEquals(1, DPT.getCfgsTrace(DP1).size());
|
assertEquals(1, DPT.getCfgsTrace(DP1).size());
|
||||||
// there should be no change from the previous state (also config2)
|
// there should be no change from the previous state (also config2)
|
||||||
|
@ -407,29 +411,29 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
||||||
|
|
||||||
IIndexFragment[] fragments;
|
IIndexFragment[] fragments;
|
||||||
mockState.setConfig(MockState.REL_V1_ID);
|
mockState.setConfig(MockState.REL_V1_ID);
|
||||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||||
assertEquals(2, fragments.length);
|
assertEquals(2, fragments.length);
|
||||||
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[0]));
|
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[0]));
|
||||||
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[0]));
|
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[0]));
|
||||||
|
|
||||||
mockState.setConfig(MockState.DBG_V2_ID);
|
mockState.setConfig(MockState.DBG_V2_ID);
|
||||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||||
assertEquals(2, fragments.length);
|
assertEquals(2, fragments.length);
|
||||||
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[3]));
|
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[3]));
|
||||||
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[3]));
|
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[3]));
|
||||||
|
|
||||||
mockState.setConfig(MockState.DBG_V1_ID);
|
mockState.setConfig(MockState.DBG_V1_ID);
|
||||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||||
assertEquals(0, fragments.length);
|
assertEquals(0, fragments.length);
|
||||||
|
|
||||||
mockState.setConfig(MockState.REL_V2_ID);
|
mockState.setConfig(MockState.REL_V2_ID);
|
||||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||||
assertEquals(2, fragments.length);
|
assertEquals(2, fragments.length);
|
||||||
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[1]));
|
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[1]));
|
||||||
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[1]));
|
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[1]));
|
||||||
|
|
||||||
mockState.setConfig(MockState.REL_V1_ID);
|
mockState.setConfig(MockState.REL_V1_ID);
|
||||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||||
assertEquals(2, fragments.length);
|
assertEquals(2, fragments.length);
|
||||||
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[0]));
|
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[0]));
|
||||||
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[0]));
|
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[0]));
|
||||||
|
@ -437,29 +441,29 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
||||||
provider1.invert();
|
provider1.invert();
|
||||||
|
|
||||||
mockState.setConfig(MockState.REL_V1_ID);
|
mockState.setConfig(MockState.REL_V1_ID);
|
||||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||||
assertEquals(2, fragments.length);
|
assertEquals(2, fragments.length);
|
||||||
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[3]));
|
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[3]));
|
||||||
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[0]));
|
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[0]));
|
||||||
|
|
||||||
mockState.setConfig(MockState.DBG_V2_ID);
|
mockState.setConfig(MockState.DBG_V2_ID);
|
||||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||||
assertEquals(2, fragments.length);
|
assertEquals(2, fragments.length);
|
||||||
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[0]));
|
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[0]));
|
||||||
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[3]));
|
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[3]));
|
||||||
|
|
||||||
mockState.setConfig(MockState.DBG_V1_ID);
|
mockState.setConfig(MockState.DBG_V1_ID);
|
||||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||||
assertEquals(1, fragments.length);
|
assertEquals(1, fragments.length);
|
||||||
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[1]));
|
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[1]));
|
||||||
|
|
||||||
mockState.setConfig(MockState.REL_V2_ID);
|
mockState.setConfig(MockState.REL_V2_ID);
|
||||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||||
assertEquals(1, fragments.length);
|
assertEquals(1, fragments.length);
|
||||||
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[1]));
|
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[1]));
|
||||||
|
|
||||||
mockState.setConfig(MockState.REL_V1_ID);
|
mockState.setConfig(MockState.REL_V1_ID);
|
||||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||||
assertEquals(2, fragments.length);
|
assertEquals(2, fragments.length);
|
||||||
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[3]));
|
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[3]));
|
||||||
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[0]));
|
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[0]));
|
||||||
|
@ -467,29 +471,29 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
||||||
provider2.invert();
|
provider2.invert();
|
||||||
|
|
||||||
mockState.setConfig(MockState.REL_V1_ID);
|
mockState.setConfig(MockState.REL_V1_ID);
|
||||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||||
assertEquals(2, fragments.length);
|
assertEquals(2, fragments.length);
|
||||||
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[3]));
|
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[3]));
|
||||||
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[3]));
|
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[3]));
|
||||||
|
|
||||||
mockState.setConfig(MockState.DBG_V2_ID);
|
mockState.setConfig(MockState.DBG_V2_ID);
|
||||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||||
assertEquals(2, fragments.length);
|
assertEquals(2, fragments.length);
|
||||||
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[0]));
|
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[0]));
|
||||||
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[0]));
|
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[0]));
|
||||||
|
|
||||||
mockState.setConfig(MockState.DBG_V1_ID);
|
mockState.setConfig(MockState.DBG_V1_ID);
|
||||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||||
assertEquals(2, fragments.length);
|
assertEquals(2, fragments.length);
|
||||||
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[1]));
|
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[1]));
|
||||||
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[1]));
|
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[1]));
|
||||||
|
|
||||||
mockState.setConfig(MockState.REL_V2_ID);
|
mockState.setConfig(MockState.REL_V2_ID);
|
||||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||||
assertEquals(0, fragments.length);
|
assertEquals(0, fragments.length);
|
||||||
|
|
||||||
mockState.setConfig(MockState.REL_V1_ID);
|
mockState.setConfig(MockState.REL_V1_ID);
|
||||||
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
|
fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||||
assertEquals(2, fragments.length);
|
assertEquals(2, fragments.length);
|
||||||
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[3]));
|
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[3]));
|
||||||
assertTrue(ArrayUtil.contains(fragments, provider2.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 {
|
private ICConfigurationDescription newCfg(ICProjectDescription des, String project, String config) throws CoreException {
|
||||||
CDefaultConfigurationData data= new CDefaultConfigurationData(project+"."+config, project+" "+config+" name", null);
|
CDefaultConfigurationData data= new CDefaultConfigurationData(project+"."+config, project+" "+config+" name", null);
|
||||||
data.initEmptyData();
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -288,7 +288,7 @@ public class IndexSearchTest extends IndexTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSanityOfMayHaveChildren() throws CoreException {
|
public void testSanityOfMayHaveChildren() throws CoreException {
|
||||||
PDOM pdom= (PDOM) ((CIndex) fIndex).getPrimaryFragments()[0];
|
PDOM pdom= (PDOM) ((CIndex) fIndex).getFragments()[0];
|
||||||
pdom.accept(new IPDOMVisitor() {
|
pdom.accept(new IPDOMVisitor() {
|
||||||
LinkedList stack= new LinkedList();
|
LinkedList stack= new LinkedList();
|
||||||
@Override
|
@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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* 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) {
|
public static void dumpLinkage(IIndex index, final int linkageID) {
|
||||||
final IPDOMVisitor v= new PDOMPrettyPrinter();
|
final IPDOMVisitor v= new PDOMPrettyPrinter();
|
||||||
IIndexFragment[] frg= ((CIndex) index).getPrimaryFragments();
|
IIndexFragment[] frg= ((CIndex) index).getFragments();
|
||||||
for (IIndexFragment element : frg) {
|
for (IIndexFragment element : frg) {
|
||||||
final PDOM pdom = (PDOM) element;
|
final PDOM pdom = (PDOM) element;
|
||||||
dumpLinkage(pdom, linkageID, v);
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* 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.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.index.IIndexLocationConverter;
|
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.IndexFilter;
|
||||||
import org.eclipse.cdt.core.index.ResourceContainerRelativeLocationConverter;
|
import org.eclipse.cdt.core.index.ResourceContainerRelativeLocationConverter;
|
||||||
import org.eclipse.cdt.core.index.URIRelativeLocationConverter;
|
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
|
* Tests addition of external pdom's into the logical index
|
||||||
*/
|
*/
|
||||||
public class PDOMProviderTests extends PDOMTestBase {
|
public class PDOMProviderTests extends PDOMTestBase {
|
||||||
|
private static final int A_FRAGMENT_OPTIONS = IIndexManager.ADD_EXTENSION_FRAGMENTS_ADD_IMPORT;
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
return suite(PDOMProviderTests.class);
|
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");
|
TestSourceReader.createFile(cproject.getProject(), new Path("/this.h"), "class A {};\n\n");
|
||||||
CCorePlugin.getIndexManager().joinIndexer(3000, npm());
|
CCorePlugin.getIndexManager().joinIndexer(3000, npm());
|
||||||
|
|
||||||
IIndex index= CCorePlugin.getIndexManager().getIndex(cproject);
|
IIndex index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTIONS);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IBinding[] bindings= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
|
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();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IBinding[] bindings= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
|
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");
|
TestSourceReader.createFile(cproject.getProject(), new Path("/this.h"), "class A {};\n\n");
|
||||||
CCorePlugin.getIndexManager().joinIndexer(3000, npm());
|
CCorePlugin.getIndexManager().joinIndexer(3000, npm());
|
||||||
|
|
||||||
IIndex index= CCorePlugin.getIndexManager().getIndex(cproject);
|
IIndex index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTIONS);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IBinding[] bindings= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
|
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();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IBinding[] bindings= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
|
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();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IBinding[] bindings= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
|
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();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IBinding[] bindings= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
|
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++) {
|
for(int i=0; i<3; i++) {
|
||||||
// try several times in order to test the status is logged only once
|
// try several times in order to test the status is logged only once
|
||||||
ICProjectDescription pd= CCorePlugin.getDefault().getProjectDescription(cproject2.getProject(), false);
|
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
|
<ReadOnlyPDOMProvider
|
||||||
class="org.eclipse.cdt.core.internal.index.provider.test.Providers$Dummy5">
|
class="org.eclipse.cdt.core.internal.index.provider.test.Providers$Dummy5">
|
||||||
</ReadOnlyPDOMProvider>
|
</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>
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.core.filesystem.filesystems">
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* 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.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
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.index.IndexFilter;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
@ -47,7 +48,7 @@ public class AllTypesCache {
|
||||||
private static final boolean DEBUG = false;
|
private static final boolean DEBUG = false;
|
||||||
|
|
||||||
private static ITypeInfo[] getTypes(ICProject[] projects, final int[] kinds, IProgressMonitor monitor) throws CoreException {
|
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 {
|
try {
|
||||||
index.acquireReadLock();
|
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
|
* This program and the accompanying materials are made available under the
|
||||||
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
|
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
|
||||||
* and is available at http://www.eclipse.org/legal/epl-v10.html
|
* 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.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
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.ILanguage;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit;
|
||||||
|
@ -205,7 +204,7 @@ public class ASTCache {
|
||||||
ASTRunnable astRunnable) {
|
ASTRunnable astRunnable) {
|
||||||
IIndex index;
|
IIndex index;
|
||||||
try {
|
try {
|
||||||
index = CCorePlugin.getIndexManager().getIndex(tUnit.getCProject(), IIndexManager.ADD_DEPENDENCIES);
|
index = CCorePlugin.getIndexManager().getIndex(tUnit.getCProject());
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
return e.getStatus();
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -121,7 +121,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
||||||
@Override
|
@Override
|
||||||
public void parse(boolean quickParseMode) throws Exception {
|
public void parse(boolean quickParseMode) throws Exception {
|
||||||
final IIndexManager indexManager= CCorePlugin.getIndexManager();
|
final IIndexManager indexManager= CCorePlugin.getIndexManager();
|
||||||
IIndex index= indexManager.getIndex(fTranslationUnit.getCProject(), IIndexManager.ADD_DEPENDENCIES);
|
IIndex index= indexManager.getIndex(fTranslationUnit.getCProject());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (index != null) {
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -43,21 +43,74 @@ public interface IIndexManager extends IPDOMManager {
|
||||||
public final static int ADD_DEPENDENT = 0x2;
|
public final static int ADD_DEPENDENT = 0x2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant for passing to getIndex methods. This constant, when set, indicates that the index
|
* @deprecated Extension fragments are now used depending on their configuration.
|
||||||
* content provided via the CIndex extension point should not be included in the resulting
|
* Use one of the ADD_EXTENSION_XX flags instead.
|
||||||
* index, as it would have done otherwise.
|
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public final static int SKIP_PROVIDED = 0x4;
|
public final static int SKIP_PROVIDED = 0x4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant for passing to getIndex methods. This constant, when set, indicates that the index
|
* Constant for passing to getIndex methods. This constant, when set, indicates that each index
|
||||||
* content provided via the ReadOnlyIndexFragmentProvider element of the CIndex extension point
|
* content provided via the ReadOnlyIndexFragmentProvider or ReadOnlyPDOMProvider, which is not
|
||||||
* should be included in the resulting index. By default such index content is not included.
|
* disabled for navigation shall be included in the resulting index.
|
||||||
* This flag is ignored if SKIP_PROVIDED flag is set.
|
|
||||||
*
|
*
|
||||||
* @since 5.4
|
* @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.
|
* 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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* 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 static final boolean SPECIALCASE_SINGLES = true;
|
||||||
|
|
||||||
private final IIndexFragment[] fFragments;
|
private final IIndexFragment[] fFragments;
|
||||||
private final int fPrimaryFragmentCount;
|
|
||||||
private int fReadLock;
|
private int fReadLock;
|
||||||
private ICompositesFactory cppCF, cCF, fCF;
|
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,
|
* @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.
|
* 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) {
|
public CIndex(IIndexFragment[] fragments) {
|
||||||
this(fragments, fragments.length);
|
fFragments= fragments;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -89,12 +81,12 @@ public class CIndex implements IIndex {
|
||||||
if (SPECIALCASE_SINGLES && fFragments.length == 1) {
|
if (SPECIALCASE_SINGLES && fFragments.length == 1) {
|
||||||
return fFragments[0].findBinding((IASTName) name);
|
return fFragments[0].findBinding((IASTName) name);
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
for (IIndexFragment fragment : fFragments) {
|
||||||
IIndexFragmentBinding binding= fFragments[i].findBinding((IASTName) name);
|
IIndexFragmentBinding binding= fragment.findBinding((IASTName) name);
|
||||||
if (binding != null) {
|
if (binding != null) {
|
||||||
return getCompositesFactory(binding.getLinkage().getLinkageID()).getCompositeBinding(binding);
|
return getCompositesFactory(binding.getLinkage().getLinkageID()).getCompositeBinding(binding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -116,8 +108,8 @@ public class CIndex implements IIndex {
|
||||||
ILinkage[] linkages = Linkage.getIndexerLinkages();
|
ILinkage[] linkages = Linkage.getIndexerLinkages();
|
||||||
for (ILinkage linkage : linkages) {
|
for (ILinkage linkage : linkages) {
|
||||||
if (filter.acceptLinkage(linkage)) {
|
if (filter.acceptLinkage(linkage)) {
|
||||||
IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
|
IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fFragments.length][];
|
||||||
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
for (int i = 0; i < fFragments.length; i++) {
|
||||||
try {
|
try {
|
||||||
IBinding[] part = fFragments[i].findBindings(patterns, isFullyQualified,
|
IBinding[] part = fFragments[i].findBindings(patterns, isFullyQualified,
|
||||||
retargetFilter(linkage, filter), monitor);
|
retargetFilter(linkage, filter), monitor);
|
||||||
|
@ -146,8 +138,8 @@ public class CIndex implements IIndex {
|
||||||
ILinkage[] linkages = Linkage.getIndexerLinkages();
|
ILinkage[] linkages = Linkage.getIndexerLinkages();
|
||||||
for (ILinkage linkage : linkages) {
|
for (ILinkage linkage : linkages) {
|
||||||
if (filter.acceptLinkage(linkage)) {
|
if (filter.acceptLinkage(linkage)) {
|
||||||
IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
|
IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fFragments.length][];
|
||||||
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
for (int i = 0; i < fFragments.length; i++) {
|
||||||
try {
|
try {
|
||||||
IBinding[] part = fFragments[i].findMacroContainers(pattern,
|
IBinding[] part = fFragments[i].findMacroContainers(pattern,
|
||||||
retargetFilter(linkage, filter), monitor);
|
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
|
// 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.
|
// 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>();
|
HashSet<NameKey> encounteredNames = new HashSet<NameKey>();
|
||||||
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
for (IIndexFragment fragment : fFragments) {
|
||||||
final IIndexFragmentName[] names = fFragments[i].findNames(binding, flags);
|
if (fragment instanceof IWritableIndexFragment) {
|
||||||
for (IIndexFragmentName name : names) {
|
final IIndexFragmentName[] names = fragment.findNames(binding, flags);
|
||||||
if (encounteredNames.add(new NameKey(name))) {
|
for (IIndexFragmentName name : names) {
|
||||||
result.add(name);
|
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
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public IIndexFile getFile(int linkageID, IIndexFileLocation location) throws CoreException {
|
public IIndexFile getFile(int linkageID, IIndexFileLocation location) throws CoreException {
|
||||||
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
for (IIndexFragment fragment : fFragments) {
|
||||||
IIndexFragmentFile candidate= fFragments[i].getFile(linkageID, location);
|
IIndexFragmentFile candidate= fragment.getFile(linkageID, location);
|
||||||
if (candidate != null && candidate.hasContent()) {
|
if (candidate != null && candidate.hasContent()) {
|
||||||
return candidate;
|
return candidate;
|
||||||
}
|
}
|
||||||
|
@ -229,8 +236,8 @@ public class CIndex implements IIndex {
|
||||||
@Override
|
@Override
|
||||||
public IIndexFile getFile(int linkageID, IIndexFileLocation location,
|
public IIndexFile getFile(int linkageID, IIndexFileLocation location,
|
||||||
ISignificantMacros significantMacros) throws CoreException {
|
ISignificantMacros significantMacros) throws CoreException {
|
||||||
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
for (IIndexFragment fragment : fFragments) {
|
||||||
IIndexFragmentFile candidate= fFragments[i].getFile(linkageID, location, significantMacros);
|
IIndexFragmentFile candidate= fragment.getFile(linkageID, location, significantMacros);
|
||||||
if (candidate != null && candidate.hasContent()) {
|
if (candidate != null && candidate.hasContent()) {
|
||||||
return candidate;
|
return candidate;
|
||||||
}
|
}
|
||||||
|
@ -245,8 +252,8 @@ public class CIndex implements IIndex {
|
||||||
}
|
}
|
||||||
Set<ISignificantMacros> handled = new HashSet<ISignificantMacros>();
|
Set<ISignificantMacros> handled = new HashSet<ISignificantMacros>();
|
||||||
ArrayList<IIndexFragmentFile> result= new ArrayList<IIndexFragmentFile>();
|
ArrayList<IIndexFragmentFile> result= new ArrayList<IIndexFragmentFile>();
|
||||||
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
for (IIndexFragment fragment : fFragments) {
|
||||||
IIndexFragmentFile[] candidates= fFragments[i].getFiles(linkageID, location);
|
IIndexFragmentFile[] candidates= fragment.getFiles(linkageID, location);
|
||||||
for (IIndexFragmentFile candidate : candidates) {
|
for (IIndexFragmentFile candidate : candidates) {
|
||||||
if (candidate.hasContent()) {
|
if (candidate.hasContent()) {
|
||||||
ISignificantMacros macroKey = candidate.getSignificantMacros();
|
ISignificantMacros macroKey = candidate.getSignificantMacros();
|
||||||
|
@ -269,8 +276,8 @@ public class CIndex implements IIndex {
|
||||||
}
|
}
|
||||||
Set<FileContentKey> keys = new HashSet<FileContentKey>();
|
Set<FileContentKey> keys = new HashSet<FileContentKey>();
|
||||||
ArrayList<IIndexFragmentFile> result= new ArrayList<IIndexFragmentFile>();
|
ArrayList<IIndexFragmentFile> result= new ArrayList<IIndexFragmentFile>();
|
||||||
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
for (IIndexFragment fragment : fFragments) {
|
||||||
IIndexFragmentFile[] candidates= fFragments[i].getFiles(location);
|
IIndexFragmentFile[] candidates= fragment.getFiles(location);
|
||||||
for (IIndexFragmentFile candidate : candidates) {
|
for (IIndexFragmentFile candidate : candidates) {
|
||||||
if (candidate.hasContent()) {
|
if (candidate.hasContent()) {
|
||||||
if (keys.add(new FileContentKey(candidate.getLinkageID(), candidate.getLocation(), candidate.getSignificantMacros()))) {
|
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;
|
List<IIndexFile> nextLevel= depth != 0 ? new LinkedList<IIndexFile>() : null;
|
||||||
for (IIndexFile iIndexFile : in) {
|
for (IIndexFile iIndexFile : in) {
|
||||||
IIndexFragmentFile file = (IIndexFragmentFile) iIndexFile;
|
IIndexFragmentFile file = (IIndexFragmentFile) iIndexFile;
|
||||||
for (int j = 0; j < fPrimaryFragmentCount; j++) {
|
for (IIndexFragment fragment : fFragments) {
|
||||||
IIndexInclude[] includedBy= fFragments[j].findIncludedBy(file);
|
IIndexInclude[] includedBy= fragment.findIncludedBy(file);
|
||||||
for (IIndexInclude include : includedBy) {
|
for (IIndexInclude include : includedBy) {
|
||||||
final IIndexFile includer = include.getIncludedBy();
|
final IIndexFile includer = include.getIncludedBy();
|
||||||
FileContentKey key= new FileContentKey(linkageID, includer.getLocation(), includer.getSignificantMacros());
|
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);
|
monitor.beginTask(Messages.CIndex_FindBindingsTask_label, fFragments.length * linkages.length);
|
||||||
for (ILinkage linkage : linkages) {
|
for (ILinkage linkage : linkages) {
|
||||||
if (filter.acceptLinkage(linkage)) {
|
if (filter.acceptLinkage(linkage)) {
|
||||||
IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
|
IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fFragments.length][];
|
||||||
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
for (int i = 0; i < fFragments.length; i++) {
|
||||||
try {
|
try {
|
||||||
IBinding[] part = fFragments[i].findBindings(names,
|
IBinding[] part = fFragments[i].findBindings(names,
|
||||||
retargetFilter(linkage, filter), new SubProgressMonitor(monitor, 1));
|
retargetFilter(linkage, filter), new SubProgressMonitor(monitor, 1));
|
||||||
|
@ -479,8 +486,8 @@ public class CIndex implements IIndex {
|
||||||
if (SPECIALCASE_SINGLES && fFragments.length == 1) {
|
if (SPECIALCASE_SINGLES && fFragments.length == 1) {
|
||||||
return fFragments[0].adaptBinding(binding);
|
return fFragments[0].adaptBinding(binding);
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
for (IIndexFragment fragment : fFragments) {
|
||||||
IIndexFragmentBinding adaptedBinding= fFragments[i].adaptBinding(binding);
|
IIndexFragmentBinding adaptedBinding= fragment.adaptBinding(binding);
|
||||||
if (adaptedBinding != null) {
|
if (adaptedBinding != null) {
|
||||||
return getCompositesFactory(binding.getLinkage().getLinkageID()).getCompositeBinding(adaptedBinding);
|
return getCompositesFactory(binding.getLinkage().getLinkageID()).getCompositeBinding(adaptedBinding);
|
||||||
}
|
}
|
||||||
|
@ -517,10 +524,8 @@ public class CIndex implements IIndex {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexFragment[] getPrimaryFragments() {
|
public IIndexFragment[] getFragments() {
|
||||||
IIndexFragment[] result= new IIndexFragment[fPrimaryFragmentCount];
|
return fFragments;
|
||||||
System.arraycopy(fFragments, 0, result, 0, fPrimaryFragmentCount);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexFragmentBinding[] findEquivalentBindings(IBinding binding) throws CoreException {
|
public IIndexFragmentBinding[] findEquivalentBindings(IBinding binding) throws CoreException {
|
||||||
|
@ -538,19 +543,19 @@ public class CIndex implements IIndex {
|
||||||
switch (linkageID) {
|
switch (linkageID) {
|
||||||
case ILinkage.CPP_LINKAGE_ID:
|
case ILinkage.CPP_LINKAGE_ID:
|
||||||
if (cppCF == null) {
|
if (cppCF == null) {
|
||||||
cppCF = new CPPCompositesFactory(new CIndex(fFragments, fFragments.length));
|
cppCF = new CPPCompositesFactory(this);
|
||||||
}
|
}
|
||||||
return cppCF;
|
return cppCF;
|
||||||
|
|
||||||
case ILinkage.C_LINKAGE_ID:
|
case ILinkage.C_LINKAGE_ID:
|
||||||
if (cCF == null) {
|
if (cCF == null) {
|
||||||
cCF = new CCompositesFactory(new CIndex(fFragments, fFragments.length));
|
cCF = new CCompositesFactory(this);
|
||||||
}
|
}
|
||||||
return cCF;
|
return cCF;
|
||||||
|
|
||||||
case ILinkage.FORTRAN_LINKAGE_ID:
|
case ILinkage.FORTRAN_LINKAGE_ID:
|
||||||
if (fCF == null) {
|
if (fCF == null) {
|
||||||
fCF = new CCompositesFactory(new CIndex(fFragments, fFragments.length));
|
fCF = new CCompositesFactory(this);
|
||||||
}
|
}
|
||||||
// This is a placeholder - it will throw CompositingNotImplementedError
|
// This is a placeholder - it will throw CompositingNotImplementedError
|
||||||
// if non-empty (non-c) results are returned by a fragment
|
// if non-empty (non-c) results are returned by a fragment
|
||||||
|
@ -582,8 +587,8 @@ public class CIndex implements IIndex {
|
||||||
ILinkage[] linkages = Linkage.getIndexerLinkages();
|
ILinkage[] linkages = Linkage.getIndexerLinkages();
|
||||||
for (ILinkage linkage : linkages) {
|
for (ILinkage linkage : linkages) {
|
||||||
if (filter.acceptLinkage(linkage)) {
|
if (filter.acceptLinkage(linkage)) {
|
||||||
IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
|
IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fFragments.length][];
|
||||||
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
for (int i = 0; i < fFragments.length; i++) {
|
||||||
try {
|
try {
|
||||||
IBinding[] part = fFragments[i].findBindingsForPrefix(prefix, filescope,
|
IBinding[] part = fFragments[i].findBindingsForPrefix(prefix, filescope,
|
||||||
retargetFilter(linkage, filter), monitor);
|
retargetFilter(linkage, filter), monitor);
|
||||||
|
@ -612,8 +617,8 @@ public class CIndex implements IIndex {
|
||||||
ILinkage[] linkages = Linkage.getIndexerLinkages();
|
ILinkage[] linkages = Linkage.getIndexerLinkages();
|
||||||
for (ILinkage linkage : linkages) {
|
for (ILinkage linkage : linkages) {
|
||||||
if (filter.acceptLinkage(linkage)) {
|
if (filter.acceptLinkage(linkage)) {
|
||||||
IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
|
IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fFragments.length][];
|
||||||
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
for (int i = 0; i < fFragments.length; i++) {
|
||||||
try {
|
try {
|
||||||
IBinding[] part = fFragments[i].findBindingsForContentAssist(prefix,
|
IBinding[] part = fFragments[i].findBindingsForContentAssist(prefix,
|
||||||
filescope, retargetFilter(linkage, filter), monitor);
|
filescope, retargetFilter(linkage, filter), monitor);
|
||||||
|
@ -642,8 +647,8 @@ public class CIndex implements IIndex {
|
||||||
ILinkage[] linkages = Linkage.getIndexerLinkages();
|
ILinkage[] linkages = Linkage.getIndexerLinkages();
|
||||||
for (ILinkage linkage : linkages) {
|
for (ILinkage linkage : linkages) {
|
||||||
if (filter.acceptLinkage(linkage)) {
|
if (filter.acceptLinkage(linkage)) {
|
||||||
IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
|
IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fFragments.length][];
|
||||||
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
for (int i = 0; i < fFragments.length; i++) {
|
||||||
try {
|
try {
|
||||||
IBinding[] part = fFragments[i].findBindings(name, filescope,
|
IBinding[] part = fFragments[i].findBindings(name, filescope,
|
||||||
retargetFilter(linkage, filter), monitor);
|
retargetFilter(linkage, filter), monitor);
|
||||||
|
@ -683,10 +688,10 @@ public class CIndex implements IIndex {
|
||||||
List<IIndexMacro> result = new ArrayList<IIndexMacro>();
|
List<IIndexMacro> result = new ArrayList<IIndexMacro>();
|
||||||
HashSet<IIndexFileLocation> handledIFLs= new HashSet<IIndexFileLocation>();
|
HashSet<IIndexFileLocation> handledIFLs= new HashSet<IIndexFileLocation>();
|
||||||
monitor.beginTask(Messages.CIndex_FindBindingsTask_label, fFragments.length);
|
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>();
|
HashSet<IIndexFile> allowedFiles= new HashSet<IIndexFile>();
|
||||||
try {
|
try {
|
||||||
IIndexMacro[] macros= fFragments[i].findMacros(name, isPrefix, caseSensitive, filter,
|
IIndexMacro[] macros= fragment.findMacros(name, isPrefix, caseSensitive, filter,
|
||||||
new SubProgressMonitor(monitor, 1));
|
new SubProgressMonitor(monitor, 1));
|
||||||
for (IIndexMacro indexMacro : macros) {
|
for (IIndexMacro indexMacro : macros) {
|
||||||
IIndexFile file= indexMacro.getFile();
|
IIndexFile file= indexMacro.getFile();
|
||||||
|
@ -759,8 +764,8 @@ public class CIndex implements IIndex {
|
||||||
return fFragments[0].getInlineNamespaces();
|
return fFragments[0].getInlineNamespaces();
|
||||||
}
|
}
|
||||||
|
|
||||||
IIndexFragmentBinding[][] preresult = new IIndexFragmentBinding[fPrimaryFragmentCount][];
|
IIndexFragmentBinding[][] preresult = new IIndexFragmentBinding[fFragments.length][];
|
||||||
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
for (int i = 0; i < fFragments.length; i++) {
|
||||||
IIndexScope[] raw = fFragments[i].getInlineNamespaces();
|
IIndexScope[] raw = fFragments[i].getInlineNamespaces();
|
||||||
IIndexFragmentBinding[] arr = preresult[i] = new IIndexFragmentBinding[raw.length];
|
IIndexFragmentBinding[] arr = preresult[i] = new IIndexFragmentBinding[raw.length];
|
||||||
for (int j = 0; j < raw.length; j++) {
|
for (int j = 0; j < raw.length; j++) {
|
||||||
|
@ -784,17 +789,19 @@ public class CIndex implements IIndex {
|
||||||
private final IIndexFileLocation location;
|
private final IIndexFileLocation location;
|
||||||
private final int linkageID;
|
private final int linkageID;
|
||||||
private final int offset;
|
private final int offset;
|
||||||
|
private final boolean inWritableFragment;
|
||||||
|
|
||||||
NameKey(IIndexFragmentName name) throws CoreException {
|
NameKey(IIndexFragmentName name, boolean writable) throws CoreException {
|
||||||
IIndexFile file = name.getFile();
|
IIndexFile file = name.getFile();
|
||||||
location = file.getLocation();
|
location = file.getLocation();
|
||||||
linkageID = file.getLinkageID();
|
linkageID = file.getLinkageID();
|
||||||
offset = name.getNodeOffset();
|
offset = name.getNodeOffset();
|
||||||
|
inWritableFragment= writable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return (location.hashCode() * 31 + linkageID) * 31 + offset;
|
return location.hashCode() * 31 + linkageID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -806,7 +813,8 @@ public class CIndex implements IIndex {
|
||||||
if (getClass() != obj.getClass())
|
if (getClass() != obj.getClass())
|
||||||
return false;
|
return false;
|
||||||
NameKey other = (NameKey) obj;
|
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;
|
return false;
|
||||||
if (linkageID != other.linkageID)
|
if (linkageID != other.linkageID)
|
||||||
return false;
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* 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.IASTPreprocessorIncludeStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
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.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.core.parser.ISignificantMacros;
|
import org.eclipse.cdt.core.parser.ISignificantMacros;
|
||||||
import org.eclipse.cdt.internal.core.pdom.ASTFilePathResolver;
|
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,
|
* 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.
|
* 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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -13,12 +13,16 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.index;
|
package org.eclipse.cdt.internal.core.index;
|
||||||
|
|
||||||
|
import static org.eclipse.cdt.core.index.IIndexManager.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
|
@ -40,11 +44,11 @@ import org.eclipse.osgi.util.NLS;
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public class IndexFactory {
|
public class IndexFactory {
|
||||||
private static final int ADD_DEPENDENCIES = IIndexManager.ADD_DEPENDENCIES;
|
private static final int ALL_FRAGMENT_OPTIONS = ADD_EXTENSION_FRAGMENTS_ADD_IMPORT
|
||||||
private static final int ADD_DEPENDENT = IIndexManager.ADD_DEPENDENT;
|
| ADD_EXTENSION_FRAGMENTS_CALL_HIERARCHY | ADD_EXTENSION_FRAGMENTS_CONTENT_ASSIST
|
||||||
private static final int SKIP_PROVIDED = IIndexManager.SKIP_PROVIDED;
|
| ADD_EXTENSION_FRAGMENTS_INCLUDE_BROWSER | ADD_EXTENSION_FRAGMENTS_NAVIGATION
|
||||||
private static final int ADD_EXTENSION_FRAGMENTS = IIndexManager.ADD_EXTENSION_FRAGMENTS;
|
| ADD_EXTENSION_FRAGMENTS_SEARCH | ADD_EXTENSION_FRAGMENTS_TYPE_HIERARCHY;
|
||||||
|
|
||||||
private PDOMManager fPDOMManager;
|
private PDOMManager fPDOMManager;
|
||||||
|
|
||||||
public IndexFactory(PDOMManager manager) {
|
public IndexFactory(PDOMManager manager) {
|
||||||
|
@ -56,21 +60,18 @@ public class IndexFactory {
|
||||||
|
|
||||||
boolean addDependencies= (options & ADD_DEPENDENCIES) != 0;
|
boolean addDependencies= (options & ADD_DEPENDENCIES) != 0;
|
||||||
boolean addDependent= (options & ADD_DEPENDENT) != 0;
|
boolean addDependent= (options & ADD_DEPENDENT) != 0;
|
||||||
boolean skipProvided= (options & SKIP_PROVIDED) != 0;
|
int fragmentUsage= options & ALL_FRAGMENT_OPTIONS;
|
||||||
boolean addExtensionFragments= (options & ADD_EXTENSION_FRAGMENTS) != 0;
|
|
||||||
|
|
||||||
HashMap<IProject, Integer> map= new HashMap<IProject, Integer>();
|
Collection<ICProject> indexProjects=
|
||||||
Collection<ICProject> selectedProjects= getProjects(projects, addDependencies, addDependent,
|
getProjects(projects, addDependencies, addDependent, new HashSet<IProject>());
|
||||||
map, new Integer(1));
|
|
||||||
|
|
||||||
HashMap<String, IIndexFragment> fragments= new LinkedHashMap<String, IIndexFragment>();
|
HashMap<String, IIndexFragment> fragments= new LinkedHashMap<String, IIndexFragment>();
|
||||||
for (ICProject cproject : selectedProjects) {
|
for (ICProject cproject : indexProjects) {
|
||||||
IIndexFragment pdom= fPDOMManager.getPDOM(cproject);
|
IIndexFragment pdom= fPDOMManager.getPDOM(cproject);
|
||||||
if (pdom != null) {
|
if (pdom != null) {
|
||||||
safeAddFragment(fragments, pdom);
|
safeAddFragment(fragments, pdom);
|
||||||
|
if (fragmentUsage != 0) {
|
||||||
if (!skipProvided) {
|
safeAddProvidedFragments(cproject, fragments, fragmentUsage);
|
||||||
safeAddProvidedFragments(cproject, fragments, addExtensionFragments);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,105 +79,58 @@ public class IndexFactory {
|
||||||
return EmptyCIndex.INSTANCE;
|
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();
|
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 {
|
public IWritableIndex getWritableIndex(ICProject project) throws CoreException {
|
||||||
Map<String, IIndexFragment> readOnlyFrag= new LinkedHashMap<String, IIndexFragment>();
|
|
||||||
IWritableIndexFragment pdom= (IWritableIndexFragment) fPDOMManager.getPDOM(project);
|
IWritableIndexFragment pdom= (IWritableIndexFragment) fPDOMManager.getPDOM(project);
|
||||||
if (pdom == null) {
|
if (pdom == null) {
|
||||||
throw new CoreException(CCorePlugin.createStatus(
|
throw new CoreException(CCorePlugin.createStatus(
|
||||||
NLS.bind(Messages.IndexFactory_errorNoSuchPDOM0, project.getElementName())));
|
NLS.bind(Messages.IndexFactory_errorNoSuchPDOM0, project.getElementName())));
|
||||||
}
|
}
|
||||||
safeAddProvidedFragments(project, readOnlyFrag, false);
|
return new WritableCIndex(pdom);
|
||||||
|
|
||||||
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()]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Collection<ICProject> getProjects(ICProject[] projects, boolean addDependencies,
|
private Collection<ICProject> getProjects(ICProject[] projects, boolean addDependencies,
|
||||||
boolean addDependent, HashMap<IProject, Integer> map, Integer markWith) {
|
boolean addDependent, Set<IProject> handled) {
|
||||||
List<IProject> projectsToSearch= new ArrayList<IProject>();
|
List<ICProject> result= new ArrayList<ICProject>();
|
||||||
|
|
||||||
for (ICProject cproject : projects) {
|
for (ICProject cproject : projects) {
|
||||||
IProject project= cproject.getProject();
|
checkAddProject(cproject, handled, result);
|
||||||
checkAddProject(project, map, projectsToSearch, markWith);
|
|
||||||
projectsToSearch.add(project);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addDependencies || addDependent) {
|
if (addDependencies || addDependent) {
|
||||||
for (int i= 0; i < projectsToSearch.size(); i++) {
|
final CoreModel cm= CoreModel.getDefault();
|
||||||
IProject project= projectsToSearch.get(i);
|
for (int i= 0; i < result.size(); i++) {
|
||||||
IProject[] nextLevel;
|
ICProject cproject= result.get(i);
|
||||||
|
IProject project= cproject.getProject();
|
||||||
try {
|
try {
|
||||||
if (addDependencies) {
|
if (addDependencies) {
|
||||||
nextLevel = project.getReferencedProjects();
|
for (IProject rp : project.getReferencedProjects()) {
|
||||||
for (int j = 0; j < nextLevel.length; j++) {
|
checkAddProject(cm.create(rp), handled, result);
|
||||||
checkAddProject(nextLevel[j], map, projectsToSearch, markWith);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (addDependent) {
|
if (addDependent) {
|
||||||
nextLevel= project.getReferencingProjects();
|
for (IProject rp : project.getReferencingProjects()) {
|
||||||
for (int j = 0; j < nextLevel.length; j++) {
|
checkAddProject(cm.create(rp), handled, result);
|
||||||
checkAddProject(nextLevel[j], map, projectsToSearch, markWith);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
// silently ignore
|
// silently ignore
|
||||||
map.put(project, new Integer(0));
|
handled.add(project);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkAddProject(IProject project, HashMap<IProject, Integer> map,
|
private void checkAddProject(ICProject cproject, Set<IProject> handled, List<ICProject> target) {
|
||||||
List<IProject> projectsToSearch, Integer markWith) {
|
if (cproject != null) {
|
||||||
if (map.get(project) == null) {
|
IProject project= cproject.getProject();
|
||||||
if (project.isOpen()) {
|
if (handled.add(project) && project.isOpen())
|
||||||
map.put(project, markWith);
|
target.add(cproject);
|
||||||
projectsToSearch.add(project);
|
}
|
||||||
} else {
|
|
||||||
map.put(project, new Integer(0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -208,17 +162,17 @@ public class IndexFactory {
|
||||||
* the CIndex extension point for the specified ICProject.
|
* the CIndex extension point for the specified ICProject.
|
||||||
* @param cproject The project to get the provided index fragments for.
|
* @param cproject The project to get the provided index fragments for.
|
||||||
* @param fragments
|
* @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,
|
private void safeAddProvidedFragments(ICProject cproject, Map<String, IIndexFragment> fragments,
|
||||||
boolean includeNonPDOMFragments) {
|
int usage) {
|
||||||
ICProjectDescription pd= CoreModel.getDefault().getProjectDescription(cproject.getProject(), false);
|
ICProjectDescription pd= CoreModel.getDefault().getProjectDescription(cproject.getProject(), false);
|
||||||
if (pd != null) {
|
if (pd != null) {
|
||||||
IndexProviderManager ipm = CCoreInternals.getPDOMManager().getIndexProviderManager();
|
IndexProviderManager ipm = CCoreInternals.getPDOMManager().getIndexProviderManager();
|
||||||
ICConfigurationDescription cfg= pd.getDefaultSettingConfiguration();
|
ICConfigurationDescription cfg= pd.getDefaultSettingConfiguration();
|
||||||
if (cfg != null) {
|
if (cfg != null) {
|
||||||
try {
|
try {
|
||||||
IIndexFragment[] pFragments= ipm.getProvidedIndexFragments(cfg, includeNonPDOMFragments);
|
IIndexFragment[] pFragments= ipm.getProvidedIndexFragments(cfg, usage);
|
||||||
for (IIndexFragment fragment : pFragments) {
|
for (IIndexFragment fragment : pFragments) {
|
||||||
safeAddFragment(fragments, fragment);
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* 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.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
|
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.index.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.core.parser.ISignificantMacros;
|
import org.eclipse.cdt.core.parser.ISignificantMacros;
|
||||||
import org.eclipse.cdt.internal.core.pdom.ASTFilePathResolver;
|
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;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
public class WritableCIndex extends CIndex implements IWritableIndex {
|
public class WritableCIndex extends CIndex implements IWritableIndex {
|
||||||
final private IWritableIndexFragment fWritableFragment;
|
|
||||||
private boolean fIsWriteLocked= false;
|
private boolean fIsWriteLocked= false;
|
||||||
private Object fThread;
|
private Object fThread;
|
||||||
|
|
||||||
public WritableCIndex(IWritableIndexFragment writable, IIndexFragment[] readonly) {
|
public WritableCIndex(IWritableIndexFragment writable) {
|
||||||
super(concat(writable, readonly));
|
super(new IWritableIndexFragment[] {writable});
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IWritableIndexFragment getWritableFragment() {
|
public IWritableIndexFragment getWritableFragment() {
|
||||||
return fWritableFragment;
|
return (IWritableIndexFragment) getFragments()[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IIndexFragmentFile getWritableFile(int linkageID, IIndexFileLocation location,
|
public IIndexFragmentFile getWritableFile(int linkageID, IIndexFileLocation location,
|
||||||
ISignificantMacros macroDictionary) throws CoreException {
|
ISignificantMacros macroDictionary) throws CoreException {
|
||||||
return fWritableFragment.getFile(linkageID, location, macroDictionary);
|
return (IIndexFragmentFile) super.getFile(linkageID, location, macroDictionary);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IIndexFragmentFile[] getWritableFiles(int linkageID, IIndexFileLocation location) throws CoreException {
|
public IIndexFragmentFile[] getWritableFiles(int linkageID, IIndexFileLocation location) throws CoreException {
|
||||||
return fWritableFragment.getFiles(linkageID, location);
|
return getWritableFragment().getFiles(linkageID, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IIndexFragmentFile[] getWritableFiles(IIndexFileLocation location) throws CoreException {
|
public IIndexFragmentFile[] getWritableFiles(IIndexFileLocation location) throws CoreException {
|
||||||
return fWritableFragment.getFiles(location);
|
return getWritableFragment().getFiles(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IIndexFragmentFile addFile(int linkageID, IIndexFileLocation location,
|
public IIndexFragmentFile addFile(int linkageID, IIndexFileLocation location,
|
||||||
ISignificantMacros macroDictionary) throws CoreException {
|
ISignificantMacros macroDictionary) throws CoreException {
|
||||||
return fWritableFragment.addFile(linkageID, location, macroDictionary);
|
return getWritableFragment().addFile(linkageID, location, macroDictionary);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IIndexFragmentFile addUncommittedFile(int linkageID, IIndexFileLocation location,
|
public IIndexFragmentFile addUncommittedFile(int linkageID, IIndexFileLocation location,
|
||||||
ISignificantMacros macroDictionary) throws CoreException {
|
ISignificantMacros macroDictionary) throws CoreException {
|
||||||
return fWritableFragment.addUncommittedFile(linkageID, location, macroDictionary);
|
return getWritableFragment().addUncommittedFile(linkageID, location, macroDictionary);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IIndexFragmentFile commitUncommittedFile() throws CoreException {
|
public IIndexFragmentFile commitUncommittedFile() throws CoreException {
|
||||||
return fWritableFragment.commitUncommittedFile();
|
return getWritableFragment().commitUncommittedFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clearUncommittedFile() throws CoreException {
|
public void clearUncommittedFile() throws CoreException {
|
||||||
fWritableFragment.clearUncommittedFile();
|
getWritableFragment().clearUncommittedFile();
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isWritableFragment(IIndexFragment frag) {
|
|
||||||
return frag == fWritableFragment;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFileContent(IIndexFragmentFile file, int linkageID, IncludeInformation[] includes,
|
public void setFileContent(IIndexFragmentFile file, int linkageID, IncludeInformation[] includes,
|
||||||
IASTPreprocessorStatement[] macros, IASTName[][] names, ASTFilePathResolver resolver,
|
IASTPreprocessorStatement[] macros, IASTName[][] names, ASTFilePathResolver resolver,
|
||||||
YieldableIndexLock lock) throws CoreException, InterruptedException {
|
YieldableIndexLock lock) throws CoreException, InterruptedException {
|
||||||
IIndexFragment indexFragment = file.getIndexFragment();
|
assert getWritableFragment() == file.getIndexFragment();
|
||||||
if (!isWritableFragment(indexFragment)) {
|
|
||||||
assert false : "Attempt to update file of read-only fragment"; //$NON-NLS-1$
|
for (IncludeInformation include : includes) {
|
||||||
} else {
|
if (include.fLocation != null) {
|
||||||
for (IncludeInformation include : includes) {
|
include.fTargetFile= addFile(linkageID, include.fLocation,
|
||||||
if (include.fLocation != null) {
|
include.fSignificantMacros);
|
||||||
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
|
@Override
|
||||||
public void clear() throws CoreException {
|
public void clear() throws CoreException {
|
||||||
fWritableFragment.clear();
|
getWritableFragment().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isWritableFile(IIndexFile file) {
|
|
||||||
return file instanceof IIndexFragmentFile &&
|
|
||||||
isWritableFragment(((IIndexFragmentFile)file).getIndexFragment());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clearFile(IIndexFragmentFile file) throws CoreException {
|
public void clearFile(IIndexFragmentFile file) throws CoreException {
|
||||||
IIndexFragment indexFragment = file.getIndexFragment();
|
getWritableFragment().clearFile(file);
|
||||||
if (!isWritableFragment(indexFragment)) {
|
|
||||||
assert false : "Attempt to clear file of read-only fragment"; //$NON-NLS-1$
|
|
||||||
} else {
|
|
||||||
((IWritableIndexFragment) indexFragment).clearFile(file);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -145,7 +117,7 @@ public class WritableCIndex extends CIndex implements IWritableIndex {
|
||||||
checkThread();
|
checkThread();
|
||||||
assert !fIsWriteLocked: "Multiple write locks is not allowed"; //$NON-NLS-1$
|
assert !fIsWriteLocked: "Multiple write locks is not allowed"; //$NON-NLS-1$
|
||||||
|
|
||||||
fWritableFragment.acquireWriteLock(getReadLockCount());
|
getWritableFragment().acquireWriteLock(getReadLockCount());
|
||||||
fIsWriteLocked= true;
|
fIsWriteLocked= true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +139,7 @@ public class WritableCIndex extends CIndex implements IWritableIndex {
|
||||||
}
|
}
|
||||||
|
|
||||||
fIsWriteLocked= false;
|
fIsWriteLocked= false;
|
||||||
fWritableFragment.releaseWriteLock(establishReadlockCount, flush);
|
getWritableFragment().releaseWriteLock(establishReadlockCount, flush);
|
||||||
|
|
||||||
if (establishReadlockCount == 0) {
|
if (establishReadlockCount == 0) {
|
||||||
fThread= null;
|
fThread= null;
|
||||||
|
@ -191,17 +163,17 @@ public class WritableCIndex extends CIndex implements IWritableIndex {
|
||||||
@Override
|
@Override
|
||||||
public void flush() throws CoreException {
|
public void flush() throws CoreException {
|
||||||
assert !fIsWriteLocked;
|
assert !fIsWriteLocked;
|
||||||
fWritableFragment.flush();
|
getWritableFragment().flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getDatabaseSizeBytes() {
|
public long getDatabaseSizeBytes() {
|
||||||
return fWritableFragment.getDatabaseSizeBytes();
|
return getWritableFragment().getDatabaseSizeBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void transferIncluders(IIndexFragmentFile source, IIndexFragmentFile target) throws CoreException {
|
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();
|
throw new IllegalArgumentException();
|
||||||
if (source.equals(target))
|
if (source.equals(target))
|
||||||
return;
|
return;
|
||||||
|
@ -210,7 +182,7 @@ public class WritableCIndex extends CIndex implements IWritableIndex {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void transferContext(IIndexFragmentFile source, IIndexFragmentFile target) throws CoreException {
|
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();
|
throw new IllegalArgumentException();
|
||||||
if (source.equals(target))
|
if (source.equals(target))
|
||||||
return;
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -12,7 +12,15 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.index.provider;
|
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.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexManager;
|
||||||
import org.eclipse.cdt.core.index.provider.IIndexProvider;
|
import org.eclipse.cdt.core.index.provider.IIndexProvider;
|
||||||
import org.eclipse.cdt.core.index.provider.IReadOnlyPDOMProvider;
|
import org.eclipse.cdt.core.index.provider.IReadOnlyPDOMProvider;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
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.ICElementDelta;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.IElementChangedListener;
|
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.core.settings.model.ICConfigurationDescription;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
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.eclipse.osgi.util.NLS;
|
||||||
import org.osgi.framework.Version;
|
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
|
* The IndexProviderManager is responsible for maintaining the set of index
|
||||||
* fragments contributed via the CIndex extension point.
|
* fragments contributed via the CIndex extension point.
|
||||||
|
@ -66,10 +66,21 @@ import java.util.Set;
|
||||||
public final class IndexProviderManager implements IElementChangedListener {
|
public final class IndexProviderManager implements IElementChangedListener {
|
||||||
private static final String ELEMENT_RO_PDOM_PROVIDER= "ReadOnlyPDOMProvider"; //$NON-NLS-1$
|
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 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 Map<ProvisionMapKey, Boolean> provisionMap;
|
||||||
private Set<String> compatibleFragmentUnavailable;
|
private Set<String> compatibleFragmentUnavailable;
|
||||||
private VersionRange pdomVersionRange;
|
private VersionRange pdomVersionRange;
|
||||||
|
@ -92,15 +103,15 @@ public final class IndexProviderManager implements IElementChangedListener {
|
||||||
* @param pdomVersionRange
|
* @param pdomVersionRange
|
||||||
*/
|
*/
|
||||||
public void reset(VersionRange pdomVersionRange) {
|
public void reset(VersionRange pdomVersionRange) {
|
||||||
this.pdomFragmentProviders= new IIndexFragmentProvider[0];
|
this.fragmentProviders= new IIndexFragmentProvider[0];
|
||||||
this.provisionMap= new HashMap<ProvisionMapKey, Boolean>();
|
this.provisionMap= new HashMap<ProvisionMapKey, Boolean>();
|
||||||
this.pdomVersionRange= pdomVersionRange;
|
this.pdomVersionRange= pdomVersionRange;
|
||||||
this.compatibleFragmentUnavailable= new HashSet<String>();
|
this.compatibleFragmentUnavailable= new HashSet<String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startup() {
|
public void startup() {
|
||||||
List<IIndexFragmentProvider> pdomProviders = new ArrayList<IIndexFragmentProvider>();
|
List<IIndexFragmentProvider> providers = new ArrayList<IIndexFragmentProvider>();
|
||||||
List<IIndexFragmentProvider> nonPDOMProviders = new ArrayList<IIndexFragmentProvider>();
|
List<IConfigurationElement[]> usageSpecifications= new ArrayList<IConfigurationElement[]>();
|
||||||
IExtensionRegistry registry = Platform.getExtensionRegistry();
|
IExtensionRegistry registry = Platform.getExtensionRegistry();
|
||||||
IExtensionPoint indexProviders = registry.getExtensionPoint(CCorePlugin.INDEX_UNIQ_ID);
|
IExtensionPoint indexProviders = registry.getExtensionPoint(CCorePlugin.INDEX_UNIQ_ID);
|
||||||
for (IExtension extension : indexProviders.getExtensions()) {
|
for (IExtension extension : indexProviders.getExtensions()) {
|
||||||
|
@ -108,9 +119,9 @@ public final class IndexProviderManager implements IElementChangedListener {
|
||||||
for (IConfigurationElement element : extension.getConfigurationElements()) {
|
for (IConfigurationElement element : extension.getConfigurationElements()) {
|
||||||
if (ELEMENT_RO_PDOM_PROVIDER.equals(element.getName())) {
|
if (ELEMENT_RO_PDOM_PROVIDER.equals(element.getName())) {
|
||||||
Object provider = element.createExecutableExtension(ATTRIBUTE_CLASS);
|
Object provider = element.createExecutableExtension(ATTRIBUTE_CLASS);
|
||||||
|
|
||||||
if (provider instanceof IReadOnlyPDOMProvider) {
|
if (provider instanceof IReadOnlyPDOMProvider) {
|
||||||
pdomProviders.add(new ReadOnlyPDOMProviderBridge((IReadOnlyPDOMProvider) provider));
|
providers.add(new ReadOnlyPDOMProviderBridge((IReadOnlyPDOMProvider) provider));
|
||||||
|
usageSpecifications.add(element.getChildren(ELEMENT_PROVIDER_USAGE));
|
||||||
} else {
|
} else {
|
||||||
CCorePlugin.log(NLS.bind(Messages.IndexProviderManager_0,
|
CCorePlugin.log(NLS.bind(Messages.IndexProviderManager_0,
|
||||||
extension.getContributor().getName()));
|
extension.getContributor().getName()));
|
||||||
|
@ -119,12 +130,13 @@ public final class IndexProviderManager implements IElementChangedListener {
|
||||||
Object provider = element.createExecutableExtension(ATTRIBUTE_CLASS);
|
Object provider = element.createExecutableExtension(ATTRIBUTE_CLASS);
|
||||||
|
|
||||||
if (provider instanceof IIndexFragmentProvider) {
|
if (provider instanceof IIndexFragmentProvider) {
|
||||||
nonPDOMProviders.add((IIndexFragmentProvider) provider);
|
providers.add((IIndexFragmentProvider) provider);
|
||||||
|
usageSpecifications.add(element.getChildren(ELEMENT_PROVIDER_USAGE));
|
||||||
} else {
|
} else {
|
||||||
CCorePlugin.log(NLS.bind(Messages.IndexProviderManager_0,
|
CCorePlugin.log(NLS.bind(Messages.IndexProviderManager_0,
|
||||||
extension.getContributor().getName()));
|
extension.getContributor().getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
|
@ -132,8 +144,41 @@ public final class IndexProviderManager implements IElementChangedListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreModel.getDefault().addElementChangedListener(this);
|
CoreModel.getDefault().addElementChangedListener(this);
|
||||||
this.pdomFragmentProviders = pdomProviders.toArray(new IIndexFragmentProvider[pdomProviders.size()]);
|
this.fragmentProviders = providers.toArray(new IIndexFragmentProvider[providers.size()]);
|
||||||
this.nonPDOMFragmentProviders = nonPDOMProviders.toArray(new IIndexFragmentProvider[nonPDOMProviders.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
|
* @param config
|
||||||
* @return the array of IIndexFragment objects for the current state
|
* @return the array of IIndexFragment objects for the current state
|
||||||
*/
|
*/
|
||||||
public IIndexFragment[] getProvidedIndexFragments(ICConfigurationDescription config,
|
public IIndexFragment[] getProvidedIndexFragments(ICConfigurationDescription config, int usage) throws CoreException {
|
||||||
boolean includeNonPDOMFragments) throws CoreException {
|
|
||||||
Map<String, IIndexFragment> id2fragment = new HashMap<String, IIndexFragment>();
|
Map<String, IIndexFragment> id2fragment = new HashMap<String, IIndexFragment>();
|
||||||
|
|
||||||
IProject project= config.getProjectDescription().getProject();
|
IProject project= config.getProjectDescription().getProject();
|
||||||
IIndexFragmentProvider[][] groups = includeNonPDOMFragments ?
|
for (int i = 0; i < fragmentProviders.length; i++) {
|
||||||
new IIndexFragmentProvider[][] { pdomFragmentProviders, nonPDOMFragmentProviders } :
|
if ((fragmentProviderUsage[i] & usage) != 0) {
|
||||||
new IIndexFragmentProvider[][] { pdomFragmentProviders };
|
IIndexFragmentProvider provider= fragmentProviders[i];
|
||||||
for (IIndexFragmentProvider[] group : groups) {
|
|
||||||
for (IIndexFragmentProvider provider : group) {
|
|
||||||
try {
|
try {
|
||||||
if (providesForProject(provider, project)) {
|
if (providesForProject(provider, project)) {
|
||||||
IIndexFragment[] fragments= provider.getIndexFragments(config);
|
IIndexFragment[] fragments= provider.getIndexFragments(config);
|
||||||
|
@ -180,7 +222,8 @@ public final class IndexProviderManager implements IElementChangedListener {
|
||||||
String key= entry.getKey();
|
String key= entry.getKey();
|
||||||
if (!compatibleFragmentUnavailable.contains(key)) {
|
if (!compatibleFragmentUnavailable.contains(key)) {
|
||||||
String msg= NLS.bind(
|
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));
|
CCorePlugin.log(new Status(IStatus.WARNING, CCorePlugin.PLUGIN_ID, msg));
|
||||||
compatibleFragmentUnavailable.add(key);
|
compatibleFragmentUnavailable.add(key);
|
||||||
}
|
}
|
||||||
|
@ -191,6 +234,45 @@ public final class IndexProviderManager implements IElementChangedListener {
|
||||||
return preresult.toArray(new IIndexFragment[preresult.size()]);
|
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.
|
* Returns the version range supported by the format identified by the specified formatID.
|
||||||
* @param formatID
|
* @param formatID
|
||||||
|
@ -276,10 +358,17 @@ public final class IndexProviderManager implements IElementChangedListener {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IIndexFragmentProvider[] newAllProviders = new IIndexFragmentProvider[pdomFragmentProviders.length + 1];
|
final int length = fragmentProviders.length;
|
||||||
System.arraycopy(pdomFragmentProviders, 0, newAllProviders, 0, pdomFragmentProviders.length);
|
|
||||||
newAllProviders[pdomFragmentProviders.length] = (IIndexFragmentProvider) provider;
|
IIndexFragmentProvider[] newProviders = new IIndexFragmentProvider[length + 1];
|
||||||
pdomFragmentProviders = newAllProviders;
|
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
|
* @param provider
|
||||||
*/
|
*/
|
||||||
public void removeIndexProvider(IIndexProvider provider) {
|
public void removeIndexProvider(IIndexProvider provider) {
|
||||||
ArrayUtil.remove(pdomFragmentProviders, provider);
|
for (int i = 0; i < fragmentProviders.length; i++) {
|
||||||
if (pdomFragmentProviders[pdomFragmentProviders.length - 1] == null) {
|
if (fragmentProviders[i] == provider) {
|
||||||
IIndexFragmentProvider[] newAllProviders = new IIndexFragmentProvider[pdomFragmentProviders.length - 1];
|
final int length = fragmentProviders.length;
|
||||||
System.arraycopy(pdomFragmentProviders, 0, newAllProviders, 0, pdomFragmentProviders.length - 1);
|
IIndexFragmentProvider[] newProviders = new IIndexFragmentProvider[length - 1];
|
||||||
pdomFragmentProviders= newAllProviders;
|
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
|
# Symbian Software Limited - initial API and implementation
|
||||||
###############################################################################
|
###############################################################################
|
||||||
IndexProviderManager_0=Ignoring unrecognized implementation of IIndexProvider contributed by {0}
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* 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.index.IIndexLocationConverter;
|
||||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
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.index.WritableCIndex;
|
||||||
import org.eclipse.cdt.internal.core.pdom.WritablePDOM;
|
import org.eclipse.cdt.internal.core.pdom.WritablePDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
|
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
|
||||||
|
@ -55,7 +54,7 @@ public class StandaloneFastIndexer extends StandaloneIndexer {
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public StandaloneFastIndexer(File writableIndexFile, IIndexLocationConverter converter, Map<String, IPDOMLinkageFactory> linkageFactoryMappings,
|
public StandaloneFastIndexer(File writableIndexFile, IIndexLocationConverter converter, Map<String, IPDOMLinkageFactory> linkageFactoryMappings,
|
||||||
IScannerInfo scanner, FileEncodingRegistry fileEncodingRegistry, ILanguageMapper mapper, IParserLogService log) throws CoreException {
|
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);
|
false, mapper, log, scanner, fileEncodingRegistry);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -72,7 +71,7 @@ public class StandaloneFastIndexer extends StandaloneIndexer {
|
||||||
*/
|
*/
|
||||||
public StandaloneFastIndexer(File writableIndexFile, IIndexLocationConverter converter, Map<String, IPDOMLinkageFactory> linkageFactoryMappings,
|
public StandaloneFastIndexer(File writableIndexFile, IIndexLocationConverter converter, Map<String, IPDOMLinkageFactory> linkageFactoryMappings,
|
||||||
IStandaloneScannerInfoProvider scannerProvider, FileEncodingRegistry fileEncodingRegistry, ILanguageMapper mapper, IParserLogService log) throws CoreException {
|
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);
|
false, mapper, log, scannerProvider, fileEncodingRegistry);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -88,7 +87,7 @@ public class StandaloneFastIndexer extends StandaloneIndexer {
|
||||||
*/
|
*/
|
||||||
public StandaloneFastIndexer(File writableIndexFile, IIndexLocationConverter converter, Map<String, IPDOMLinkageFactory> linkageFactoryMappings,
|
public StandaloneFastIndexer(File writableIndexFile, IIndexLocationConverter converter, Map<String, IPDOMLinkageFactory> linkageFactoryMappings,
|
||||||
FileEncodingRegistry fileEncodingRegistry, ILanguageMapper mapper, IParserLogService log) throws CoreException {
|
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);
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* 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.IParserLogService;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
import org.eclipse.cdt.internal.core.dom.AbstractCodeReaderFactory;
|
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.index.WritableCIndex;
|
||||||
import org.eclipse.cdt.internal.core.pdom.WritablePDOM;
|
import org.eclipse.cdt.internal.core.pdom.WritablePDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
|
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
|
||||||
|
@ -61,7 +60,7 @@ public class StandaloneFullIndexer extends StandaloneIndexer{
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public StandaloneFullIndexer(File writableIndexFile, IIndexLocationConverter converter, Map<String, IPDOMLinkageFactory> linkageFactoryMappings,
|
public StandaloneFullIndexer(File writableIndexFile, IIndexLocationConverter converter, Map<String, IPDOMLinkageFactory> linkageFactoryMappings,
|
||||||
IScannerInfo scanner, FileEncodingRegistry fileEncodingRegistry, ILanguageMapper mapper, IParserLogService log, AbstractCodeReaderFactory codeReaderFactory) throws CoreException {
|
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);
|
false, mapper, log, scanner, fileEncodingRegistry);
|
||||||
fCodeReaderFactory = codeReaderFactory;
|
fCodeReaderFactory = codeReaderFactory;
|
||||||
}
|
}
|
||||||
|
@ -80,7 +79,7 @@ public class StandaloneFullIndexer extends StandaloneIndexer{
|
||||||
*/
|
*/
|
||||||
public StandaloneFullIndexer(File writableIndexFile, IIndexLocationConverter converter, Map<String, IPDOMLinkageFactory> linkageFactoryMappings,
|
public StandaloneFullIndexer(File writableIndexFile, IIndexLocationConverter converter, Map<String, IPDOMLinkageFactory> linkageFactoryMappings,
|
||||||
IStandaloneScannerInfoProvider scannerProvider, FileEncodingRegistry fileEncodingRegistry, ILanguageMapper mapper, IParserLogService log, AbstractCodeReaderFactory codeReaderFactory) throws CoreException {
|
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);
|
false, mapper, log, scannerProvider, fileEncodingRegistry);
|
||||||
fCodeReaderFactory = codeReaderFactory;
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -287,7 +287,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
private boolean fIndexFilesWithoutConfiguration= true;
|
private boolean fIndexFilesWithoutConfiguration= true;
|
||||||
private List<LinkageTask> fRequestsPerLinkage= new ArrayList<LinkageTask>();
|
private List<LinkageTask> fRequestsPerLinkage= new ArrayList<LinkageTask>();
|
||||||
private Map<IIndexFile, IndexFileContent> fIndexContentCache= new LRUCache<IIndexFile, IndexFileContent>(500);
|
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 Map<IIndexFileLocation, LocationTask> fOneLinkageTasks= new HashMap<IIndexFileLocation, AbstractIndexerTask.LocationTask>();
|
||||||
|
|
||||||
private Object[] fFilesToUpdate;
|
private Object[] fFilesToUpdate;
|
||||||
|
@ -951,8 +951,8 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
return ctxFile;
|
return ctxFile;
|
||||||
|
|
||||||
IIndexFragmentFile nextCtx= (IIndexFragmentFile) ctxInclude.getIncludedBy();
|
IIndexFragmentFile nextCtx= (IIndexFragmentFile) ctxInclude.getIncludedBy();
|
||||||
if (!fIndex.isWritableFile(nextCtx))
|
if (nextCtx == null)
|
||||||
return ctxFile;
|
return nextCtx;
|
||||||
|
|
||||||
// Found a recursion
|
// Found a recursion
|
||||||
if (!safeGuard.add(nextCtx))
|
if (!safeGuard.add(nextCtx))
|
||||||
|
@ -1148,13 +1148,11 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
collectOrderedFileKeys(linkageID, inclusion, enteredFiles, orderedFileKeys);
|
collectOrderedFileKeys(linkageID, inclusion, enteredFiles, orderedFileKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
IIndexFile newFile= selectIndexFile(linkageID, topIfl, ast.getSignificantMacros());
|
IIndexFragmentFile newFile= selectIndexFile(linkageID, topIfl, ast.getSignificantMacros());
|
||||||
if (ctx != null) {
|
if (ctx != null) {
|
||||||
orderedFileKeys.add(new FileInAST(null, topKey, fileContentsHash));
|
orderedFileKeys.add(new FileInAST(null, topKey, fileContentsHash));
|
||||||
if (newFile != null && fIndex.isWritableFile(newFile)) {
|
// File can be reused
|
||||||
// File can be reused
|
ctx.fNewFile= newFile;
|
||||||
ctx.fNewFile= (IIndexFragmentFile) newFile;
|
|
||||||
}
|
|
||||||
} else if (newFile == null) {
|
} else if (newFile == null) {
|
||||||
orderedFileKeys.add(new FileInAST(null, topKey, fileContentsHash));
|
orderedFileKeys.add(new FileInAST(null, topKey, fileContentsHash));
|
||||||
}
|
}
|
||||||
|
@ -1233,7 +1231,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
return fc;
|
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);
|
LinkageTask map = findRequestMap(linkageID);
|
||||||
if (map != null) {
|
if (map != null) {
|
||||||
LocationTask locTask= map.find(ifl);
|
LocationTask locTask= map.find(ifl);
|
||||||
|
@ -1245,8 +1243,8 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IIndexFile[] files = getAvailableIndexFiles(linkageID, ifl);
|
IIndexFragmentFile[] files = getAvailableIndexFiles(linkageID, ifl);
|
||||||
for (IIndexFile file : files) {
|
for (IIndexFragmentFile file : files) {
|
||||||
if (sigMacros.equals(file.getSignificantMacros()))
|
if (sigMacros.equals(file.getSignificantMacros()))
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
@ -1278,30 +1276,25 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexFile[] getAvailableIndexFiles(int linkageID, IIndexFileLocation ifl)
|
public IIndexFragmentFile[] getAvailableIndexFiles(int linkageID, IIndexFileLocation ifl)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
IIndexFile[] files= fIndexFilesCache.get(ifl);
|
IIndexFragmentFile[] files= fIndexFilesCache.get(ifl);
|
||||||
if (files == null) {
|
if (files == null) {
|
||||||
if (fResolver.canBePartOfSDK(ifl)) {
|
IIndexFragmentFile[] fragFiles = fIndex.getWritableFiles(linkageID, ifl);
|
||||||
// Check for a version in potentially another pdom.
|
int j= 0;
|
||||||
files= fIndex.getFiles(linkageID, ifl);
|
for (int i = 0; i < fragFiles.length; i++) {
|
||||||
} else {
|
if (fragFiles[i].hasContent()) {
|
||||||
IIndexFragmentFile[] fragFiles = fIndex.getWritableFiles(linkageID, ifl);
|
if (j != i)
|
||||||
int j= 0;
|
fragFiles[j]= fragFiles[i];
|
||||||
for (int i = 0; i < fragFiles.length; i++) {
|
j++;
|
||||||
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);
|
fIndexFilesCache.put(ifl, files);
|
||||||
}
|
}
|
||||||
return 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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -22,7 +22,6 @@ import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.nio.channels.FileChannel;
|
import java.nio.channels.FileChannel;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -672,45 +671,20 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enqueue(IPDOMIndexerTask subjob) {
|
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) {
|
synchronized (fTaskQueue) {
|
||||||
if (fCurrentTask != null && fCurrentTask.acceptUrgentTask(subjob)) {
|
if (fCurrentTask != null && fCurrentTask.acceptUrgentTask(subjob)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int i= 0;
|
|
||||||
for (IPDOMIndexerTask task : fTaskQueue) {
|
for (IPDOMIndexerTask task : fTaskQueue) {
|
||||||
if (task.acceptUrgentTask(subjob)) {
|
if (task.acceptUrgentTask(subjob)) {
|
||||||
return;
|
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();
|
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 getNextTask() {
|
||||||
IPDOMIndexerTask result= null;
|
IPDOMIndexerTask result= null;
|
||||||
synchronized (fTaskQueue) {
|
synchronized (fTaskQueue) {
|
||||||
|
|
|
@ -1,250 +1,315 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
<!-- Schema file written by PDE -->
|
<!-- Schema file written by PDE -->
|
||||||
<schema targetNamespace="org.eclipse.cdt.core" xmlns="http://www.w3.org/2001/XMLSchema">
|
<schema targetNamespace="org.eclipse.cdt.core" xmlns="http://www.w3.org/2001/XMLSchema">
|
||||||
<annotation>
|
<annotation>
|
||||||
<appInfo>
|
<appInfo>
|
||||||
<meta.schema plugin="org.eclipse.cdt.core" id="CIndex" name="CIndex"/>
|
<meta.schema plugin="org.eclipse.cdt.core" id="CIndex" name="CIndex"/>
|
||||||
</appInfo>
|
</appInfo>
|
||||||
<documentation>
|
<documentation>
|
||||||
This extension point groups extensions to the index functionality in CDT
|
This extension point groups extensions to the index functionality in CDT
|
||||||
</documentation>
|
</documentation>
|
||||||
</annotation>
|
</annotation>
|
||||||
|
|
||||||
<element name="extension">
|
<element name="extension">
|
||||||
<annotation>
|
<annotation>
|
||||||
<appInfo>
|
<appInfo>
|
||||||
<meta.element />
|
<meta.element />
|
||||||
</appInfo>
|
</appInfo>
|
||||||
</annotation>
|
</annotation>
|
||||||
<complexType>
|
<complexType>
|
||||||
<choice minOccurs="1" maxOccurs="unbounded">
|
<choice minOccurs="1" maxOccurs="unbounded">
|
||||||
<element ref="ExportProjectProvider"/>
|
<element ref="ExportProjectProvider"/>
|
||||||
<element ref="ReadOnlyPDOMProvider"/>
|
<element ref="ReadOnlyPDOMProvider"/>
|
||||||
<element ref="ReadOnlyIndexFragmentProvider"/>
|
<element ref="ReadOnlyIndexFragmentProvider"/>
|
||||||
</choice>
|
</choice>
|
||||||
<attribute name="point" type="string" use="required">
|
<attribute name="point" type="string" use="required">
|
||||||
<annotation>
|
<annotation>
|
||||||
<documentation>
|
<documentation>
|
||||||
|
|
||||||
</documentation>
|
</documentation>
|
||||||
</annotation>
|
</annotation>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="id" type="string">
|
<attribute name="id" type="string">
|
||||||
<annotation>
|
<annotation>
|
||||||
<documentation>
|
<documentation>
|
||||||
|
|
||||||
</documentation>
|
</documentation>
|
||||||
</annotation>
|
</annotation>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="name" type="string">
|
<attribute name="name" type="string">
|
||||||
<annotation>
|
<annotation>
|
||||||
<documentation>
|
<documentation>
|
||||||
|
|
||||||
</documentation>
|
</documentation>
|
||||||
<appInfo>
|
<appInfo>
|
||||||
<meta.attribute translatable="true"/>
|
<meta.attribute translatable="true"/>
|
||||||
</appInfo>
|
</appInfo>
|
||||||
</annotation>
|
</annotation>
|
||||||
</attribute>
|
</attribute>
|
||||||
</complexType>
|
</complexType>
|
||||||
</element>
|
</element>
|
||||||
|
|
||||||
<element name="ExportProjectProvider">
|
<element name="ExportProjectProvider">
|
||||||
<annotation>
|
<annotation>
|
||||||
<documentation>
|
<documentation>
|
||||||
<h2>ExportProjectProvider</h2>
|
<h2>ExportProjectProvider</h2>
|
||||||
<p>
|
<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).
|
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>
|
<p>
|
||||||
<b>Invoking the application as a headless application</b>
|
<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.
|
This example ant file shows how to invoke the tool headlessly, the same approach would work from a shell or batch file.
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
<project name="Generate PDOM" default="generate">
|
<project name="Generate PDOM" default="generate">
|
||||||
<target name="generate">
|
<target name="generate">
|
||||||
<!-- This script shows how to invoke the default project provider (ExternalExportProjectProvider) -->
|
<!-- This script shows how to invoke the default project provider (ExternalExportProjectProvider) -->
|
||||||
<property name="pprovider" value="org.eclipse.cdt.core.index.export.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="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="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="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 -->
|
<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">
|
<java classname="org.eclipse.equinox.launcher.Main">
|
||||||
<classpath>
|
<classpath>
|
||||||
<fileset dir="${eclipse.home}/plugins">
|
<fileset dir="${eclipse.home}/plugins">
|
||||||
<include name="*equinox.launcher*.jar"/>
|
<include name="*equinox.launcher*.jar"/>
|
||||||
</fileset>
|
</fileset>
|
||||||
</classpath>
|
</classpath>
|
||||||
<arg value="-nosplash"/>
|
<arg value="-nosplash"/>
|
||||||
<arg value="-exitdata"/>
|
<arg value="-exitdata"/>
|
||||||
<arg value="-application"/><arg value="org.eclipse.cdt.core.GeneratePDOM"/>
|
<arg value="-application"/><arg value="org.eclipse.cdt.core.GeneratePDOM"/>
|
||||||
<arg value="-pprovider"/><arg value="${pprovider}"/>
|
<arg value="-pprovider"/><arg value="${pprovider}"/>
|
||||||
<arg value="-source"/><arg value="${source}"/>
|
<arg value="-source"/><arg value="${source}"/>
|
||||||
<arg value="-target"/><arg value="${target}"/>
|
<arg value="-target"/><arg value="${target}"/>
|
||||||
<arg value="-id"/><arg value="${id}"/>
|
<arg value="-id"/><arg value="${id}"/>
|
||||||
</java>
|
</java>
|
||||||
</target>
|
</target>
|
||||||
</project>
|
</project>
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
<b>Invoking the tool via an Eclipse Launch Configuration</b>
|
<b>Invoking the tool via an Eclipse Launch Configuration</b>
|
||||||
<p>
|
<p>
|
||||||
Specify "org.eclipse.cdt.core.GeneratePDOM" as the application to launch
|
Specify "org.eclipse.cdt.core.GeneratePDOM" as the application to launch
|
||||||
<p>
|
<p>
|
||||||
In the Argument tabs provide (for example)
|
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
|
-target C:\ExportedPDOMs\acmeSDK_2_5.pdom -source E:\AcmeSDK\v2.5\inc -include E:\this.h -id com.acme.mysdk.v2.5
|
||||||
<p>
|
<p>
|
||||||
</documentation>
|
</documentation>
|
||||||
</annotation>
|
</annotation>
|
||||||
<complexType>
|
<complexType>
|
||||||
<attribute name="class" type="string" use="required">
|
<attribute name="class" type="string" use="required">
|
||||||
<annotation>
|
<annotation>
|
||||||
<documentation>
|
<documentation>
|
||||||
the fully qualified name of the IExportProjectProvider implementation to register
|
the fully qualified name of the IExportProjectProvider implementation to register
|
||||||
</documentation>
|
</documentation>
|
||||||
<appInfo>
|
<appInfo>
|
||||||
<meta.attribute kind="java"/>
|
<meta.attribute kind="java"/>
|
||||||
</appInfo>
|
</appInfo>
|
||||||
</annotation>
|
</annotation>
|
||||||
</attribute>
|
</attribute>
|
||||||
</complexType>
|
</complexType>
|
||||||
</element>
|
</element>
|
||||||
|
|
||||||
<element name="ReadOnlyPDOMProvider">
|
<element name="ReadOnlyPDOMProvider">
|
||||||
<annotation>
|
<annotation>
|
||||||
<documentation>
|
<documentation>
|
||||||
<h2>ReadOnlyPDOMProvider</h2>
|
<h2>ReadOnlyPDOMProvider</h2>
|
||||||
<p>
|
<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.
|
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:
|
An example of contributing a prebuilt read-only pdom:
|
||||||
<pre>
|
<pre>
|
||||||
<CIndex>
|
<CIndex>
|
||||||
<ReadOnlyPDOMProvider class="com.acme.ide.index.AcmeSDKProvider"/>
|
<ReadOnlyPDOMProvider class="com.acme.ide.index.AcmeSDKProvider"/>
|
||||||
</CIndex>
|
</CIndex>
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
and the corresponding implementation
|
and the corresponding implementation
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
package com.acme.ide.index.sdk;
|
package com.acme.ide.index.sdk;
|
||||||
|
|
||||||
import org.eclipse.core.index.provider.IReadOnlyPDOMProvider;
|
import org.eclipse.core.index.provider.IReadOnlyPDOMProvider;
|
||||||
import org.eclipse.core.index.provider.IPDOMDescriptor;
|
import org.eclipse.core.index.provider.IPDOMDescriptor;
|
||||||
import org.eclipse.core.index.IIndexLocationConverter;
|
import org.eclipse.core.index.IIndexLocationConverter;
|
||||||
import org.eclipse.core.index.URIRelativeLocationConverter;
|
import org.eclipse.core.index.URIRelativeLocationConverter;
|
||||||
|
|
||||||
public class AcmeSDKProvider implements IReadOnlyPDOMProvider {
|
public class AcmeSDKProvider implements IReadOnlyPDOMProvider {
|
||||||
public boolean providesFor(ICProject project) {
|
public boolean providesFor(ICProject project) {
|
||||||
// e.g. decide by looking for acme project nature
|
// e.g. decide by looking for acme project nature
|
||||||
return AcmeNature.isAcmeProject(project);
|
return AcmeNature.isAcmeProject(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPDOMDescriptor[] getDescriptors(ICConfigurationDescription config) {
|
public IPDOMDescriptor[] getDescriptors(ICConfigurationDescription config) {
|
||||||
final IPath sdkBase = AcmeSDKAPI.getSDKBase(config);
|
final IPath sdkBase = AcmeSDKAPI.getSDKBase(config);
|
||||||
return new IPDOMDescriptor[] { new IPDOMDescriptor() {
|
return new IPDOMDescriptor[] { new IPDOMDescriptor() {
|
||||||
public IIndexLocationConverter getIndexLocationConverter() {
|
public IIndexLocationConverter getIndexLocationConverter() {
|
||||||
return new URIRelativeLocationConverter(URIUtil.toURI(sdkBase));
|
return new URIRelativeLocationConverter(URIUtil.toURI(sdkBase));
|
||||||
}
|
}
|
||||||
public IPath getLocation() {
|
public IPath getLocation() {
|
||||||
IPath path = sdkBase.append(AcmeSDKAPI.getPrebuiltPDOMFilename(config));
|
IPath path = sdkBase.append(AcmeSDKAPI.getPrebuiltPDOMFilename(config));
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
</documentation>
|
</documentation>
|
||||||
</annotation>
|
</annotation>
|
||||||
<complexType>
|
<complexType>
|
||||||
<attribute name="class" type="string" use="required">
|
<sequence minOccurs="0" maxOccurs="1">
|
||||||
<annotation>
|
<element ref="FragmentProviderUsage"/>
|
||||||
<documentation>
|
</sequence>
|
||||||
The fully qualified name of the IReadOnlyPDOMProvider implementation to register
|
<attribute name="class" type="string" use="required">
|
||||||
</documentation>
|
<annotation>
|
||||||
<appInfo>
|
<documentation>
|
||||||
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.core.index.provider.IReadOnlyPDOMProvider"/>
|
The fully qualified name of the IReadOnlyPDOMProvider implementation to register
|
||||||
</appInfo>
|
</documentation>
|
||||||
</annotation>
|
<appInfo>
|
||||||
</attribute>
|
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.core.index.provider.IReadOnlyPDOMProvider"/>
|
||||||
</complexType>
|
</appInfo>
|
||||||
</element>
|
</annotation>
|
||||||
|
</attribute>
|
||||||
<element name="ReadOnlyIndexFragmentProvider">
|
</complexType>
|
||||||
<annotation>
|
</element>
|
||||||
<documentation>
|
|
||||||
<h2>ReadOnlyIndexFragmentProvider</h2>
|
<element name="ReadOnlyIndexFragmentProvider">
|
||||||
<p>
|
<annotation>
|
||||||
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.
|
<documentation>
|
||||||
<p>
|
<h2>ReadOnlyIndexFragmentProvider</h2>
|
||||||
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.
|
<p>
|
||||||
</documentation>
|
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.
|
||||||
</annotation>
|
<p>
|
||||||
<complexType>
|
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.
|
||||||
<attribute name="class" type="string" use="required">
|
</documentation>
|
||||||
<annotation>
|
</annotation>
|
||||||
<documentation>
|
<complexType>
|
||||||
The fully qualified name of a class implementing IIndexFragmentProvider interface.
|
<sequence minOccurs="0" maxOccurs="1">
|
||||||
</documentation>
|
<element ref="FragmentProviderUsage"/>
|
||||||
<appInfo>
|
</sequence>
|
||||||
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.internal.core.index.provider.IIndexFragmentProvider"/>
|
<attribute name="class" type="string" use="required">
|
||||||
</appInfo>
|
<annotation>
|
||||||
</annotation>
|
<documentation>
|
||||||
</attribute>
|
The fully qualified name of a class implementing IIndexFragmentProvider interface.
|
||||||
</complexType>
|
</documentation>
|
||||||
</element>
|
<appInfo>
|
||||||
|
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.internal.core.index.provider.IIndexFragmentProvider"/>
|
||||||
<annotation>
|
</appInfo>
|
||||||
<appInfo>
|
</annotation>
|
||||||
<meta.section type="apiInfo"/>
|
</attribute>
|
||||||
</appInfo>
|
</complexType>
|
||||||
<documentation>
|
</element>
|
||||||
Index content provided by ISVs under this extension point will be accessible via the logical index org.eclipse.core.index.IIndex API
|
|
||||||
|
<element name="FragmentProviderUsage">
|
||||||
For export functionality, see package org.eclipse.cdt.core.index.export
|
<annotation>
|
||||||
</documentation>
|
<documentation>
|
||||||
</annotation>
|
Defines for which tools the fragment provider shall be used.
|
||||||
|
</documentation>
|
||||||
<annotation>
|
</annotation>
|
||||||
<appInfo>
|
<complexType>
|
||||||
<meta.section type="since"/>
|
<attribute name="navigation" type="boolean" use="required">
|
||||||
</appInfo>
|
<annotation>
|
||||||
<documentation>
|
<documentation>
|
||||||
4.0
|
Whether the fragment provider shall be used for performing 'Open Declaration' and 'Open Element'.
|
||||||
</documentation>
|
</documentation>
|
||||||
</annotation>
|
</annotation>
|
||||||
|
</attribute>
|
||||||
<annotation>
|
<attribute name="content_assist" type="boolean" use="required">
|
||||||
<appInfo>
|
<annotation>
|
||||||
<meta.section type="examples"/>
|
<documentation>
|
||||||
</appInfo>
|
Whether the fragment provider shall be used for performing content-assist.
|
||||||
<documentation>
|
</documentation>
|
||||||
See subelement documentation
|
</annotation>
|
||||||
</documentation>
|
</attribute>
|
||||||
</annotation>
|
<attribute name="add_import" type="boolean" use="required">
|
||||||
|
<annotation>
|
||||||
<annotation>
|
<documentation>
|
||||||
<appInfo>
|
Whether the fragment provider shall be used for performing 'Add Import'.
|
||||||
<meta.section type="implementation"/>
|
</documentation>
|
||||||
</appInfo>
|
</annotation>
|
||||||
<documentation>
|
</attribute>
|
||||||
See subelement documentation
|
<attribute name="call_hierarchy" type="boolean" use="required">
|
||||||
</documentation>
|
<annotation>
|
||||||
</annotation>
|
<documentation>
|
||||||
|
Whether the fragment provider shall be used for populating the call hierarchy.
|
||||||
<annotation>
|
</documentation>
|
||||||
<appInfo>
|
</annotation>
|
||||||
<meta.section type="copyright"/>
|
</attribute>
|
||||||
</appInfo>
|
<attribute name="type_hierarchy" type="boolean" use="required">
|
||||||
<documentation>
|
<annotation>
|
||||||
Copyright (c) 2007, 2011 Symbian Software Systems and others.
|
<documentation>
|
||||||
All rights reserved. This program and the accompanying materials
|
Whether the fragment provider shall be used for populating the type hierarchy.
|
||||||
are made available under the terms of the Eclipse Public License v1.0
|
</documentation>
|
||||||
which accompanies this distribution, and is available at
|
</annotation>
|
||||||
http://www.eclipse.org/legal/epl-v10.html
|
</attribute>
|
||||||
</documentation>
|
<attribute name="include_browser" type="boolean" use="required">
|
||||||
</annotation>
|
<annotation>
|
||||||
|
<documentation>
|
||||||
</schema>
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -12,16 +12,13 @@
|
||||||
package org.eclipse.cdt.ui.tests.text;
|
package org.eclipse.cdt.ui.tests.text;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URI;
|
import java.io.FileOutputStream;
|
||||||
|
|
||||||
import junit.extensions.TestSetup;
|
import junit.extensions.TestSetup;
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
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.core.runtime.Path;
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
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.Position;
|
||||||
import org.eclipse.jface.text.source.SourceViewer;
|
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.model.ICProject;
|
||||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
|
||||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
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.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||||
import org.eclipse.cdt.ui.testplugin.Accessor;
|
import org.eclipse.cdt.ui.testplugin.Accessor;
|
||||||
import org.eclipse.cdt.ui.testplugin.EditorTestHelper;
|
import org.eclipse.cdt.ui.testplugin.EditorTestHelper;
|
||||||
import org.eclipse.cdt.ui.testplugin.ResourceTestHelper;
|
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.CEditor;
|
||||||
import org.eclipse.cdt.internal.ui.editor.SemanticHighlighting;
|
import org.eclipse.cdt.internal.ui.editor.SemanticHighlighting;
|
||||||
import org.eclipse.cdt.internal.ui.editor.SemanticHighlightingManager;
|
import org.eclipse.cdt.internal.ui.editor.SemanticHighlightingManager;
|
||||||
|
@ -68,7 +54,7 @@ public class AbstractSemanticHighlightingTest extends TestCase {
|
||||||
|
|
||||||
private ICProject fCProject;
|
private ICProject fCProject;
|
||||||
private final String fTestFilename;
|
private final String fTestFilename;
|
||||||
private File fSdkFile;
|
private File fExternalFile;
|
||||||
|
|
||||||
public SemanticHighlightingTestSetup(Test test, String testFilename) {
|
public SemanticHighlightingTestSetup(Test test, String testFilename) {
|
||||||
super(test);
|
super(test);
|
||||||
|
@ -83,65 +69,25 @@ public class AbstractSemanticHighlightingTest extends TestCase {
|
||||||
"void SDKFunction();\n"+
|
"void SDKFunction();\n"+
|
||||||
"class SDKClass { public: void SDKMethod(); };\n\n";
|
"class SDKClass { public: void SDKMethod(); };\n\n";
|
||||||
|
|
||||||
fSdkFile= createExternalSDK(sdkCode);
|
fExternalFile= createExternalFile(sdkCode);
|
||||||
assertNotNull(fSdkFile);
|
assertNotNull(fExternalFile);
|
||||||
fSdkFile.deleteOnExit();
|
// 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);
|
|
||||||
|
|
||||||
importExternalSDK(fSdkFile, fCProject);
|
|
||||||
|
|
||||||
|
fCProject= EditorTestHelper.createCProject(PROJECT, LINKED_FOLDER, false, true);
|
||||||
|
BaseTestCase.waitForIndexer(fCProject);
|
||||||
fEditor= (CEditor) EditorTestHelper.openInEditor(ResourceTestHelper.findFile(fTestFilename), true);
|
fEditor= (CEditor) EditorTestHelper.openInEditor(ResourceTestHelper.findFile(fTestFilename), true);
|
||||||
fSourceViewer= EditorTestHelper.getSourceViewer(fEditor);
|
fSourceViewer= EditorTestHelper.getSourceViewer(fEditor);
|
||||||
assertTrue(EditorTestHelper.joinReconciler(fSourceViewer, 500, 10000, 100));
|
assertTrue(EditorTestHelper.joinReconciler(fSourceViewer, 500, 10000, 100));
|
||||||
EditorTestHelper.joinBackgroundActivities();
|
EditorTestHelper.joinBackgroundActivities();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void importExternalSDK(final File sdk, final ICProject associatedProject) {
|
private static File createExternalFile(final String code) throws Exception {
|
||||||
final URI baseURI= new File("c:/ExternalSDK/").toURI();
|
File dest = File.createTempFile("external", ".h");
|
||||||
IndexProviderManager ipm= CCoreInternals.getPDOMManager().getIndexProviderManager();
|
FileOutputStream fos = new FileOutputStream(dest);
|
||||||
ipm.addIndexProvider(new ReadOnlyPDOMProviderBridge(
|
fos.write(code.getBytes());
|
||||||
new IReadOnlyPDOMProvider() {
|
fos.close();
|
||||||
@Override
|
return dest;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getTestFilename() {
|
protected String getTestFilename() {
|
||||||
|
@ -165,9 +111,11 @@ public class AbstractSemanticHighlightingTest extends TestCase {
|
||||||
if (fCProject != null)
|
if (fCProject != null)
|
||||||
CProjectHelper.delete(fCProject);
|
CProjectHelper.delete(fCProject);
|
||||||
|
|
||||||
if (fSdkFile != null) {
|
if (fExternalFile != null) {
|
||||||
fSdkFile.delete();
|
fExternalFile.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TestScannerProvider.sIncludeFiles= null;
|
||||||
super.tearDown();
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* 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.IIndex;
|
||||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
import org.eclipse.cdt.core.index.IIndexMacro;
|
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.index.IndexFilter;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
@ -301,7 +302,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
try {
|
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();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IIndexBinding[] bindings= index.findBindingsForPrefix(prefix, false, filter, monitor);
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* 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 {
|
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();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
ICElement element= input;
|
ICElement element= input;
|
||||||
|
@ -154,7 +154,7 @@ public class CHContentProvider extends AsyncTreeContentProvider {
|
||||||
|
|
||||||
private Object[] asyncronouslyComputeReferencedBy(CHNode parent) throws CoreException, InterruptedException {
|
private Object[] asyncronouslyComputeReferencedBy(CHNode parent) throws CoreException, InterruptedException {
|
||||||
ICProject[] scope= CoreModel.getDefault().getCModel().getCProjects();
|
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();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
return CHQueries.findCalledBy(this, parent, index, NPM);
|
return CHQueries.findCalledBy(this, parent, index, NPM);
|
||||||
|
@ -165,7 +165,7 @@ public class CHContentProvider extends AsyncTreeContentProvider {
|
||||||
|
|
||||||
private Object[] asyncronouslyComputeRefersTo(CHNode parent) throws CoreException, InterruptedException {
|
private Object[] asyncronouslyComputeRefersTo(CHNode parent) throws CoreException, InterruptedException {
|
||||||
ICProject[] scope= CoreModel.getDefault().getCModel().getCProjects();
|
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();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
return CHQueries.findCalls(this, parent, index, NPM);
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* 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;
|
import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
|
||||||
|
|
||||||
public class CallHierarchyUI {
|
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 final ICElement[] NO_ELEMENTS = {};
|
||||||
private static boolean sIsJUnitTest= false;
|
private static boolean sIsJUnitTest= false;
|
||||||
|
|
||||||
|
@ -187,9 +189,7 @@ public class CallHierarchyUI {
|
||||||
private static ICElement[] findDefinitions(ICProject project, IEditorInput editorInput, ITextSelection sel)
|
private static ICElement[] findDefinitions(ICProject project, IEditorInput editorInput, ITextSelection sel)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
try {
|
try {
|
||||||
IIndex index= CCorePlugin.getIndexManager().getIndex(project,
|
IIndex index= CCorePlugin.getIndexManager().getIndex(project, INDEX_SEARCH_OPTION);
|
||||||
IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT);
|
|
||||||
|
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IASTName name= IndexUI.getSelectedName(editorInput, sel);
|
IASTName name= IndexUI.getSelectedName(editorInput, sel);
|
||||||
|
@ -275,8 +275,7 @@ public class CallHierarchyUI {
|
||||||
final ITranslationUnit tu= CModelUtil.getTranslationUnit(input);
|
final ITranslationUnit tu= CModelUtil.getTranslationUnit(input);
|
||||||
if (tu != null) {
|
if (tu != null) {
|
||||||
final ICProject project= tu.getCProject();
|
final ICProject project= tu.getCProject();
|
||||||
final IIndex index= CCorePlugin.getIndexManager().getIndex(project,
|
final IIndex index = CCorePlugin.getIndexManager().getIndex(project, INDEX_SEARCH_OPTION);
|
||||||
IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT);
|
|
||||||
|
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* 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.IIndexFile;
|
||||||
import org.eclipse.cdt.core.index.IIndexInclude;
|
import org.eclipse.cdt.core.index.IIndexInclude;
|
||||||
import org.eclipse.cdt.core.index.IIndexMacro;
|
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.IIndexName;
|
||||||
import org.eclipse.cdt.core.index.IndexFilter;
|
import org.eclipse.cdt.core.index.IndexFilter;
|
||||||
import org.eclipse.cdt.core.model.ILanguage;
|
import org.eclipse.cdt.core.model.ILanguage;
|
||||||
|
@ -170,11 +171,11 @@ public class AddIncludeOnSelectionAction extends TextEditorAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
final String[] lookupName = new String[1];
|
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) {
|
SharedASTJob job = new SharedASTJob(CEditorMessages.AddIncludeOnSelection_label, fTu) {
|
||||||
@Override
|
@Override
|
||||||
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException {
|
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException {
|
||||||
deduceInclude((ITextSelection) selection, ast, lookupName);
|
deduceInclude((ITextSelection) selection, index, ast, lookupName);
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -198,6 +199,8 @@ public class AddIncludeOnSelectionAction extends TextEditorAction {
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Thread.currentThread().interrupt();
|
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 ast an AST.
|
||||||
* @param lookupName a one-element array used to return the selected name.
|
* @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 {
|
throws CoreException {
|
||||||
IASTNodeSelector selector = ast.getNodeSelector(fTu.getLocation().toOSString());
|
IASTNodeSelector selector = ast.getNodeSelector(fTu.getLocation().toOSString());
|
||||||
IASTName name = selector.findEnclosingName(selection.getOffset(), selection.getLength());
|
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 Map<String, IncludeCandidate> candidatesMap= new HashMap<String, IncludeCandidate>();
|
||||||
final IIndex index = ast.getIndex();
|
|
||||||
final IndexFilter filter = IndexFilter.getDeclaredBindingFilter(ast.getLinkage().getLinkageID(), false);
|
final IndexFilter filter = IndexFilter.getDeclaredBindingFilter(ast.getLinkage().getLinkageID(), false);
|
||||||
|
|
||||||
List<IIndexBinding> bindings = new ArrayList<IIndexBinding>();
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* 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.IIndexFile;
|
||||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.core.index.IIndexInclude;
|
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.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
@ -84,7 +85,7 @@ public class IBContentProvider extends AsyncTreeContentProvider {
|
||||||
IIndex index;
|
IIndex index;
|
||||||
try {
|
try {
|
||||||
ICProject[] scope= CoreModel.getDefault().getCModel().getCProjects();
|
ICProject[] scope= CoreModel.getDefault().getCModel().getCProjects();
|
||||||
index= CCorePlugin.getIndexManager().getIndex(scope);
|
index= CCorePlugin.getIndexManager().getIndex(scope, IIndexManager.ADD_EXTENSION_FRAGMENTS_INCLUDE_BROWSER);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CUIPlugin.log(e);
|
CUIPlugin.log(e);
|
||||||
|
@ -105,8 +106,7 @@ public class IBContentProvider extends AsyncTreeContentProvider {
|
||||||
}
|
}
|
||||||
if (includes.length > 0) {
|
if (includes.length > 0) {
|
||||||
Set<IBNode> result= new LinkedHashSet<IBNode>(includes.length);
|
Set<IBNode> result= new LinkedHashSet<IBNode>(includes.length);
|
||||||
for (int i = 0; i < includes.length; i++) {
|
for (IIndexInclude include : includes) {
|
||||||
IIndexInclude include = includes[i];
|
|
||||||
try {
|
try {
|
||||||
if (fComputeIncludedBy) {
|
if (fComputeIncludedBy) {
|
||||||
directiveFile= targetFile= new IBFile(project, include.getIncludedByLocation());
|
directiveFile= targetFile= new IBFile(project, include.getIncludedByLocation());
|
||||||
|
@ -158,10 +158,9 @@ public class IBContentProvider extends AsyncTreeContentProvider {
|
||||||
if (files.length > 0) {
|
if (files.length > 0) {
|
||||||
ArrayList<IIndexInclude> list= new ArrayList<IIndexInclude>();
|
ArrayList<IIndexInclude> list= new ArrayList<IIndexInclude>();
|
||||||
HashSet<IIndexFileLocation> handled= new HashSet<IIndexFileLocation>();
|
HashSet<IIndexFileLocation> handled= new HashSet<IIndexFileLocation>();
|
||||||
for (int i = 0; i < files.length; i++) {
|
for (IIndexFile file : files) {
|
||||||
final IIndexInclude[] includes = index.findIncludedBy(files[i]);
|
final IIndexInclude[] includes = index.findIncludedBy(file);
|
||||||
for (int j = 0; j < includes.length; j++) {
|
for (IIndexInclude indexInclude : includes) {
|
||||||
IIndexInclude indexInclude = includes[j];
|
|
||||||
if (handled.add(indexInclude.getIncludedByLocation())) {
|
if (handled.add(indexInclude.getIncludedByLocation())) {
|
||||||
list.add(indexInclude);
|
list.add(indexInclude);
|
||||||
}
|
}
|
||||||
|
@ -186,10 +185,9 @@ public class IBContentProvider extends AsyncTreeContentProvider {
|
||||||
if (files.length > 0) {
|
if (files.length > 0) {
|
||||||
ArrayList<IIndexInclude> list= new ArrayList<IIndexInclude>();
|
ArrayList<IIndexInclude> list= new ArrayList<IIndexInclude>();
|
||||||
HashSet<IIndexFileLocation> handled= new HashSet<IIndexFileLocation>();
|
HashSet<IIndexFileLocation> handled= new HashSet<IIndexFileLocation>();
|
||||||
for (int i = 0; i < files.length; i++) {
|
for (IIndexFile file : files) {
|
||||||
final IIndexInclude[] includes = index.findIncludes(files[i]);
|
final IIndexInclude[] includes = index.findIncludes(file);
|
||||||
for (int j = 0; j < includes.length; j++) {
|
for (IIndexInclude indexInclude : includes) {
|
||||||
IIndexInclude indexInclude = includes[j];
|
|
||||||
if (handled.add(indexInclude.getIncludesLocation())) {
|
if (handled.add(indexInclude.getIncludesLocation())) {
|
||||||
list.add(indexInclude);
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* 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.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
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.IIndexName;
|
||||||
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
|
@ -72,7 +73,7 @@ public class OpenDefinitionAction extends IndexAction {
|
||||||
if (cproject != null) {
|
if (cproject != null) {
|
||||||
IIndex index= CCorePlugin.getIndexManager().getIndex(cproject);
|
IIndex index= CCorePlugin.getIndexManager().getIndex(cproject);
|
||||||
if (!openDefinition(cproject, bindingNode, index)) {
|
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);
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -493,8 +493,8 @@ public abstract class CSearchQuery implements ISearchQuery {
|
||||||
result.setIndexerBusy(!CCorePlugin.getIndexManager().isIndexerIdle());
|
result.setIndexerBusy(!CCorePlugin.getIndexManager().isIndexerIdle());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
IIndex index= CCorePlugin.getIndexManager().getIndex(projects,
|
IIndex index = CCorePlugin.getIndexManager().getIndex(projects,
|
||||||
IIndexManager.ADD_EXTENSION_FRAGMENTS);
|
IIndexManager.ADD_EXTENSION_FRAGMENTS_SEARCH);
|
||||||
try {
|
try {
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
} catch (InterruptedException e) {
|
} 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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -134,7 +134,7 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
|
||||||
|
|
||||||
fMonitor= monitor;
|
fMonitor= monitor;
|
||||||
fIndex= CCorePlugin.getIndexManager().getIndex(fTranslationUnit.getCProject(),
|
fIndex= CCorePlugin.getIndexManager().getIndex(fTranslationUnit.getCProject(),
|
||||||
IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT);
|
IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT | IIndexManager.ADD_EXTENSION_FRAGMENTS_NAVIGATION);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fIndex.acquireReadLock();
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -147,7 +147,7 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont
|
||||||
|
|
||||||
try {
|
try {
|
||||||
IIndexManager manager= CCorePlugin.getIndexManager();
|
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 {
|
try {
|
||||||
fIndex.acquireReadLock();
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -149,7 +149,7 @@ class THHierarchyModel {
|
||||||
THGraph graph= new THGraph();
|
THGraph graph= new THGraph();
|
||||||
try {
|
try {
|
||||||
ICProject[] scope= CoreModel.getDefault().getCModel().getCProjects();
|
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();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
if (monitor.isCanceled())
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* 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;
|
import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
|
||||||
|
|
||||||
public class TypeHierarchyUI {
|
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) {
|
public static THViewPart open(ICElement input, IWorkbenchWindow window) {
|
||||||
if (!isValidInput(input)) {
|
if (!isValidInput(input)) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -141,7 +144,7 @@ public class TypeHierarchyUI {
|
||||||
|
|
||||||
private static ICElement[] findInput(ICProject project, IEditorInput editorInput, IRegion sel) throws CoreException {
|
private static ICElement[] findInput(ICProject project, IEditorInput editorInput, IRegion sel) throws CoreException {
|
||||||
try {
|
try {
|
||||||
IIndex index= CCorePlugin.getIndexManager().getIndex(project, IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT);
|
IIndex index= CCorePlugin.getIndexManager().getIndex(project, INDEX_SEARCH_OPTION);
|
||||||
|
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
|
@ -180,7 +183,7 @@ public class TypeHierarchyUI {
|
||||||
private static ICElement[] findInput(ICElement member) {
|
private static ICElement[] findInput(ICElement member) {
|
||||||
ICProject project= member.getCProject();
|
ICProject project= member.getCProject();
|
||||||
try {
|
try {
|
||||||
IIndex index= CCorePlugin.getIndexManager().getIndex(project, IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT);
|
IIndex index= CCorePlugin.getIndexManager().getIndex(project, INDEX_SEARCH_OPTION);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IIndexName name= IndexUI.elementToName(index, member);
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* 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 {
|
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>();
|
List<IIndexFileLocation> list= new ArrayList<IIndexFileLocation>();
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* 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.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
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.index.IndexFilter;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
|
@ -360,7 +361,7 @@ public class NewClassWizardUtil {
|
||||||
IIndex index= null;
|
IIndex index= null;
|
||||||
try {
|
try {
|
||||||
if (project != null) {
|
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();
|
index.acquireReadLock();
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue