Search in sources :

Example 1 with IBinaryParser

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;
}
Also used : ICProjectDescription(org.eclipse.cdt.core.settings.model.ICProjectDescription) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) LinkedList(java.util.LinkedList) IBinaryParser(org.eclipse.cdt.core.IBinaryParser) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) CoreException(org.eclipse.core.runtime.CoreException) IExtension(org.eclipse.core.runtime.IExtension) ICConfigurationDescription(org.eclipse.cdt.core.settings.model.ICConfigurationDescription)

Example 2 with IBinaryParser

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;
}
Also used : IBinaryParser(org.eclipse.cdt.core.IBinaryParser) IFile(org.eclipse.core.resources.IFile) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) CoreException(org.eclipse.core.runtime.CoreException) IExtension(org.eclipse.core.runtime.IExtension) IBinaryObject(org.eclipse.cdt.core.IBinaryParser.IBinaryObject) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Aggregations

IBinaryParser (org.eclipse.cdt.core.IBinaryParser)2 CoreException (org.eclipse.core.runtime.CoreException)2 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)2 IExtension (org.eclipse.core.runtime.IExtension)2 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)2 LinkedList (java.util.LinkedList)1 IBinaryObject (org.eclipse.cdt.core.IBinaryParser.IBinaryObject)1 ICConfigurationDescription (org.eclipse.cdt.core.settings.model.ICConfigurationDescription)1 ICProjectDescription (org.eclipse.cdt.core.settings.model.ICProjectDescription)1 IFile (org.eclipse.core.resources.IFile)1