Search in sources :

Example 1 with ICConfigurationDescription

use of org.eclipse.cdt.core.settings.model.ICConfigurationDescription 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 ICConfigurationDescription

use of org.eclipse.cdt.core.settings.model.ICConfigurationDescription in project linuxtools by eclipse.

the class CProjectBuildHelpers method isOptionCheckedInAutotoolsPrefStore.

/**
 * <h1>Option enabled check</h1>
 * <p> Check to see if an option is enabled in the .autotools configuration.</p>
 *
 * @param project  the IProject project which will be read to check if it is c or cpp.
 * @param optionId copy paste directly from .autotools. pick the 'ID' field value.
 * @return true if it is
 */
public static boolean isOptionCheckedInAutotoolsPrefStore(final IProject project, final String optionId) {
    // We define a 'final' variable that will be accessible in the runnable object.
    final BooleanWithGetSet userChoiceBool = new BooleanWithGetSet(false);
    // need to run this in the ui thread otherwise get SWT Exceptions
    // based on concurrency issues.
    Display.getDefault().syncExec(() -> {
        // Code copied from private methd: SetAutotoolsStringOptionValue.setOptionValue()
        // Except I added a line to save the configuration to disk as well.
        AutotoolsConfigurationManager.getInstance().syncConfigurations(project);
        ICConfigurationDescription cfgds = CoreModel.getDefault().getProjectDescription(project).getActiveConfiguration();
        if (cfgds != null) {
            IAConfiguration iaConfig = AutotoolsConfigurationManager.getInstance().getConfiguration(project, cfgds.getId());
            // Read option value
            IConfigureOption option = iaConfig.getOption(optionId);
            String optValString = option.getValue();
            boolean optVal = Boolean.parseBoolean(optValString);
            userChoiceBool.setVal(optVal);
        }
    });
    return userChoiceBool.getVal();
}
Also used : IAConfiguration(org.eclipse.cdt.internal.autotools.core.configure.IAConfiguration) ICConfigurationDescription(org.eclipse.cdt.core.settings.model.ICConfigurationDescription) IConfigureOption(org.eclipse.cdt.internal.autotools.core.configure.IConfigureOption)

Example 3 with ICConfigurationDescription

use of org.eclipse.cdt.core.settings.model.ICConfigurationDescription in project linuxtools by eclipse.

the class CProjectBuildHelpers method setOptionInAutotools.

/**
 * <h1>Set Autotools option and write to disk.</h1>
 *
 * <p> Set an option (as well as flags) in the .autotools configuration and update gui. <br>
 * It is oblivious as to whether the option ID is an option or a flag, it just looks at the ID in the xml. </p>
 *
 * <p> It is designed so that it can be ran from a background thread.
 * It syncs with the GUI thread to avoid concurrency exceptions. </p>
 *
 * <p> *this modifies gui checkbox options* <b>as well as</b> *saving the option to disk*. </p>
 *
 * @param project    the IProject project which will be read to check if it is c or cpp.
 * @param optId      Id of option to set. Take directly out of .autotools. a 'flag' is also an option.
 * @param optVal     string value of the option. e.g "true"  "1234";
 */
public static void setOptionInAutotools(final IProject project, final String optId, final String optVal) {
    // need to run this in the ui thread otherwise get SWT Exceptions
    // based on concurrency issues.
    Display.getDefault().syncExec(() -> {
        // Code copied from private methd: SetAutotoolsStringOptionValue.setOptionValue()
        // Except I added a line to save the configuration to disk as well.
        AutotoolsConfigurationManager.getInstance().syncConfigurations(project);
        ICConfigurationDescription cfgds = CoreModel.getDefault().getProjectDescription(project).getActiveConfiguration();
        if (cfgds != null) {
            IAConfiguration iaConfig = AutotoolsConfigurationManager.getInstance().getConfiguration(project, cfgds.getId());
            // Set option value.
            iaConfig.setOption(optId, optVal);
            // Save option to disk.
            AutotoolsConfigurationManager.getInstance().saveConfigs(project);
        }
    });
}
Also used : IAConfiguration(org.eclipse.cdt.internal.autotools.core.configure.IAConfiguration) ICConfigurationDescription(org.eclipse.cdt.core.settings.model.ICConfigurationDescription)

Aggregations

ICConfigurationDescription (org.eclipse.cdt.core.settings.model.ICConfigurationDescription)3 IAConfiguration (org.eclipse.cdt.internal.autotools.core.configure.IAConfiguration)2 LinkedList (java.util.LinkedList)1 IBinaryParser (org.eclipse.cdt.core.IBinaryParser)1 ICProjectDescription (org.eclipse.cdt.core.settings.model.ICProjectDescription)1 IConfigureOption (org.eclipse.cdt.internal.autotools.core.configure.IConfigureOption)1 CoreException (org.eclipse.core.runtime.CoreException)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 IExtension (org.eclipse.core.runtime.IExtension)1 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)1