mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-05 23:35:48 +02:00
Code streamlining.
This commit is contained in:
parent
a421c6d1f1
commit
3d9f5a3c93
1 changed files with 25 additions and 34 deletions
|
@ -11,16 +11,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
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.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import com.ibm.icu.text.MessageFormat;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
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;
|
||||||
|
@ -44,8 +34,16 @@ import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.osgi.service.resolver.VersionRange;
|
import org.eclipse.osgi.service.resolver.VersionRange;
|
||||||
|
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.
|
||||||
|
@ -106,7 +104,7 @@ public final class IndexProviderManager implements IElementChangedListener {
|
||||||
IExtension extension = extensions[i];
|
IExtension extension = extensions[i];
|
||||||
try {
|
try {
|
||||||
IConfigurationElement[] ce = extension.getConfigurationElements();
|
IConfigurationElement[] ce = extension.getConfigurationElements();
|
||||||
for (int j=0; j<ce.length; j++) {
|
for (int j= 0; j < ce.length; j++) {
|
||||||
if (ce[j].getName().equals(ELEMENT_RO_PDOMPROVIDER)) {
|
if (ce[j].getName().equals(ELEMENT_RO_PDOMPROVIDER)) {
|
||||||
IIndexProvider provider = (IIndexProvider) ce[j].createExecutableExtension(ATTRIBUTE_CLASS);
|
IIndexProvider provider = (IIndexProvider) ce[j].createExecutableExtension(ATTRIBUTE_CLASS);
|
||||||
|
|
||||||
|
@ -114,15 +112,13 @@ public final class IndexProviderManager implements IElementChangedListener {
|
||||||
provider = new ReadOnlyPDOMProviderBridge((IReadOnlyPDOMProvider) provider);
|
provider = new ReadOnlyPDOMProviderBridge((IReadOnlyPDOMProvider) provider);
|
||||||
providers.add(provider);
|
providers.add(provider);
|
||||||
} else {
|
} else {
|
||||||
CCorePlugin.log(MessageFormat.format(
|
CCorePlugin.log(NLS.bind(Messages.IndexProviderManager_0,
|
||||||
Messages.IndexProviderManager_0,
|
extension.getContributor().getName()));
|
||||||
new Object[] { extension.getContributor().getName() }
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(CoreException ce) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(ce);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,15 +145,15 @@ public final class IndexProviderManager implements IElementChangedListener {
|
||||||
for (int j= 0; j < fragments.length; j++) {
|
for (int j= 0; j < fragments.length; j++) {
|
||||||
try {
|
try {
|
||||||
processCandidate(id2fragment, fragments[j]);
|
processCandidate(id2fragment, fragments[j]);
|
||||||
} catch(InterruptedException ie) {
|
} catch (InterruptedException e) {
|
||||||
CCorePlugin.log(ie); // continue with next candidate
|
CCorePlugin.log(e); // continue with next candidate
|
||||||
} catch(CoreException ce) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(ce); // continue with next candidate
|
CCorePlugin.log(e); // continue with next candidate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(CoreException ce) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(ce); // move to next provider
|
CCorePlugin.log(e); // move to next provider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,13 +163,9 @@ public final class IndexProviderManager implements IElementChangedListener {
|
||||||
if (entry.getValue() == null) {
|
if (entry.getValue() == null) {
|
||||||
String key= entry.getKey();
|
String key= entry.getKey();
|
||||||
if (!compatibleFragmentUnavailable.contains(key)) {
|
if (!compatibleFragmentUnavailable.contains(key)) {
|
||||||
String msg= MessageFormat.format(
|
String msg= NLS.bind(
|
||||||
Messages.IndexProviderManager_NoCompatibleFragmentsAvailable,
|
Messages.IndexProviderManager_NoCompatibleFragmentsAvailable, key);
|
||||||
new Object[]{key}
|
CCorePlugin.log(new Status(IStatus.WARNING, CCorePlugin.PLUGIN_ID, msg));
|
||||||
);
|
|
||||||
IStatus status= new Status(IStatus.WARNING, CCorePlugin.PLUGIN_ID,
|
|
||||||
IStatus.WARNING, msg, null);
|
|
||||||
CCorePlugin.log(status);
|
|
||||||
compatibleFragmentUnavailable.add(key);
|
compatibleFragmentUnavailable.add(key);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -295,7 +287,7 @@ public final class IndexProviderManager implements IElementChangedListener {
|
||||||
try {
|
try {
|
||||||
ICProject cproject= CoreModel.getDefault().create(project);
|
ICProject cproject= CoreModel.getDefault().create(project);
|
||||||
provisionMap.put(key, new Boolean(provider.providesFor(cproject)));
|
provisionMap.put(key, new Boolean(provider.providesFor(cproject)));
|
||||||
} catch(CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
provisionMap.put(key, Boolean.FALSE);
|
provisionMap.put(key, Boolean.FALSE);
|
||||||
}
|
}
|
||||||
|
@ -324,12 +316,11 @@ public final class IndexProviderManager implements IElementChangedListener {
|
||||||
processDelta(children[i]);
|
processDelta(children[i]);
|
||||||
break;
|
break;
|
||||||
case ICElement.C_PROJECT:
|
case ICElement.C_PROJECT:
|
||||||
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<ProvisionMapKey> toRemove = new ArrayList<ProvisionMapKey>();
|
List<ProvisionMapKey> toRemove = new ArrayList<ProvisionMapKey>();
|
||||||
for (Iterator<ProvisionMapKey> i = provisionMap.keySet().iterator(); i.hasNext(); ) {
|
for (ProvisionMapKey key : provisionMap.keySet()) {
|
||||||
ProvisionMapKey key = i.next();
|
|
||||||
if (key.getProject().equals(cproject.getProject())) {
|
if (key.getProject().equals(cproject.getProject())) {
|
||||||
toRemove.add(key);
|
toRemove.add(key);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue