Skip to content

Commit c005feb

Browse files
committed
Copy methods removed in transition from CDT 8.1 to CDT 8.2.
The previous modification was not creating a good project configuration and it produced issues with the indexer.
1 parent 9d8618a commit c005feb

File tree

2 files changed

+51
-10
lines changed

2 files changed

+51
-10
lines changed

it.baeyens.arduino.core/plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@
267267
allPopups="true"
268268
locationURI="toolbar:org.eclipse.ui.main.toolbar">
269269
<toolbar
270-
id="it.baeyens.arduino.toolbar.main">
270+
id="it.baeyens.arduino.toolbar.main" label="Arduino">
271271
<command
272272
commandId="it.baeyens.arduino.actions.ArduinoBuildAction"
273273
disabledIcon="icons/check_disabled.png"

it.baeyens.arduino.core/src/it/baeyens/arduino/tools/ShouldHaveBeenInCDT.java

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
package it.baeyens.arduino.tools;
22

3+
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
34
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper;
5+
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
6+
import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport;
47
import org.eclipse.cdt.core.model.CoreModel;
58
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
69
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
710
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
811
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
912
import org.eclipse.cdt.managedbuilder.core.IBuilder;
13+
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
1014
import org.eclipse.cdt.managedbuilder.core.IToolChain;
1115
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
1216
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
@@ -20,21 +24,22 @@
2024
import it.baeyens.arduino.ui.BuildConfigurationsPage.ConfigurationDescriptor;
2125

2226
import java.util.ArrayList;
27+
import java.util.List;
2328

2429
@SuppressWarnings("restriction")
2530
// TOFIX Get this code in CDT so I should not have to do this
2631
public class ShouldHaveBeenInCDT {
2732
/*
2833
* Copied from wizard STDWizardHandler package package org.eclipse.cdt.managedbuilder.ui.wizards;; This method creates the .cProject file in your
2934
* project.
30-
*
35+
*
3136
* BK: modified this and made it work for multiple configs.
3237
*/
3338
/**
3439
* This method creates the .cProject file in your project. it is intended to be used with newly created projects. Using this method with project
3540
* that have existed for some time is unknown
36-
*
37-
*
41+
*
42+
*
3843
* @param project
3944
* The newly created project that needs a .cproject file.
4045
* @param alCfgs
@@ -101,16 +106,52 @@ public static void setCProjectDescription(IProject project,
101106
}
102107
CConfigurationData data = cfg.getConfigurationData();
103108
ICConfigurationDescription cfgDes = des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
104-
105-
if (cfgDes instanceof ILanguageSettingsProvidersKeeper) {
106-
ILanguageSettingsProvidersKeeper lspk = (ILanguageSettingsProvidersKeeper)cfgDes;
107-
lspk.setDefaultLanguageSettingsProvidersIds(new String[] {alCfgs.get(i).ToolchainID});
108-
}
109-
// ConfigurationDataProvider.setDefaultLanguageSettingsProviders(project, cfg, cfgDes);
109+
110+
setDefaultLanguageSettingsProviders(project, alCfgs.get(i), cfg, cfgDes);
110111
}
111112
monitor.worked(50);
112113
mngr.setProjectDescription(project, des);
113114

114115
}
115116

117+
private static void setDefaultLanguageSettingsProviders(IProject project, ConfigurationDescriptor cfgDes, IConfiguration cfg, ICConfigurationDescription cfgDescription) {
118+
// propagate the preference to project properties
119+
boolean isPreferenceEnabled = ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(null);
120+
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, isPreferenceEnabled);
121+
122+
if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
123+
ILanguageSettingsProvidersKeeper lspk = (ILanguageSettingsProvidersKeeper)cfgDescription;
124+
125+
lspk.setDefaultLanguageSettingsProvidersIds(new String[] {cfgDes.ToolchainID});
126+
127+
List<ILanguageSettingsProvider> providers = getDefaultLanguageSettingsProviders(cfg, cfgDescription);
128+
lspk.setLanguageSettingProviders(providers);
129+
}
130+
}
131+
132+
private static List<ILanguageSettingsProvider> getDefaultLanguageSettingsProviders(IConfiguration cfg, ICConfigurationDescription cfgDescription) {
133+
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
134+
String[] ids = cfg != null ? cfg.getDefaultLanguageSettingsProviderIds() : null;
135+
136+
if (ids == null) {
137+
// Try with legacy providers
138+
ids = ScannerDiscoveryLegacySupport.getDefaultProviderIdsLegacy(cfgDescription);
139+
}
140+
141+
if (ids != null) {
142+
for (String id : ids) {
143+
ILanguageSettingsProvider provider = null;
144+
if (!LanguageSettingsManager.isPreferShared(id)) {
145+
provider = LanguageSettingsManager.getExtensionProviderCopy(id, false);
146+
}
147+
if (provider == null) {
148+
provider = LanguageSettingsManager.getWorkspaceProvider(id);
149+
}
150+
providers.add(provider);
151+
}
152+
}
153+
154+
return providers;
155+
}
156+
116157
}

0 commit comments

Comments
 (0)