Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Problems with ExternalSettingsProvider usage --> BUG?

What version of CDT are you using?

If you think you've found a bug in HEAD, please open a bug at, preferably with a test.
There are some tests for external settings providers in ExternalSettingsProviderTests to get you going.


On 14 October 2010 10:15, Tomljenovic Marko (CDG-SMT/EMT1) <Marko.Tomljenovic@xxxxxxxxxxxx> wrote:
I found out the following thing:

It looks like I found a bug. When the external setting provider returns an already existing macro but with a different value then this macro is still stored in the .cproject file. But it is located before the 'old' macro.
I assume then that this file is read like this: Read in all macros in the order like they are written in the .cproject file and store the macros in a hash map where the key is the macro name.
But now we have the same macro (regarding name) twice in the .cproject file. The new one comes before the old one and therefor the value of the old one always overwrites the new value. This would then lead to my mentioned problem.

Is this a bug or the wanted behaviour? I assume it is a bug!

Greets Marko

-----Ursprüngliche Nachricht-----
Von: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] Im Auftrag von Tomljenovic Marko (CDG-SMT/EMT1)
Gesendet: Donnerstag, 14. Oktober 2010 09:50
An: CDT General developers list.
Betreff: [cdt-dev] Problems with ExternalSettingsProvider usage

Hello guys,
Does anybody have some experience with the usage of the ExternalSettingsProvider extension point?
We are currently using CDT 6.0.2.

I have done the following things:

-I have registered an ExternalSettingProvider class
-In an example command I set the providers on the project, and when I execute the command the 2nd time I call the updateExternalSettingsProviders

Class ExternalSettingsProvider:
 public CExternalSetting[] getSettings(final IProject prj, final ICConfigurationDescription cfg) {
   // Create an example macro
   String value = new SimpleDateFormat("ssSSS").format(new Date());

   CExternalSetting setting =
       new CExternalSetting(new String[] { "org.eclipse.cdt.core.gcc", "org.eclipse.cdt.core.g++" }, new String[] {
           "org.eclipse.cdt.core.cSource", "org.eclipse.cdt.core.asmSource" }, null,
           new ICSettingEntry[] { new CMacroEntry("EXAMPLE_MACRO", value, ICSettingEntry.MACRO) });
   System.err.println("CExternalSettingProvider.getSettings() - " + value);
   return new CExternalSetting[] { setting };

Command code to register/update the ExternalSettingsProvider
         ICConfigurationDescription activeConfiguration = null;
         String[] ids = new String[] { "bdom.cdt.settings.provider" };
         IProject prj = (IProject) obj;
         if (!set) {
           set = true;

           ICProjectDescription cProjectDescr = CCorePlugin.getDefault().getProjectDescription(prj, true);
           activeConfiguration = cProjectDescr.getActiveConfiguration();

           try {
             CoreModel.getDefault().setProjectDescription(prj, cProjectDescr, true, new NullProgressMonitor());
           catch (CoreException e) {
             // TODO Auto-generated catch block
         else {

           ICProjectDescription projectDescription2 = CCorePlugin.getDefault().getProjectDescription(prj, true);
           activeConfiguration = projectDescription2.getActiveConfiguration();
           try {
             CoreModel.getDefault().setProjectDescription(prj, projectDescription2, true, new NullProgressMonitor());
           catch (CoreException e) {
             // TODO Auto-generated catch block

Problems with this implementation
The example macro is set properly when the external settings provider is called the first time. But when it is called the 2nd time the changed macro value is not visible in the project properties. In the .cproject file though the new macro value is stored somehow.

Does anybody has a clue on what I am doing wrong?

Greets Marko
cdt-dev mailing list
cdt-dev mailing list

Back to the top