Hi Jonah and list members in general,
Thanks for responding to my email.
An aggregating tool reads in language settings from a variety of types of projects (including projects that are designed to build and run using non-eclipse IDEs, using non-gcc compilers) and puts these settings in a file (say file1.json) within the project.
I have a langaugeSettingsProvider which reads in build settings from file1.json (if it's present) and supplies them to the CDT project. It extends LanguageSettingsSerializableProvider so that it can serialize the settings in an eclipse-standard way that can be stored with the rest of the project settings to make the settings travel with the project even if file1.json is subsequently deleted.
The presence of file1.json in a project's directory signifies that there are settings for my Provider to provide, which it duly does, responding to resource change events for that file and updating accordingly. The Provider shows up in Project Properties -> C/C++ General -> Preprocessor Include Pa... -> Providers. The problem is that when creating a new CDT project in a location that contains file1.json, the Provider has to be checked in the providers list. This must be done for each project, and projects are created or recreated fairly frequently.
I'm looking for a way to have the Provider automatically 'checked' when the project is created. At the moment, I'm doing something like the following:
final ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription( myProject );
for (ICConfigurationDescription config : projDesc.getConfigurations()) {
if (config instanceof CConfigurationDescriptionCache) {
/* panic about not being able to change a cache, but don't know how to get non-cached version */
}
List<ILanguageSettingsProvider> oldProviders = config.getLanguageSettingProviders();
String[] ids = new String[oldProviders.size() + 1];
...get IDs of existing providers, and add ID of own.
List<ILanguageSettingsProvider> newProviders = LanguageSettingsManager.createLanguageSettingsProviders( ids );
config.setLanguageSettingProviders(newProviders);
}
This code has the desired effect, but finding a way to make sure this code is called after project creation (while the workspace isn't locked, but before the user or other code in the plugin wants to do anything reliant on those settings) has lead to some scruffy code.
Is there really no way to have my settings provider used by default on new CDT projects? If not, is there a clean way to have the above code called once project creation is complete?
Many thanks for any knowledge/guidance,
Rob