mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
tidy code
This commit is contained in:
parent
43e699e18c
commit
bea41263df
1 changed files with 9 additions and 11 deletions
|
@ -40,14 +40,14 @@ import org.eclipse.core.runtime.Platform;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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. This is done
|
* fragments contributed via the CIndex extension point.
|
||||||
* for the current project state (on a per-project basis).
|
|
||||||
* <p>
|
* <p>
|
||||||
* It is an internal class, and is public only for testing purposes.
|
* It is an internal class, and is public only for testing purposes.
|
||||||
*/
|
*/
|
||||||
public final class IndexProviderManager implements IElementChangedListener {
|
public final class IndexProviderManager implements IElementChangedListener {
|
||||||
public static final String READ_ONLY_PDOM_PROVIDER= "ReadOnlyPDOMProvider"; //$NON-NLS-1$
|
public static final String READ_ONLY_PDOM_PROVIDER= "ReadOnlyPDOMProvider"; //$NON-NLS-1$
|
||||||
private IIndexFragmentProvider[] allProviders;
|
private IIndexFragmentProvider[] allProviders;
|
||||||
|
private Map provisionMap= new HashMap();
|
||||||
|
|
||||||
public IndexProviderManager() {
|
public IndexProviderManager() {
|
||||||
List providers = new ArrayList();
|
List providers = new ArrayList();
|
||||||
|
@ -127,23 +127,22 @@ public final class IndexProviderManager implements IElementChangedListener {
|
||||||
allProviders = newAllProviders;
|
allProviders = newAllProviders;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map map = new HashMap();
|
|
||||||
private boolean providesForProject(IIndexProvider provider, IProject project) {
|
private boolean providesForProject(IIndexProvider provider, IProject project) {
|
||||||
List key = new ArrayList();
|
List key = new ArrayList();
|
||||||
key.add(provider);
|
key.add(provider);
|
||||||
key.add(project);
|
key.add(project);
|
||||||
|
|
||||||
if(!map.containsKey(key)) {
|
if(!provisionMap.containsKey(key)) {
|
||||||
try {
|
try {
|
||||||
ICProject cproject= CoreModel.getDefault().create(project);
|
ICProject cproject= CoreModel.getDefault().create(project);
|
||||||
map.put(key, new Boolean(provider.providesFor(cproject)));
|
provisionMap.put(key, new Boolean(provider.providesFor(cproject)));
|
||||||
} catch(CoreException ce) {
|
} catch(CoreException ce) {
|
||||||
CCorePlugin.log(ce);
|
CCorePlugin.log(ce);
|
||||||
map.put(key, Boolean.FALSE);
|
provisionMap.put(key, Boolean.FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ((Boolean) map.get(key)).booleanValue();
|
return ((Boolean) provisionMap.get(key)).booleanValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void elementChanged(ElementChangedEvent event) {
|
public void elementChanged(ElementChangedEvent event) {
|
||||||
|
@ -166,19 +165,18 @@ public final class IndexProviderManager implements IElementChangedListener {
|
||||||
processDelta(children[i]);
|
processDelta(children[i]);
|
||||||
break;
|
break;
|
||||||
case ICElement.C_PROJECT:
|
case ICElement.C_PROJECT:
|
||||||
// Find the appropriate indexer and pass the delta on
|
|
||||||
final ICProject cproject = (ICProject)delta.getElement();
|
final ICProject cproject = (ICProject)delta.getElement();
|
||||||
switch (delta.getKind()) {
|
switch (delta.getKind()) {
|
||||||
case ICElementDelta.REMOVED:
|
case ICElementDelta.REMOVED:
|
||||||
List toRemove = new ArrayList();
|
List toRemove = new ArrayList();
|
||||||
for(Iterator i = map.keySet().iterator(); i.hasNext(); ) {
|
for(Iterator i = provisionMap.keySet().iterator(); i.hasNext(); ) {
|
||||||
List key = (List) i.next();
|
List key = (List) i.next();
|
||||||
if(key.contains(cproject.getProject())) {
|
if(key.contains(cproject.getProject())) {
|
||||||
toRemove.add(key);
|
toRemove.add(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(Iterator i = toRemove.iterator(); i.hasNext(); ) {
|
for(Iterator i = toRemove.iterator(); i.hasNext(); ) {
|
||||||
map.remove(i.next());
|
provisionMap.remove(i.next());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue