Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » How to configure scanner discovery programmatically?
How to configure scanner discovery programmatically? [message #1171955] Tue, 05 November 2013 15:51 Go to next message
Solveigh Matthies is currently offline Solveigh MatthiesFriend
Messages: 7
Registered: July 2009
Junior Member
How can I configure CDT's scanner discovery settings programmatically per project?
On the Preprocessor Include Paths, Macros etc. page in the project's preferences I can change the Compiler command pattern for the GCC Build Output Parser manually. But I would like to do so programmatically. How can I accomplish that?
Re: How to configure scanner discovery programmatically? [message #1174780 is a reply to message #1171955] Thu, 07 November 2013 10:02 Go to previous message
Solveigh Matthies is currently offline Solveigh MatthiesFriend
Messages: 7
Registered: July 2009
Junior Member
After diving deep into the CDT code I ended up with something like this:

		ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project, true);
		ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
		for (ICConfigurationDescription cfgDescription : cfgDescriptions) {

			String[] defaultIds = ((ILanguageSettingsProvidersKeeper) cfgDescription).getDefaultLanguageSettingsProvidersIds();
			String[] defaultIds2 = new String[defaultIds.length];
			List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
			List<ILanguageSettingsProvider> providers2 = new ArrayList<ILanguageSettingsProvider>();
			for (int i = 0; i < defaultIds.length; i++) {
				if( providers.get(i).getId().equals("org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser") ) {
					ILanguageSettingsProvider gccbop = LanguageSettingsManager.getWorkspaceProvider("org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser");
					ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(gccbop);
					ILanguageSettingsEditableProvider newProvider = LanguageSettingsManager.getProviderCopy((ILanguageSettingsEditableProvider)rawProvider, true);

					// FIXME this API is not considered stable yet
					AbstractBuildCommandParser selectedProvider = (AbstractBuildCommandParser) newProvider;
				} else {
			// remove the default id from the list
			((ILanguageSettingsProvidersKeeper) cfgDescription).setDefaultLanguageSettingsProvidersIds(defaultIds2);
			// set the adapted list of providers
			((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers2);
		// persist changes
		try {
			CoreModel.getDefault().setProjectDescription(project, prjDescription);
		} catch (CoreException e) {
Previous Topic:CDT GNU autotool C++ project: automatic makefile generation for subdirs
Next Topic:Adding items to syntax coloring
Goto Forum:

Current Time: Thu Apr 19 13:13:46 GMT 2018

Powered by FUDForum. Page generated in 0.01524 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software