|
1 | 1 | package it.baeyens.arduino.tools;
|
2 | 2 |
|
| 3 | +<<<<<<< HEAD |
3 | 4 | import it.baeyens.arduino.ui.BuildConfigurationsPage.ConfigurationDescriptor;
|
4 | 5 |
|
5 | 6 | import java.util.ArrayList;
|
6 | 7 |
|
| 8 | +======= |
| 9 | +import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; |
| 10 | +>>>>>>> 900a472803717354280efa2760da613018fee890 |
7 | 11 | import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper;
|
| 12 | +import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager; |
| 13 | +import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport; |
8 | 14 | import org.eclipse.cdt.core.model.CoreModel;
|
9 | 15 | import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
10 | 16 | import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
11 | 17 | import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
|
12 | 18 | import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
|
13 | 19 | import org.eclipse.cdt.managedbuilder.core.IBuilder;
|
| 20 | +import org.eclipse.cdt.managedbuilder.core.IConfiguration; |
14 | 21 | import org.eclipse.cdt.managedbuilder.core.IToolChain;
|
15 | 22 | import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
16 | 23 | import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
|
|
22 | 29 | import org.eclipse.core.runtime.CoreException;
|
23 | 30 | import org.eclipse.core.runtime.IProgressMonitor;
|
24 | 31 |
|
| 32 | +<<<<<<< HEAD |
| 33 | +======= |
| 34 | +import it.baeyens.arduino.ui.BuildConfigurationsPage.ConfigurationDescriptor; |
| 35 | + |
| 36 | +import java.util.ArrayList; |
| 37 | +import java.util.List; |
| 38 | + |
| 39 | +>>>>>>> 900a472803717354280efa2760da613018fee890 |
25 | 40 | @SuppressWarnings("restriction")
|
26 | 41 | // TOFIX Get this code in CDT so I should not have to do this
|
27 | 42 | public class ShouldHaveBeenInCDT {
|
28 | 43 | /*
|
29 | 44 | * Copied from wizard STDWizardHandler package package org.eclipse.cdt.managedbuilder.ui.wizards;; This method creates the .cProject file in your
|
30 | 45 | * project.
|
31 |
| - * |
| 46 | + * |
32 | 47 | * BK: modified this and made it work for multiple configs.
|
33 | 48 | */
|
34 | 49 | /**
|
35 | 50 | * This method creates the .cProject file in your project. it is intended to be used with newly created projects. Using this method with project
|
36 | 51 | * that have existed for some time is unknown
|
37 |
| - * |
38 |
| - * |
| 52 | + * |
| 53 | + * |
39 | 54 | * @param project
|
40 | 55 | * The newly created project that needs a .cproject file.
|
41 | 56 | * @param alCfgs
|
@@ -103,16 +118,60 @@ public static void setCProjectDescription(IProject project, ArrayList<Configurat
|
103 | 118 | CConfigurationData data = cfg.getConfigurationData();
|
104 | 119 | ICConfigurationDescription cfgDes = des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
|
105 | 120 |
|
| 121 | +<<<<<<< HEAD |
106 | 122 | if (cfgDes instanceof ILanguageSettingsProvidersKeeper) {
|
107 | 123 | ILanguageSettingsProvidersKeeper lspk = (ILanguageSettingsProvidersKeeper) cfgDes;
|
108 | 124 | lspk.setDefaultLanguageSettingsProvidersIds(new String[] { alCfgs.get(i).ToolchainID });
|
109 | 125 | }
|
110 | 126 | // without this line the indexer doesn't work properly in juno
|
111 | 127 | ConfigurationDataProvider.setDefaultLanguageSettingsProviders(project, cfg, cfgDes);
|
| 128 | +======= |
| 129 | + setDefaultLanguageSettingsProviders(project, alCfgs.get(i), cfg, cfgDes); |
| 130 | +>>>>>>> 900a472803717354280efa2760da613018fee890 |
112 | 131 | }
|
113 | 132 | monitor.worked(50);
|
114 | 133 | mngr.setProjectDescription(project, des);
|
115 | 134 |
|
116 | 135 | }
|
117 | 136 |
|
| 137 | + private static void setDefaultLanguageSettingsProviders(IProject project, ConfigurationDescriptor cfgDes, IConfiguration cfg, ICConfigurationDescription cfgDescription) { |
| 138 | + // propagate the preference to project properties |
| 139 | + boolean isPreferenceEnabled = ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(null); |
| 140 | + ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, isPreferenceEnabled); |
| 141 | + |
| 142 | + if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { |
| 143 | + ILanguageSettingsProvidersKeeper lspk = (ILanguageSettingsProvidersKeeper)cfgDescription; |
| 144 | + |
| 145 | + lspk.setDefaultLanguageSettingsProvidersIds(new String[] {cfgDes.ToolchainID}); |
| 146 | + |
| 147 | + List<ILanguageSettingsProvider> providers = getDefaultLanguageSettingsProviders(cfg, cfgDescription); |
| 148 | + lspk.setLanguageSettingProviders(providers); |
| 149 | + } |
| 150 | + } |
| 151 | + |
| 152 | + private static List<ILanguageSettingsProvider> getDefaultLanguageSettingsProviders(IConfiguration cfg, ICConfigurationDescription cfgDescription) { |
| 153 | + List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(); |
| 154 | + String[] ids = cfg != null ? cfg.getDefaultLanguageSettingsProviderIds() : null; |
| 155 | + |
| 156 | + if (ids == null) { |
| 157 | + // Try with legacy providers |
| 158 | + ids = ScannerDiscoveryLegacySupport.getDefaultProviderIdsLegacy(cfgDescription); |
| 159 | + } |
| 160 | + |
| 161 | + if (ids != null) { |
| 162 | + for (String id : ids) { |
| 163 | + ILanguageSettingsProvider provider = null; |
| 164 | + if (!LanguageSettingsManager.isPreferShared(id)) { |
| 165 | + provider = LanguageSettingsManager.getExtensionProviderCopy(id, false); |
| 166 | + } |
| 167 | + if (provider == null) { |
| 168 | + provider = LanguageSettingsManager.getWorkspaceProvider(id); |
| 169 | + } |
| 170 | + providers.add(provider); |
| 171 | + } |
| 172 | + } |
| 173 | + |
| 174 | + return providers; |
| 175 | + } |
| 176 | + |
118 | 177 | }
|
0 commit comments