1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 10:46:02 +02:00

new method getDefaultBinaryParser()

This commit is contained in:
Alain Magloire 2003-03-31 03:44:10 +00:00
parent 447b3b553a
commit c593b78e02

View file

@ -163,32 +163,40 @@ public class CCorePlugin extends Plugin {
public IBinaryParser getBinaryParser(IProject project) throws CoreException { public IBinaryParser getBinaryParser(IProject project) throws CoreException {
IBinaryParser parser = null; IBinaryParser parser = null;
try { if (project != null) {
ICDescriptor cdesc = (ICDescriptor) getCProjectDescription(project); try {
ICExtensionReference[] cextensions = cdesc.get(BINARY_PARSER_UNIQ_ID); ICDescriptor cdesc = (ICDescriptor) getCProjectDescription(project);
if (cextensions.length > 0) ICExtensionReference[] cextensions = cdesc.get(BINARY_PARSER_UNIQ_ID);
parser = (IBinaryParser) cextensions[0].createExtension(); if (cextensions.length > 0)
} catch (CoreException e) { parser = (IBinaryParser) cextensions[0].createExtension();
} catch (CoreException e) {
}
} }
if (parser == null) { if (parser == null) {
String id = getPluginPreferences().getDefaultString(PREF_BINARY_PARSER); parser = getDefaultBinaryParser();
if (id == null || id.length() == 0) { }
id = DEFAULT_BINARY_PARSER_UNIQ_ID; return parser;
} }
IExtensionPoint extensionPoint = getDescriptor().getExtensionPoint(BINARY_PARSER_SIMPLE_ID);
IExtension extension = extensionPoint.getExtension(id); public IBinaryParser getDefaultBinaryParser() throws CoreException {
if (extension != null) { IBinaryParser parser = null;
IConfigurationElement element[] = extension.getConfigurationElements(); String id = getPluginPreferences().getDefaultString(PREF_BINARY_PARSER);
for (int i = 0; i < element.length; i++) { if (id == null || id.length() == 0) {
if (element[i].getName().equalsIgnoreCase("cextension")) { id = DEFAULT_BINARY_PARSER_UNIQ_ID;
parser = (IBinaryParser) element[i].createExecutableExtension("run"); }
break; IExtensionPoint extensionPoint = getDescriptor().getExtensionPoint(BINARY_PARSER_SIMPLE_ID);
} IExtension extension = extensionPoint.getExtension(id);
if (extension != null) {
IConfigurationElement element[] = extension.getConfigurationElements();
for (int i = 0; i < element.length; i++) {
if (element[i].getName().equalsIgnoreCase("cextension")) {
parser = (IBinaryParser) element[i].createExecutableExtension("run");
break;
} }
} else {
IStatus s = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, "No Binary Format", null);
throw new CoreException(s);
} }
} else {
IStatus s = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, "No Binary Format", null);
throw new CoreException(s);
} }
return parser; return parser;
} }