mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 14:15:23 +02:00
Initial support for non-PDOM index fragments contributed through an
extension.
This commit is contained in:
parent
7a3c9ba3a1
commit
9972595fc7
13 changed files with 212 additions and 120 deletions
|
@ -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]));
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,12 +43,22 @@ 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)
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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,16 +162,51 @@ 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>
|
||||
<h2>ReadOnlyIndexFragmentProvider</h2>
|
||||
<p>
|
||||
This subelement of CIndex allows ISVs to contribute read-only index fragments to the CDT Index. This extension point imposes no limitations on how the index information is collected and stored. The index fragments may, for example, be based on data dynamically fetched from a remote server.
|
||||
<p>
|
||||
The only information needed for this extension point is the fully qualified name of a class implementing the org.eclipse.cdt.core.index.IIndexFragmentProvider interface. This class will be consulted during the eclipse session for the appropriate read-only content to add to the logical index. The logical index is accessible via the org.eclipse.core.index.IIndex API.
|
||||
</documentation>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<attribute name="class" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The fully qualified name of a class implementing IIndexFragmentProvider interface.
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.internal.core.index.provider.IIndexFragmentProvider"/>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="apiInfo"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
Index content provided by ISVs under this extension point will be accessible via the logical index org.eclipse.core.index.IIndex API
|
||||
|
||||
For export functionality, see package org.eclipse.cdt.core.index.export
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="since"/>
|
||||
|
@ -184,23 +225,12 @@ public class AcmeSDKProvider implements IReadOnlyPDOMProvider {
|
|||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<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="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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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())
|
||||
|
|
Loading…
Add table
Reference in a new issue