|
29 | 29 | @SuppressWarnings("restriction")
|
30 | 30 | // TOFIX Get this code in CDT so I should not have to do this
|
31 | 31 | public class ShouldHaveBeenInCDT {
|
32 |
| - /* |
33 |
| - * Copied from wizard STDWizardHandler package package |
34 |
| - * org.eclipse.cdt.managedbuilder.ui.wizards;; This method creates the |
35 |
| - * .cProject file in your project. |
36 |
| - * |
37 |
| - * BK: modified this and made it work for multiple configs. |
38 |
| - */ |
39 |
| - /** |
40 |
| - * This method creates the .cProject file in your project. it is intended to |
41 |
| - * be used with newly created projects. Using this method with project that |
42 |
| - * have existed for some time is unknown |
43 |
| - * |
44 |
| - * |
45 |
| - * @param project |
46 |
| - * The newly created project that needs a .cproject file. |
47 |
| - * @param alCfgs |
48 |
| - * An array-list of configuration descriptors (names, toolchain |
49 |
| - * IDs) to be used with this project |
50 |
| - * @param isManagedBuild |
51 |
| - * When true the project is managed build. Else the project is |
52 |
| - * not (read you have to maintain the makefiles yourself) |
53 |
| - * @param monitor |
54 |
| - * The monitor to follow the process |
55 |
| - * @throws CoreException |
56 |
| - */ |
57 |
| - public static ICProjectDescription setCProjectDescription(IProject project, |
58 |
| - ArrayList<ConfigurationDescriptor> alCfgs, boolean isManagedBuild, IProgressMonitor monitor) |
59 |
| - throws CoreException { |
60 |
| - |
61 |
| - ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); |
62 |
| - ICProjectDescription des = mngr.createProjectDescription(project, false, true); |
63 |
| - ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project); |
64 |
| - ManagedProject mProj = new ManagedProject(des); |
65 |
| - info.setManagedProject(mProj); |
66 |
| - monitor.worked(20); |
67 |
| - |
68 |
| - // Iterate across the configurations |
69 |
| - for (int i = 0; i < alCfgs.size(); i++) { |
70 |
| - IToolChain tcs = ManagedBuildManager.getExtensionToolChain(alCfgs.get(i).ToolchainID); |
71 |
| - |
72 |
| - Configuration cfg = new Configuration(mProj, (ToolChain) tcs, |
73 |
| - ManagedBuildManager.calculateChildId(alCfgs.get(i).ToolchainID, null), alCfgs.get(i).configName); |
74 |
| - IBuilder bld = cfg.getEditableBuilder(); |
75 |
| - if (bld != null) { |
76 |
| - bld.setManagedBuildOn(isManagedBuild); |
77 |
| - cfg.setArtifactName("${ProjName}"); //$NON-NLS-1$ |
78 |
| - } else { |
79 |
| - System.out.println("Messages.StdProjectTypeHandler_3"); //$NON-NLS-1$ |
80 |
| - } |
81 |
| - CConfigurationData data = cfg.getConfigurationData(); |
82 |
| - ICConfigurationDescription cfgDes = des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data); |
83 |
| - |
84 |
| - setDefaultLanguageSettingsProviders(project, alCfgs.get(i), cfg, cfgDes); |
85 |
| - } |
86 |
| - monitor.worked(50); |
87 |
| - return des; |
| 32 | + /* |
| 33 | + * Copied from wizard STDWizardHandler package package |
| 34 | + * org.eclipse.cdt.managedbuilder.ui.wizards;; This method creates the |
| 35 | + * .cProject file in your project. |
| 36 | + * |
| 37 | + * BK: modified this and made it work for multiple configs. |
| 38 | + */ |
| 39 | + /** |
| 40 | + * This method creates the .cProject file in your project. it is intended to |
| 41 | + * be used with newly created projects. Using this method with project that |
| 42 | + * have existed for some time is unknown |
| 43 | + * |
| 44 | + * |
| 45 | + * @param project |
| 46 | + * The newly created project that needs a .cproject file. |
| 47 | + * @param alCfgs |
| 48 | + * An array-list of configuration descriptors (names, toolchain |
| 49 | + * IDs) to be used with this project |
| 50 | + * @param isManagedBuild |
| 51 | + * When true the project is managed build. Else the project is |
| 52 | + * not (read you have to maintain the makefiles yourself) |
| 53 | + * @param monitor |
| 54 | + * The monitor to follow the process |
| 55 | + * @throws CoreException |
| 56 | + */ |
| 57 | + public static ICProjectDescription setCProjectDescription(IProject project, |
| 58 | + ArrayList<ConfigurationDescriptor> alCfgs, boolean isManagedBuild, IProgressMonitor monitor) |
| 59 | + throws CoreException { |
| 60 | + |
| 61 | + ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); |
| 62 | + ICProjectDescription des = mngr.createProjectDescription(project, false, true); |
| 63 | + ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project); |
| 64 | + ManagedProject mProj = new ManagedProject(des); |
| 65 | + info.setManagedProject(mProj); |
| 66 | + monitor.worked(20); |
| 67 | + |
| 68 | + // Iterate across the configurations |
| 69 | + for (ConfigurationDescriptor curConfDesc : alCfgs) { |
| 70 | + IToolChain tcs = ManagedBuildManager.getExtensionToolChain(curConfDesc.ToolchainID); |
| 71 | + |
| 72 | + Configuration cfg = new Configuration(mProj, (ToolChain) tcs, |
| 73 | + ManagedBuildManager.calculateChildId(curConfDesc.ToolchainID, null), curConfDesc.configName); |
| 74 | + IBuilder bld = cfg.getEditableBuilder(); |
| 75 | + if (bld != null) { |
| 76 | + bld.setManagedBuildOn(isManagedBuild); |
| 77 | + cfg.setArtifactName("${ProjName}"); //$NON-NLS-1$ |
| 78 | + } else { |
| 79 | + System.out.println("Messages.StdProjectTypeHandler_3"); //$NON-NLS-1$ |
| 80 | + } |
| 81 | + CConfigurationData data = cfg.getConfigurationData(); |
| 82 | + ICConfigurationDescription cfgDes = des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data); |
| 83 | + |
| 84 | + setDefaultLanguageSettingsProviders(project, curConfDesc, cfg, cfgDes); |
| 85 | + } |
| 86 | + monitor.worked(50); |
| 87 | + return des; |
88 | 88 |
|
89 |
| - } |
| 89 | + } |
90 | 90 |
|
91 |
| - private static void setDefaultLanguageSettingsProviders(IProject project, ConfigurationDescriptor cfgDes, |
92 |
| - IConfiguration cfg, ICConfigurationDescription cfgDescription) { |
93 |
| - // propagate the preference to project properties |
94 |
| - boolean isPreferenceEnabled = ScannerDiscoveryLegacySupport |
95 |
| - .isLanguageSettingsProvidersFunctionalityEnabled(null); |
96 |
| - ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, isPreferenceEnabled); |
| 91 | + private static void setDefaultLanguageSettingsProviders(IProject project, ConfigurationDescriptor cfgDes, |
| 92 | + IConfiguration cfg, ICConfigurationDescription cfgDescription) { |
| 93 | + // propagate the preference to project properties |
| 94 | + boolean isPreferenceEnabled = ScannerDiscoveryLegacySupport |
| 95 | + .isLanguageSettingsProvidersFunctionalityEnabled(null); |
| 96 | + ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, isPreferenceEnabled); |
97 | 97 |
|
98 |
| - if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { |
99 |
| - ILanguageSettingsProvidersKeeper lspk = (ILanguageSettingsProvidersKeeper) cfgDescription; |
| 98 | + if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { |
| 99 | + ILanguageSettingsProvidersKeeper lspk = (ILanguageSettingsProvidersKeeper) cfgDescription; |
100 | 100 |
|
101 |
| - lspk.setDefaultLanguageSettingsProvidersIds(new String[] { cfgDes.ToolchainID }); |
| 101 | + lspk.setDefaultLanguageSettingsProvidersIds(new String[] { cfgDes.ToolchainID }); |
102 | 102 |
|
103 |
| - List<ILanguageSettingsProvider> providers = getDefaultLanguageSettingsProviders(cfg, cfgDescription); |
104 |
| - lspk.setLanguageSettingProviders(providers); |
| 103 | + List<ILanguageSettingsProvider> providers = getDefaultLanguageSettingsProviders(cfg, cfgDescription); |
| 104 | + lspk.setLanguageSettingProviders(providers); |
| 105 | + } |
105 | 106 | }
|
106 |
| - } |
107 | 107 |
|
108 |
| - private static List<ILanguageSettingsProvider> getDefaultLanguageSettingsProviders(IConfiguration cfg, |
109 |
| - ICConfigurationDescription cfgDescription) { |
110 |
| - List<ILanguageSettingsProvider> providers = new ArrayList<>(); |
111 |
| - String[] ids = cfg != null ? cfg.getDefaultLanguageSettingsProviderIds() : null; |
| 108 | + private static List<ILanguageSettingsProvider> getDefaultLanguageSettingsProviders(IConfiguration cfg, |
| 109 | + ICConfigurationDescription cfgDescription) { |
| 110 | + List<ILanguageSettingsProvider> providers = new ArrayList<>(); |
| 111 | + String[] ids = cfg != null ? cfg.getDefaultLanguageSettingsProviderIds() : null; |
112 | 112 |
|
113 |
| - if (ids == null) { |
114 |
| - // Try with legacy providers |
115 |
| - ids = ScannerDiscoveryLegacySupport.getDefaultProviderIdsLegacy(cfgDescription); |
116 |
| - } |
117 |
| - |
118 |
| - if (ids != null) { |
119 |
| - for (String id : ids) { |
120 |
| - ILanguageSettingsProvider provider = null; |
121 |
| - if (!LanguageSettingsManager.isPreferShared(id)) { |
122 |
| - provider = LanguageSettingsManager.getExtensionProviderCopy(id, false); |
| 113 | + if (ids == null) { |
| 114 | + // Try with legacy providers |
| 115 | + ids = ScannerDiscoveryLegacySupport.getDefaultProviderIdsLegacy(cfgDescription); |
123 | 116 | }
|
124 |
| - if (provider == null) { |
125 |
| - provider = LanguageSettingsManager.getWorkspaceProvider(id); |
| 117 | + |
| 118 | + if (ids != null) { |
| 119 | + for (String id : ids) { |
| 120 | + ILanguageSettingsProvider provider = null; |
| 121 | + if (!LanguageSettingsManager.isPreferShared(id)) { |
| 122 | + provider = LanguageSettingsManager.getExtensionProviderCopy(id, false); |
| 123 | + } |
| 124 | + if (provider == null) { |
| 125 | + provider = LanguageSettingsManager.getWorkspaceProvider(id); |
| 126 | + } |
| 127 | + providers.add(provider); |
| 128 | + } |
126 | 129 | }
|
127 |
| - providers.add(provider); |
128 |
| - } |
129 |
| - } |
130 | 130 |
|
131 |
| - return providers; |
132 |
| - } |
| 131 | + return providers; |
| 132 | + } |
133 | 133 |
|
134 | 134 | }
|
0 commit comments