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 10:51 Go to next message
Solveigh Matthies is currently offline Solveigh Matthies
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 05:02 Go to previous message
Solveigh Matthies is currently offline Solveigh Matthies
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;
					selectedProvider.setCompilerPattern(selectedProvider.getCompilerPattern()+"|(/acc/sys/L865/cdk/g\\+\\+)");			
					selectedProvider.setResourceScope(AbstractBuildCommandParser.ResourceScope.FILE);
					//providers.remove(i);
					providers2.add(selectedProvider);
					//defaultIds2[i]=providers.get(i).getId();
				} else {
					providers2.add(providers.get(i));
					defaultIds2[i]=defaultIds[i];
				}
			}
			// 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) {
			LOGGER.error(e.getMessage());
		}
Previous Topic:CDT GNU autotool C++ project: automatic makefile generation for subdirs
Next Topic:Adding items to syntax coloring
Goto Forum:
  


Current Time: Thu Jul 31 11:51:06 EDT 2014

Powered by FUDForum. Page generated in 0.04716 seconds