use of org.eclipse.cdt.core.IBinaryParser in project linuxtools by eclipse.
the class STSymbolManager method getBinaryParser.
/**
* Retrieve the list of binary parsers defined for the given project.
* @param project The project.
* @return The binary parsers for this project.
*/
private List<IBinaryParser> getBinaryParser(IProject project) {
List<IBinaryParser> parsers = new LinkedList<>();
ICProjectDescription projDesc = CCorePlugin.getDefault().getProjectDescription(project);
if (projDesc == null) {
return parsers;
}
ICConfigurationDescription[] cfgs = projDesc.getConfigurations();
String[] binaryParserIds = CoreModelUtil.getBinaryParserIds(cfgs);
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, CCorePlugin.BINARY_PARSER_SIMPLE_ID);
for (String id : binaryParserIds) {
IExtension extension = extensionPoint.getExtension(id);
if (extension != null) {
IConfigurationElement[] element = extension.getConfigurationElements();
for (IConfigurationElement element2 : element) {
if (element2.getName().equalsIgnoreCase("cextension")) {
// $NON-NLS-1$
try {
// $NON-NLS-1$
IBinaryParser parser = (IBinaryParser) element2.createExecutableExtension("run");
if (parser != null) {
parsers.add(parser);
}
} catch (CoreException e) {
// TODO: handle exception ?
}
}
}
}
}
return parsers;
}
use of org.eclipse.cdt.core.IBinaryParser in project linuxtools by eclipse.
the class STSymbolManager method getBinaryObject.
/**
* Gets the IBinaryObject corresponding to the given path (absolute path in filesystem). If a IBinaryObject
* corresponding to the given path has been already built by eclipse, return it. Otherwise build a new
* IBinaryObject, according to project preferences. Note that it may return null if the path is invalid, or is not a
* valid binary file.
* @param path
* @param defaultparser
* @return a IBinaryObject
*/
private IBinaryObject getBinaryObject(IPath path, IBinaryParser defaultparser) {
IFile c = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
List<IBinaryParser> parsers;
if (c != null) {
IBinaryObject object = getAlreadyExistingBinaryObject(c);
if (object != null) {
return object;
}
parsers = getBinaryParser(c.getProject());
} else {
parsers = new LinkedList<>();
}
if (defaultparser == null) {
try {
defaultparser = CCorePlugin.getDefault().getDefaultBinaryParser();
} catch (CoreException e) {
Activator.getDefault().getLog().log(e.getStatus());
}
}
if (defaultparser != null) {
parsers.add(defaultparser);
}
IBinaryObject ret = buildBinaryObject(path, parsers);
if (ret == null) {
// trying all BinaryParsers...
parsers.clear();
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, CCorePlugin.BINARY_PARSER_SIMPLE_ID);
for (IExtension extension : extensionPoint.getExtensions()) {
if (extension != null) {
IConfigurationElement[] element = extension.getConfigurationElements();
for (IConfigurationElement element2 : element) {
if (element2.getName().equalsIgnoreCase("cextension")) {
// $NON-NLS-1$
IBinaryParser parser;
try {
// $NON-NLS-1$
parser = (IBinaryParser) element2.createExecutableExtension("run");
parsers.add(parser);
} catch (CoreException e) {
}
}
}
}
}
ret = buildBinaryObject(path, parsers);
}
return ret;
}
Aggregations