Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Adding language settings providers to built-in project types

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

On Wed, 12 Feb 2020 at 18:06, Jonah Graham <jonah@xxxxxxxxxxxxxxxx> wrote:
Hi Rob,

As far as I know this won't be possible, you need a project type or toolchain.

Can you explain your use case a little more? In particular is there a deficiency in the default language setting provider for your use case? Or are you providing some new functionality?

HTH,
Jonah

~~~
Jonah Graham
Kichwa Coders
www.kichwacoders.com


On Tue, 11 Feb 2020 at 08:29, Mega Masha <megamasha@xxxxxxxxx> wrote:
Hi all,

I've created a LanguageSettingsProvider, and I want its contributions to be used by default for CDT's C and C++ projects whenever my settingsProvider's plugin is installed. Ideally I want it to be used by all configurations, including Release, Debug, and any other configurations that might be contributed from elsewhere, but I don't know what those configs might be.

The CDT developer's FAQ says

"In order to get providers created for new projects with New Project Wizard - use org.eclipse.cdt.managedbuilder.core.buildDefinitions extension point to associate the provider with your project type. Specify attribute "languageSettingsProviders" for element "configuration" or "toolchain"."

However, I'm not defining the project type, configuration or toolchain that I want to be part of (most of those are defined by cdt). Is it possible to add my settingsProvider to those project types/configurations/toolchains using the plugin.xml file in the settingsProvider's plugin?

If so, can anyone provide an example of how, or where it's done?

Thanks,

Rob
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/cdt-dev

Back to the top