[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [cdt-dev] Problem with adding entries to language settings provider in CDT plugin
|
Hi Erwin!
I did go through some pains trying to add entries programatically somewhat recently.
You can see the hurdles in CompilationDatabaseParser class.
I would double check that you have a writable ICConfigurationDescription. If not, I think you have to get a writable description and set it within a WorkspaceJob. Also make sure you get the correct language settings provider from this writable description. See CompilationDatabaseParser.scheduleOnWritableCfgDescription for example.
I also remember the description was not seen as dirty just by changing language settings. I did a hack by setting a “session property” on the project description. See CompilationDatabaseParser.touchProjectDes.
I don’t really master any of these parts but maybe one of those suggestions will help you.
Marc-André
> On Jul 13, 2020, at 11:21 AM, Waterlander, Erwin <erwin.waterlander@xxxxxxxxx> wrote:
>
> Hi,
>
> When I add an editable language settings provider via the plugin.xml to a CDT plugin per configuration, the entries added in the plugin.xml are not there.
> And when I add entries programmatically to the provider they are also not there.
> What am I doing wrong?
>
> I took the example from the CDT plugin developers guide and added this to the plugin.xml:
>
> <extension
> point="org.eclipse.cdt.core.LanguageSettingsProvider">
> <provider
> class="org.eclipse.cdt.core.language.settings.providers.LanguageSettingsGenericProvider"
> id="org.eclipse.cdt.example.toolchain.provider1"
> name="Example Provider"
> prefer-non-shared="true">
> <entry
> kind="includePath"
> name="org.eclipse.cdt.example.toolchain.entry2"
> value="/project/include">
> </entry>
> </provider>
> </extension>
> <extension
> point="org.eclipse.cdt.ui.LanguageSettingsProviderAssociation">
> <id-association
> id="org.eclipse.cdt.example.toolchain.provider1"
> ui-edit-entries="true">
> </id-association>
> </extension>
>
>
> <configuration
> id="org.eclipse.cdt.example.toolchain.configuration1"
> languageSettingsProviders="org.eclipse.cdt.example.toolchain.provider1;org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider;org.eclipse.cdt.ui.UserLanguageSettingsProvider"
> name="Test Release">
> .....
> </configuration>
>
>
> Adding entries programmatically:
>
>
> LanguageSettingsGenericProvider provider = null;
>
> List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
> .getLanguageSettingProviders();
> for (ILanguageSettingsProvider p : providers) {
> if (p.getId().contains("example")) {
> provider = (LanguageSettingsGenericProvider) p;
> break;
> }
> }
>
> System.out.println("provider id: " + provider.getId());
> // Output: provider id: org.eclipse.cdt.example.toolchain.provider1
> // No number suffix (?)
>
> // Get existing entries (from plugin.xml).
> List<ICLanguageSettingEntry> entries = provider.getSettingEntries(cfgDescription, project,
> "org.eclipse.cdt.core.cSource");
>
> // entries appears to be null. I would expect to see the include path from plugin.xml.
>
> if (entries == null)
> entries = new ArrayList<ICLanguageSettingEntry>();
>
> // Add extra include path
> CIncludePathEntry entry;
> entry = CDataUtil.createCIncludePathEntry("/project/include/extra", ICSettingEntry.NONE);
> entries.add(entry);
>
> provider.setSettingEntries(cfgDescription, project, "org.eclipse.cdt.core.cSource", entries);
>
> CoreModel.getDefault().setProjectDescription(project, projectDescription);
>
>
> regards,
>
> --
> Erwin
>
> ---------------------------------------------------------------------
> Intel Benelux B.V.
> Registered in The Netherlands under number 24134020
> Statutory seat: Rotterdam
> Registered address: Capronilaan 37, 1119NG Schiphol-Rijk
>
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
>
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/cdt-dev