Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2011-09-17 01:30:17 +0000
committerSergey Prigogin2011-10-18 01:08:11 +0000
commit9972595fc75d8873b87c04457cf3fad6d000a82a (patch)
treee8892f9360d21b7d85af52c5f635288363a602af
parent7a3c9ba3a163291f47e57a8124a5d4bd9e99cc47 (diff)
downloadorg.eclipse.cdt-9972595fc75d8873b87c04457cf3fad6d000a82a.tar.gz
org.eclipse.cdt-9972595fc75d8873b87c04457cf3fad6d000a82a.tar.xz
org.eclipse.cdt-9972595fc75d8873b87c04457cf3fad6d000a82a.zip
Initial support for non-PDOM index fragments contributed through an
extension.
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java34
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMProviderTests.java2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexManager.java16
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java72
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFactory.java21
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/IndexProviderManager.java98
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMProxy.java3
-rw-r--r--core/org.eclipse.cdt.core/schema/CIndex.exsd56
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHierarchyModel.java7
13 files changed, 209 insertions, 117 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java
index c4cb84e7459..34a600877e2 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java
@@ -237,7 +237,7 @@ public class IndexProviderManagerTest extends IndexTestBase {
ipm.reset(VERSION_405); ipm.startup();
ipm.addIndexProvider(provider1); ipm.addIndexProvider(provider2);
- IIndexFragment[] actual = ipm.getProvidedIndexFragments(mockState.getCurrentConfig());
+ IIndexFragment[] actual = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
assertEquals(1, actual.length);
assertFragmentPresent("contentID.contentA", "38", actual);
} finally {
@@ -292,7 +292,7 @@ public class IndexProviderManagerTest extends IndexTestBase {
ipm.reset(VERSION_502); ipm.startup();
ipm.addIndexProvider(provider1); ipm.addIndexProvider(provider2);
- IIndexFragment[] actual = ipm.getProvidedIndexFragments(mockState.getCurrentConfig());
+ IIndexFragment[] actual = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
assertEquals(3, actual.length);
assertFragmentPresent("contentID.foo", "90", actual);
assertFragmentPresent("contentID.bar", "91", actual);
@@ -399,29 +399,29 @@ public class IndexProviderManagerTest extends IndexTestBase {
IIndexFragment[] fragments;
mockState.setConfig(MockState.REL_V1_ID);
- fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig());
+ fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
assertEquals(2, fragments.length);
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[0]));
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[0]));
mockState.setConfig(MockState.DBG_V2_ID);
- fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig());
+ fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
assertEquals(2, fragments.length);
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[3]));
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[3]));
mockState.setConfig(MockState.DBG_V1_ID);
- fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig());
+ fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
assertEquals(0, fragments.length);
mockState.setConfig(MockState.REL_V2_ID);
- fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig());
+ fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
assertEquals(2, fragments.length);
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[1]));
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[1]));
mockState.setConfig(MockState.REL_V1_ID);
- fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig());
+ fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
assertEquals(2, fragments.length);
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[0]));
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[0]));
@@ -429,29 +429,29 @@ public class IndexProviderManagerTest extends IndexTestBase {
provider1.invert();
mockState.setConfig(MockState.REL_V1_ID);
- fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig());
+ fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
assertEquals(2, fragments.length);
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[3]));
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[0]));
mockState.setConfig(MockState.DBG_V2_ID);
- fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig());
+ fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
assertEquals(2, fragments.length);
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[0]));
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[3]));
mockState.setConfig(MockState.DBG_V1_ID);
- fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig());
+ fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
assertEquals(1, fragments.length);
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[1]));
mockState.setConfig(MockState.REL_V2_ID);
- fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig());
+ fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
assertEquals(1, fragments.length);
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[1]));
mockState.setConfig(MockState.REL_V1_ID);
- fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig());
+ fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
assertEquals(2, fragments.length);
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[3]));
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[0]));
@@ -459,29 +459,29 @@ public class IndexProviderManagerTest extends IndexTestBase {
provider2.invert();
mockState.setConfig(MockState.REL_V1_ID);
- fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig());
+ fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
assertEquals(2, fragments.length);
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[3]));
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[3]));
mockState.setConfig(MockState.DBG_V2_ID);
- fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig());
+ fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
assertEquals(2, fragments.length);
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[0]));
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[0]));
mockState.setConfig(MockState.DBG_V1_ID);
- fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig());
+ fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
assertEquals(2, fragments.length);
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[1]));
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[1]));
mockState.setConfig(MockState.REL_V2_ID);
- fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig());
+ fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
assertEquals(0, fragments.length);
mockState.setConfig(MockState.REL_V1_ID);
- fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig());
+ fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true);
assertEquals(2, fragments.length);
assertTrue(ArrayUtil.contains(fragments, provider1.fragments[3]));
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[3]));
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMProviderTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMProviderTests.java
index eeb51dcc574..09464883c19 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMProviderTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMProviderTests.java
@@ -305,7 +305,7 @@ public class PDOMProviderTests extends PDOMTestBase {
for(int i=0; i<3; i++) {
// try several times in order to test the status is logged only once
ICProjectDescription pd= CCorePlugin.getDefault().getProjectDescription(cproject2.getProject(), false);
- assertEquals(0, ipm.getProvidedIndexFragments(pd.getActiveConfiguration()).length);
+ assertEquals(0, ipm.getProvidedIndexFragments(pd.getActiveConfiguration(), true).length);
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexManager.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexManager.java
index e1f77cc0472..e1e6bcb6b56 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexManager.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexManager.java
@@ -43,13 +43,23 @@ public interface IIndexManager extends IPDOMManager {
public final static int ADD_DEPENDENT = 0x2;
/**
- * Constant for passing to getIndex methods. This constant, when set, indicates
- * that index content provided via the CIndex extension point should not be included
- * in the resulting index, as it would have done otherwise.
+ * Constant for passing to getIndex methods. This constant, when set, indicates that the index
+ * content provided via the CIndex extension point should not be included in the resulting
+ * index, as it would have done otherwise.
*/
public final static int SKIP_PROVIDED = 0x4;
/**
+ * Constant for passing to getIndex methods. This constant, when set, indicates that the index
+ * content provided via the ReadOnlyIndexFragmentProvider element of the CIndex extension point
+ * should be included in the resulting index. By default such index content is not included.
+ * This flag is ignored if SKIP_PROVIDED flag is set.
+ *
+ * @since 5.4
+ */
+ public final static int ADD_EXTENSION_FRAGMENTS = 0x8;
+
+ /**
* Constant for indicating there is no time out period for joining the indexer job.
* @see IIndexManager#joinIndexer(int, IProgressMonitor)
*/
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java
index fa011fc2c37..74e05607504 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java
@@ -20,7 +20,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
@@ -65,6 +64,14 @@ public class CIndex implements IIndex {
private int fReadLock;
private ICompositesFactory cppCF, cCF, fCF;
+ /**
+ * Creates an index consisting of one or more 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.
+ * @param primaryFragmentCount The number of primary index fragments. This number may include
+ * extended fragments.
+ */
public CIndex(IIndexFragment[] fragments, int primaryFragmentCount) {
fFragments= fragments;
fPrimaryFragmentCount= primaryFragmentCount;
@@ -109,7 +116,8 @@ public class CIndex implements IIndex {
IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
for (int i = 0; i < fPrimaryFragmentCount; i++) {
try {
- IBinding[] part = fFragments[i].findBindings(patterns, isFullyQualified, retargetFilter(linkage, filter), monitor);
+ IBinding[] part = fFragments[i].findBindings(patterns, isFullyQualified,
+ retargetFilter(linkage, filter), monitor);
fragmentBindings[i] = new IIndexFragmentBinding[part.length];
System.arraycopy(part, 0, fragmentBindings[i], 0, part.length);
} catch (CoreException e) {
@@ -171,29 +179,47 @@ public class CIndex implements IIndex {
binding= bindings[0];
}
- int fragCount= 0;
+ // Maps a file location to -1 if the file belongs to an earlier index fragment,
+ // or to the index of the last checked index fragment plus one, if the file doesn't belong
+ // to any of the index fragments up to the last checked one.
+ HashMap<IIndexFileLocation, Integer> fileCheckCache = new HashMap<IIndexFileLocation, Integer>();
for (int i = 0; i < fPrimaryFragmentCount; i++) {
- final IIndexFragmentName[] names = fFragments[i].findNames(binding, flags);
- if (names.length > 0) {
- result.addAll(Arrays.asList(names));
- fragCount++;
- }
- }
- // bug 192352, files can reside in multiple fragments, remove duplicates
- if (fragCount > 1 || (flags & IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES) != 0) {
- HashMap<String, IIndexFile> fileMap= new HashMap<String, IIndexFile>();
- for (Iterator<IIndexFragmentName> iterator = result.iterator(); iterator.hasNext();) {
- final IIndexFragmentName name = iterator.next();
- final IIndexFile file= name.getFile();
- final String fileKey= name.getFile().getLocation().getURI().toString();
- final IIndexFile otherFile= fileMap.get(fileKey);
- if (otherFile == null) {
- fileMap.put(fileKey, file);
- } else if (!otherFile.equals(file)) { // same file in another fragment
- iterator.remove();
+ IIndexFragment fragment = fFragments[i];
+ final IIndexFragmentName[] names = fragment.findNames(binding, flags);
+ for (IIndexFragmentName name : names) {
+ IIndexFileLocation location = name.getFile().getLocation();
+ Integer checkState = fileCheckCache.get(location);
+ int checkOffset = checkState == null ? 0 : checkState.intValue();
+ if (checkOffset >= 0) {
+ for (; checkOffset < i; checkOffset++) {
+ IIndexFragment fragment2 = fFragments[checkOffset];
+ if (fragment2.getFiles(location).length != 0) {
+ checkOffset = -1;
+ break;
+ }
+ }
+ fileCheckCache.put(location, Integer.valueOf(checkOffset));
+ }
+ if (checkOffset == i) {
+ result.add(name);
}
}
}
+// // bug 192352, files can reside in multiple fragments, remove duplicates
+// if (fragCount > 1 || (flags & IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES) != 0) {
+// HashMap<String, IIndexFile> fileMap= new HashMap<String, IIndexFile>();
+// for (Iterator<IIndexFragmentName> iterator = result.iterator(); iterator.hasNext();) {
+// final IIndexFragmentName name = iterator.next();
+// final IIndexFile file= name.getFile();
+// final String fileKey= name.getFile().getLocation().getURI().toString();
+// final IIndexFile otherFile= fileMap.get(fileKey);
+// if (otherFile == null) {
+// fileMap.put(fileKey, file);
+// } else if (!otherFile.equals(file)) { // same file in another fragment
+// iterator.remove();
+// }
+// }
+// }
return result.toArray(new IIndexName[result.size()]);
}
@@ -436,8 +462,8 @@ public class CIndex implements IIndex {
IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
for (int i = 0; i < fPrimaryFragmentCount; i++) {
try {
- IBinding[] part = fFragments[i].findBindings(names, retargetFilter(linkage, filter),
- new SubProgressMonitor(monitor, 1));
+ IBinding[] part = fFragments[i].findBindings(names,
+ retargetFilter(linkage, filter), new SubProgressMonitor(monitor, 1));
fragmentBindings[i] = new IIndexFragmentBinding[part.length];
System.arraycopy(part, 0, fragmentBindings[i], 0, part.length);
} catch (CoreException e) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFactory.java
index 2ca1f06577b..215ced10904 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFactory.java
@@ -8,6 +8,7 @@
* Contributors:
* Markus Schorn - initial API and implementation
* Andrew Ferguson (Symbian)
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.index;
@@ -42,6 +43,7 @@ public class IndexFactory {
private static final int ADD_DEPENDENCIES = IIndexManager.ADD_DEPENDENCIES;
private static final int ADD_DEPENDENT = IIndexManager.ADD_DEPENDENT;
private static final int SKIP_PROVIDED = IIndexManager.SKIP_PROVIDED;
+ private static final int ADD_EXTENSION_FRAGMENTS = IIndexManager.ADD_EXTENSION_FRAGMENTS;
private PDOMManager fPDOMManager;
@@ -55,6 +57,7 @@ public class IndexFactory {
boolean addDependencies= (options & ADD_DEPENDENCIES) != 0;
boolean addDependent= (options & ADD_DEPENDENT) != 0;
boolean skipProvided= (options & SKIP_PROVIDED) != 0;
+ boolean addExtensionFragments= (options & ADD_EXTENSION_FRAGMENTS) != 0;
HashMap<IProject, Integer> map= new HashMap<IProject, Integer>();
Collection<ICProject> selectedProjects= getProjects(projects, addDependencies, addDependent,
@@ -67,7 +70,7 @@ public class IndexFactory {
safeAddFragment(fragments, pdom);
if (!skipProvided) {
- safeAddProvidedFragments(cproject, fragments);
+ safeAddProvidedFragments(cproject, fragments, addExtensionFragments);
}
}
}
@@ -87,7 +90,7 @@ public class IndexFactory {
safeAddFragment(fragments, pdom);
if (!skipProvided) {
- safeAddProvidedFragments(cproject, fragments);
+ safeAddProvidedFragments(cproject, fragments, addExtensionFragments);
}
}
}
@@ -103,7 +106,7 @@ public class IndexFactory {
throw new CoreException(CCorePlugin.createStatus(
NLS.bind(Messages.IndexFactory_errorNoSuchPDOM0, project.getElementName())));
}
- safeAddProvidedFragments(project, readOnlyFrag);
+ safeAddProvidedFragments(project, readOnlyFrag, false);
Collection<ICProject> selectedProjects= getProjects(new ICProject[] {project}, true, false,
new HashMap<IProject, Integer>(), new Integer(1));
@@ -201,19 +204,21 @@ public class IndexFactory {
}
/**
- * Adds ID -> IIndexFragment entries to the specified Map, for fragments provided under the
- * CIndex extension point for the specified ICProject
- * @param cproject
+ * Adds ID -> IIndexFragment entries to the specified Map, for fragments provided under
+ * the CIndex extension point for the specified ICProject.
+ * @param cproject The project to get the provided index fragments for.
* @param fragments
+ * @param includeNonPDOMFragments
*/
- private void safeAddProvidedFragments(ICProject cproject, Map<String, IIndexFragment> fragments) {
+ private void safeAddProvidedFragments(ICProject cproject, Map<String, IIndexFragment> fragments,
+ boolean includeNonPDOMFragments) {
ICProjectDescription pd= CoreModel.getDefault().getProjectDescription(cproject.getProject(), false);
if (pd != null) {
IndexProviderManager ipm = CCoreInternals.getPDOMManager().getIndexProviderManager();
ICConfigurationDescription cfg= pd.getDefaultSettingConfiguration();
if (cfg != null) {
try {
- IIndexFragment[] pFragments= ipm.getProvidedIndexFragments(cfg);
+ IIndexFragment[] pFragments= ipm.getProvidedIndexFragments(cfg, includeNonPDOMFragments);
for (IIndexFragment fragment : pFragments) {
safeAddFragment(fragments, fragment);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/IndexProviderManager.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/IndexProviderManager.java
index 092cc94df79..b9946676fb8 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/IndexProviderManager.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/IndexProviderManager.java
@@ -8,6 +8,7 @@
* Contributors:
* Andrew Ferguson (Symbian) - Initial implementation
* Markus Schorn (Wind River Systems)
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.index.provider;
@@ -64,9 +65,11 @@ import java.util.Set;
*/
public final class IndexProviderManager implements IElementChangedListener {
private static final String ELEMENT_RO_PDOM_PROVIDER= "ReadOnlyPDOMProvider"; //$NON-NLS-1$
+ private static final String ELEMENT_RO_INDEX_FRAGMENT_PROVIDER= "ReadOnlyIndexFragmentProvider"; //$NON-NLS-1$
private static final String ATTRIBUTE_CLASS = "class"; //$NON-NLS-1$
- private IIndexFragmentProvider[] allProviders;
+ private IIndexFragmentProvider[] pdomFragmentProviders;
+ private IIndexFragmentProvider[] nonPDOMFragmentProviders;
private Map<ProvisionMapKey, Boolean> provisionMap;
private Set<String> compatibleFragmentUnavailable;
private VersionRange pdomVersionRange;
@@ -89,14 +92,15 @@ public final class IndexProviderManager implements IElementChangedListener {
* @param pdomVersionRange
*/
public void reset(VersionRange pdomVersionRange) {
- this.allProviders= new IIndexFragmentProvider[0];
- this.provisionMap= new HashMap<ProvisionMapKey,Boolean>();
+ this.pdomFragmentProviders= new IIndexFragmentProvider[0];
+ this.provisionMap= new HashMap<ProvisionMapKey, Boolean>();
this.pdomVersionRange= pdomVersionRange;
this.compatibleFragmentUnavailable= new HashSet<String>();
}
public void startup() {
- List<IIndexFragmentProvider> providers = new ArrayList<IIndexFragmentProvider>();
+ List<IIndexFragmentProvider> pdomProviders = new ArrayList<IIndexFragmentProvider>();
+ List<IIndexFragmentProvider> nonPDOMProviders = new ArrayList<IIndexFragmentProvider>();
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint indexProviders = registry.getExtensionPoint(CCorePlugin.INDEX_UNIQ_ID);
for (IExtension extension : indexProviders.getExtensions()) {
@@ -106,11 +110,20 @@ public final class IndexProviderManager implements IElementChangedListener {
Object provider = element.createExecutableExtension(ATTRIBUTE_CLASS);
if (provider instanceof IReadOnlyPDOMProvider) {
- providers.add(new ReadOnlyPDOMProviderBridge((IReadOnlyPDOMProvider) provider));
+ pdomProviders.add(new ReadOnlyPDOMProviderBridge((IReadOnlyPDOMProvider) provider));
} else {
CCorePlugin.log(NLS.bind(Messages.IndexProviderManager_0,
extension.getContributor().getName()));
}
+ } else if (ELEMENT_RO_INDEX_FRAGMENT_PROVIDER.equals(element.getName())) {
+ Object provider = element.createExecutableExtension(ATTRIBUTE_CLASS);
+
+ if (provider instanceof IIndexFragmentProvider) {
+ nonPDOMProviders.add((IIndexFragmentProvider) provider);
+ } else {
+ CCorePlugin.log(NLS.bind(Messages.IndexProviderManager_0,
+ extension.getContributor().getName()));
+ }
}
}
} catch (CoreException e) {
@@ -119,7 +132,8 @@ public final class IndexProviderManager implements IElementChangedListener {
}
CoreModel.getDefault().addElementChangedListener(this);
- this.allProviders = providers.toArray(new IIndexFragmentProvider[providers.size()]);
+ this.pdomFragmentProviders = pdomProviders.toArray(new IIndexFragmentProvider[pdomProviders.size()]);
+ this.nonPDOMFragmentProviders = nonPDOMProviders.toArray(new IIndexFragmentProvider[nonPDOMProviders.size()]);
}
/**
@@ -130,26 +144,32 @@ public final class IndexProviderManager implements IElementChangedListener {
* @param config
* @return the array of IIndexFragment objects for the current state
*/
- public IIndexFragment[] getProvidedIndexFragments(ICConfigurationDescription config) throws CoreException {
+ public IIndexFragment[] getProvidedIndexFragments(ICConfigurationDescription config,
+ boolean includeNonPDOMFragments) throws CoreException {
Map<String, IIndexFragment> id2fragment = new HashMap<String, IIndexFragment>();
IProject project= config.getProjectDescription().getProject();
- for (IIndexFragmentProvider provider : allProviders) {
- try {
- if (providesForProject(provider, project)) {
- IIndexFragment[] fragments= provider.getIndexFragments(config);
- for (IIndexFragment fragment : fragments) {
- try {
- processCandidate(id2fragment, fragment);
- } catch (InterruptedException e) {
- CCorePlugin.log(e); // continue with next candidate
- } catch (CoreException e) {
- CCorePlugin.log(e); // continue with next candidate
+ IIndexFragmentProvider[][] groups = includeNonPDOMFragments ?
+ new IIndexFragmentProvider[][] { pdomFragmentProviders, nonPDOMFragmentProviders } :
+ new IIndexFragmentProvider[][] { pdomFragmentProviders };
+ for (IIndexFragmentProvider[] group : groups) {
+ for (IIndexFragmentProvider provider : group) {
+ try {
+ if (providesForProject(provider, project)) {
+ IIndexFragment[] fragments= provider.getIndexFragments(config);
+ for (IIndexFragment fragment : fragments) {
+ try {
+ processCandidate(id2fragment, fragment);
+ } catch (InterruptedException e) {
+ CCorePlugin.log(e); // continue with next candidate
+ } catch (CoreException e) {
+ CCorePlugin.log(e); // continue with next candidate
+ }
}
}
+ } catch (CoreException e) {
+ CCorePlugin.log(e); // move to next provider
}
- } catch (CoreException e) {
- CCorePlugin.log(e); // move to next provider
}
}
@@ -176,14 +196,11 @@ public final class IndexProviderManager implements IElementChangedListener {
* @param formatID
*/
private VersionRange getCurrentlySupportedVersionRangeForFormat(String formatID) {
- /*
- * TODO - at the point we support alternate IIndexFragment implementations, this method will need
- * to be altered to lookup version ranges for the contributed format via an extension point.
- */
- if (!PDOM.FRAGMENT_PROPERTY_VALUE_FORMAT_ID.equals(formatID)) {
- throw new IllegalArgumentException("Non-PDOM formats are currently unsupported"); //$NON-NLS-1$
+ if (PDOM.FRAGMENT_PROPERTY_VALUE_FORMAT_ID.equals(formatID)) {
+ return pdomVersionRange;
}
- return pdomVersionRange;
+ // Version range checks do not apply to non-PDOM IIndexFragments.
+ return null;
}
/**
@@ -209,7 +226,8 @@ public final class IndexProviderManager implements IElementChangedListener {
Version cver= Version.parseVersion(csver); // illegal argument exception
IIndexFragment existing= id2fragment.get(cid);
- if (getCurrentlySupportedVersionRangeForFormat(cformatID).isIncluded(cver)) {
+ VersionRange versionRange = getCurrentlySupportedVersionRangeForFormat(cformatID);
+ if (versionRange == null || versionRange.isIncluded(cver)) {
if (existing != null) {
String esver= null, eformatID= null;
existing.acquireReadLock();
@@ -243,6 +261,8 @@ public final class IndexProviderManager implements IElementChangedListener {
}
/**
+ * Adds a PDOM-based index fragment provider.
+ *
* <b>Note: This method should not be called for purposes other than testing</b>
* @param provider
*/
@@ -256,23 +276,25 @@ public final class IndexProviderManager implements IElementChangedListener {
return;
}
- IIndexFragmentProvider[] newAllProviders = new IIndexFragmentProvider[allProviders.length + 1];
- System.arraycopy(allProviders, 0, newAllProviders, 0, allProviders.length);
- newAllProviders[allProviders.length] = (IIndexFragmentProvider) provider;
- allProviders = newAllProviders;
+ IIndexFragmentProvider[] newAllProviders = new IIndexFragmentProvider[pdomFragmentProviders.length + 1];
+ System.arraycopy(pdomFragmentProviders, 0, newAllProviders, 0, pdomFragmentProviders.length);
+ newAllProviders[pdomFragmentProviders.length] = (IIndexFragmentProvider) provider;
+ pdomFragmentProviders = newAllProviders;
}
/**
- * Removes the specified provider by object identity
+ * Removes the specified provider by object identity. Only a PDOM-based provider can be removed
+ * using this method.
+ *
* <b>Note: This method should not be called for purposes other than testing</b>
* @param provider
*/
public void removeIndexProvider(IIndexProvider provider) {
- ArrayUtil.remove(allProviders, provider);
- if (allProviders[allProviders.length - 1] == null) {
- IIndexFragmentProvider[] newAllProviders = new IIndexFragmentProvider[allProviders.length - 1];
- System.arraycopy(allProviders, 0, newAllProviders, 0, allProviders.length - 1);
- allProviders= newAllProviders;
+ ArrayUtil.remove(pdomFragmentProviders, provider);
+ if (pdomFragmentProviders[pdomFragmentProviders.length - 1] == null) {
+ IIndexFragmentProvider[] newAllProviders = new IIndexFragmentProvider[pdomFragmentProviders.length - 1];
+ System.arraycopy(pdomFragmentProviders, 0, newAllProviders, 0, pdomFragmentProviders.length - 1);
+ pdomFragmentProviders= newAllProviders;
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java
index 019c75bc4c6..8a791b5ad76 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java
@@ -1589,9 +1589,6 @@ public class PDOM extends PlatformObject implements IPDOM {
}
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.index.IIndexFragment#getInlineNamespaces()
- */
public IIndexScope[] getInlineNamespaces() throws CoreException {
PDOMLinkage linkage = getLinkage(ILinkage.CPP_LINKAGE_ID);
if (linkage == null) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMProxy.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMProxy.java
index 0604bc2e191..ade962723be 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMProxy.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMProxy.java
@@ -314,9 +314,6 @@ public class PDOMProxy implements IPDOM {
fDelegate.clearResultCache();
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.index.IIndexFragment#getInlineNamespaces()
- */
public IIndexScope[] getInlineNamespaces() throws CoreException {
if (fDelegate != null)
return fDelegate.getInlineNamespaces();
diff --git a/core/org.eclipse.cdt.core/schema/CIndex.exsd b/core/org.eclipse.cdt.core/schema/CIndex.exsd
index 8c02bba8c74..f35783e15cd 100644
--- a/core/org.eclipse.cdt.core/schema/CIndex.exsd
+++ b/core/org.eclipse.cdt.core/schema/CIndex.exsd
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.cdt.core">
+<schema targetNamespace="org.eclipse.cdt.core" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appInfo>
<meta.schema plugin="org.eclipse.cdt.core" id="CIndex" name="CIndex"/>
@@ -11,10 +11,16 @@
</annotation>
<element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
<complexType>
<choice minOccurs="1" maxOccurs="unbounded">
<element ref="ExportProjectProvider"/>
<element ref="ReadOnlyPDOMProvider"/>
+ <element ref="ReadOnlyIndexFragmentProvider"/>
</choice>
<attribute name="point" type="string" use="required">
<annotation>
@@ -156,10 +162,34 @@ public class AcmeSDKProvider implements IReadOnlyPDOMProvider {
<attribute name="class" type="string" use="required">
<annotation>
<documentation>
- the fully qualified name of the IReadOnlyPDOMProvider implementation to register
+ The fully qualified name of the IReadOnlyPDOMProvider implementation to register
</documentation>
<appInfo>
- <meta.attribute kind="java" basedOn="org.eclipse.cdt.core.index.provider.IReadOnlyPDOMProvider"/>
+ <meta.attribute kind="java" basedOn=":org.eclipse.cdt.core.index.provider.IReadOnlyPDOMProvider"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="ReadOnlyIndexFragmentProvider">
+ <annotation>
+ <documentation>
+ &lt;h2&gt;ReadOnlyIndexFragmentProvider&lt;/h2&gt;
+&lt;p&gt;
+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.
+&lt;p&gt;
+The only information needed for this extension point is the fully qualified name of a class implementing the org.eclipse.cdt.core.index.IIndexFragmentProvider interface. This class will be consulted during the eclipse session for the appropriate read-only content to add to the logical index. The logical index is accessible via the org.eclipse.core.index.IIndex API.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ The fully qualified name of a class implementing IIndexFragmentProvider interface.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.cdt.internal.core.index.provider.IIndexFragmentProvider"/>
</appInfo>
</annotation>
</attribute>
@@ -168,30 +198,30 @@ public class AcmeSDKProvider implements IReadOnlyPDOMProvider {
<annotation>
<appInfo>
- <meta.section type="since"/>
+ <meta.section type="apiInfo"/>
</appInfo>
<documentation>
- 4.0
+ 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="examples"/>
+ <meta.section type="since"/>
</appInfo>
<documentation>
- See subelement documentation
+ 4.0
</documentation>
</annotation>
<annotation>
<appInfo>
- <meta.section type="apiInfo"/>
+ <meta.section type="examples"/>
</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
+ See subelement documentation
</documentation>
</annotation>
@@ -200,7 +230,7 @@ For export functionality, see package org.eclipse.cdt.core.index.export
<meta.section type="implementation"/>
</appInfo>
<documentation>
- [Enter information about supplied implementation of this extension point.]
+ See subelement documentation
</documentation>
</annotation>
@@ -209,7 +239,7 @@ For export functionality, see package org.eclipse.cdt.core.index.export
<meta.section type="copyright"/>
</appInfo>
<documentation>
- Copyright (c) 2007 Symbian Software Systems and others.
+ 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
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.java
index ed0d6811f88..c8aef901061 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
+ * Copyright (c) 2006, 2011 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.callhierarchy;
@@ -23,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexFile;
+import org.eclipse.cdt.core.index.IIndexManager;
import org.eclipse.cdt.core.index.IIndexName;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
@@ -150,7 +152,7 @@ public class CHContentProvider extends AsyncTreeContentProvider {
private Object[] asyncronouslyComputeReferencedBy(CHNode parent) throws CoreException, InterruptedException {
ICProject[] scope= CoreModel.getDefault().getCModel().getCProjects();
- IIndex index= CCorePlugin.getIndexManager().getIndex(scope);
+ IIndex index= CCorePlugin.getIndexManager().getIndex(scope, IIndexManager.ADD_EXTENSION_FRAGMENTS);
index.acquireReadLock();
try {
return CHQueries.findCalledBy(this, parent, index, NPM);
@@ -161,7 +163,7 @@ public class CHContentProvider extends AsyncTreeContentProvider {
private Object[] asyncronouslyComputeRefersTo(CHNode parent) throws CoreException, InterruptedException {
ICProject[] scope= CoreModel.getDefault().getCModel().getCProjects();
- IIndex index= CCorePlugin.getIndexManager().getIndex(scope);
+ IIndex index= CCorePlugin.getIndexManager().getIndex(scope, IIndexManager.ADD_EXTENSION_FRAGMENTS);
index.acquireReadLock();
try {
return CHQueries.findCalls(this, parent, index, NPM);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java
index 52b26bcd1db..67b81215a74 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java
@@ -56,6 +56,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
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.IIndexManager;
import org.eclipse.cdt.core.index.IIndexName;
import org.eclipse.cdt.core.index.IndexLocationFactory;
import org.eclipse.cdt.core.model.CoreModel;
@@ -487,7 +488,8 @@ public abstract class PDOMSearchQuery implements ISearchQuery {
result.setIndexerBusy(!CCorePlugin.getIndexManager().isIndexerIdle());
try {
- IIndex index= CCorePlugin.getIndexManager().getIndex(projects, 0);
+ IIndex index= CCorePlugin.getIndexManager().getIndex(projects,
+ IIndexManager.ADD_EXTENSION_FRAGMENTS);
try {
index.acquireReadLock();
} catch (InterruptedException e) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java
index 4cd34574581..c86b8f11f33 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java
@@ -71,7 +71,7 @@ public class PDOMSearchTextSelectionQuery extends PDOMSearchQuery {
return Status.OK_STATUS;
}
}
- binding = index.findBinding(searchName);
+ binding = ast.getIndex().findBinding(searchName);
binding= CPPTemplates.findDeclarationForSpecialization(binding);
if (binding != null) {
label= labelForBinding(index, binding, label);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHierarchyModel.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHierarchyModel.java
index 46950694069..8aa74d620e6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHierarchyModel.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHierarchyModel.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -26,6 +26,7 @@ import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexManager;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
@@ -53,7 +54,7 @@ class THHierarchyModel {
static final int END_OF_COMPUTATION = 0;
private static final ISchedulingRule RULE = new THSchedulingRule();
- private static final Object[] NO_CHILDREN= new Object[0];
+ private static final Object[] NO_CHILDREN= {};
private ICElement fInput;
private int fHierarchyKind;
@@ -148,7 +149,7 @@ class THHierarchyModel {
THGraph graph= new THGraph();
try {
ICProject[] scope= CoreModel.getDefault().getCModel().getCProjects();
- IIndex index= CCorePlugin.getIndexManager().getIndex(scope);
+ IIndex index= CCorePlugin.getIndexManager().getIndex(scope, IIndexManager.ADD_EXTENSION_FRAGMENTS);
index.acquireReadLock();
try {
if (monitor.isCanceled())

Back to the top