diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/build/core/scannerconfig/tests/CfgScannerConfigProfileManagerTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/build/core/scannerconfig/tests/CfgScannerConfigProfileManagerTests.java index 2a45af47eb7..ecc47409893 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/build/core/scannerconfig/tests/CfgScannerConfigProfileManagerTests.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/build/core/scannerconfig/tests/CfgScannerConfigProfileManagerTests.java @@ -59,6 +59,7 @@ public class CfgScannerConfigProfileManagerTests extends BaseTestCase { * @throws CoreException */ public void testBasicCfgScannerConfigProfileChanges() throws CoreException { + ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(fProject, false); ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(fProject); ICConfigurationDescription[] cfgDescs = prjDesc.getConfigurations(); assertTrue(cfgDescs.length > 0); @@ -107,7 +108,6 @@ public class CfgScannerConfigProfileManagerTests extends BaseTestCase { Assert.isTrue("dummyFile".equals(scbi.getBuildOutputFilePath())); // Test restore defaults - ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(fProject, false); scbis.applyInfo(cic, null); // Save the project description CoreModel.getDefault().setProjectDescription(fProject, prjDesc); diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java index 13f87f2dcb1..2e078a8fdca 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.managedbuilder.core.tests; +import java.io.IOException; import java.util.Arrays; import java.util.Map; import java.util.Properties; @@ -95,6 +96,27 @@ public class ManagedBuildCoreTests20 extends TestCase { return suite; } + /** + * Convert path to OS specific representation + */ + private String toOSLocation(String path) { + java.io.File file = new java.io.File(path); + try { + path = file.getCanonicalPath(); + } catch (IOException e) { + } + + return path; + } + + /** + * Convert path to OS specific representation + */ + private String toOSString(String path) { + return new Path(path).toOSString(); + } + + /** * Navigates through the build info as defined in the extensions * defined in this plugin @@ -218,18 +240,37 @@ public class ManagedBuildCoreTests20 extends TestCase { } //These are the expected path settings - final String[] expectedPaths = new String[5]; - - // This first path is a built-in, so it will not be manipulated by build manager - expectedPaths[0] = (new Path("/usr/include")).toOSString(); - expectedPaths[1] = (new Path("/opt/gnome/include")).toOSString(); - IPath path = new Path("C:\\home\\tester/include"); - if(path.isAbsolute()) // for win32 path is treated as absolute - expectedPaths[2] = path.toOSString(); - else // for Linux path is relative - expectedPaths[2] = project.getLocation().append("Sub Config").append(path).toOSString(); - expectedPaths[3] = project.getLocation().append( "includes" ).toOSString(); - expectedPaths[4] = (new Path("/usr/gnu/include")).toOSString(); + IPath buildCWD = project.getLocation().append("Sub Config"); + final String[] expectedPaths; + if (new Path("C:\\home\\tester/include").isAbsolute()) { + // Windows + expectedPaths = new String[] { + toOSLocation("/usr/include"), + toOSLocation("/opt/gnome/include"), + toOSLocation("C:\\home\\tester/include"), + // relative paths from MBS will make 3 entries + project.getLocation().append("includes").toOSString(), + buildCWD.append("includes").toOSString(), + toOSString("includes"), + "/usr/gnu/include", // Not converted to OS string due to being flagged as ICSettingEntry.RESOLVED + }; + } else { + // Unix + expectedPaths = new String[] { + toOSLocation("/usr/include"), + toOSLocation("/opt/gnome/include"), + // on unix "C:\\home\\tester/include" is relative path + // looks like nonsense but it this way due to MBS converting entry to keep "Sub Config/C:\\home\\tester/include" in its storage + project.getLocation().append("Sub Config/C:\\home\\tester/include").toOSString(), + buildCWD.append("Sub Config/C:\\home\\tester/include").toOSString(), + toOSString("Sub Config/C:\\home\\tester/include"), + // relative paths from MBS will make 3 entries + project.getLocation().append("includes").toOSString(), + buildCWD.append("includes").toOSString(), + toOSString("includes"), + "/usr/gnu/include", // Not converted to OS string due to being flagged as ICSettingEntry.RESOLVED + }; + } // Create a new managed project based on the sub project type IProjectType projType = ManagedBuildManager.getExtensionProjectType("test.sub"); diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/LanguageSettingsProvidersMBSTest.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/LanguageSettingsProvidersMBSTest.java index 82d5eec4ee5..d66c480f3e5 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/LanguageSettingsProvidersMBSTest.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/LanguageSettingsProvidersMBSTest.java @@ -22,13 +22,9 @@ import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.testplugin.util.BaseTestCase; -import org.eclipse.cdt.managedbuilder.core.IConfiguration; -import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; -import org.eclipse.cdt.managedbuilder.internal.dataprovider.ConfigurationDataProvider; import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; /** * Test creation of a new project in respect with language settings providers. @@ -52,37 +48,12 @@ public class LanguageSettingsProvidersMBSTest extends BaseTestCase { super.tearDown(); } - /** - * Imitate a new Project Wizard. New Project Wizards really do these things in CDT. - */ - private static IProject imitateNewProjectWizard(String name, String projectTypeId) throws CoreException { - IProject project = ManagedBuildTestHelper.createProject(name, projectTypeId); - ManagedBuildTestHelper.addManagedBuildNature(project); - - ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project, true); - assertNotNull(prjDescription); - ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations(); - for (ICConfigurationDescription cfgDescription : cfgDescriptions) { - assertNotNull(cfgDescription); - assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - - IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(cfgDescription); - ConfigurationDataProvider.setDefaultLanguageSettingsProviders(project, cfg, cfgDescription); - - assertTrue(((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders().size() > 0); - } - - CoreModel.getDefault().setProjectDescription(project, prjDescription); - - return project; - } - /** * Test new GNU Executable project. */ public void testGnuToolchainProviders() throws Exception { - // create a new project imitating wizard - IProject project = imitateNewProjectWizard(this.getName(), PROJECT_TYPE_EXECUTABLE_GNU); + // create a new project + IProject project = ManagedBuildTestHelper.createProject(this.getName(), PROJECT_TYPE_EXECUTABLE_GNU); // check that the language settings providers are in place. ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project, false); @@ -123,8 +94,8 @@ public class LanguageSettingsProvidersMBSTest extends BaseTestCase { * of language settings providers. */ public void testProjectPersistence_Defaults() throws Exception { - // create a new project imitating wizard - IProject project = imitateNewProjectWizard(this.getName(), PROJECT_TYPE_EXECUTABLE_GNU); + // create a new project + IProject project = ManagedBuildTestHelper.createProject(this.getName(), PROJECT_TYPE_EXECUTABLE_GNU); // double-check that the project contains language settings providers ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project, false); @@ -158,8 +129,8 @@ public class LanguageSettingsProvidersMBSTest extends BaseTestCase { * Test that storage file is created for language settings for empty set of language settings providers. */ public void testProjectPersistence_NoProviders() throws Exception { - // create a new project imitating wizard - IProject project = imitateNewProjectWizard(this.getName(), PROJECT_TYPE_EXECUTABLE_GNU); + // create a new project + IProject project = ManagedBuildTestHelper.createProject(this.getName(), PROJECT_TYPE_EXECUTABLE_GNU); // remove language settings providers from the project ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project, true); diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java index 28a09006da5..7d53d82ce9c 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java @@ -505,6 +505,11 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild if(baseCfg.sourceEntries != null) sourceEntries = baseCfg.sourceEntries.clone(); + defaultLanguageSettingsProvidersAttribute = baseCfg.defaultLanguageSettingsProvidersAttribute; + if(baseCfg.defaultLanguageSettingsProviderIds != null) { + defaultLanguageSettingsProviderIds = baseCfg.defaultLanguageSettingsProviderIds.clone(); + } + // enableInternalBuilder(baseCfg.isInternalBuilderEnabled()); // setInternalBuilderIgnoreErr(baseCfg.getInternalBuilderIgnoreErr()); // setInternalBuilderParallel(baseCfg.getInternalBuilderParallel()); @@ -646,6 +651,10 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild if(cloneConfig.sourceEntries != null) { sourceEntries = cloneConfig.sourceEntries.clone(); } + defaultLanguageSettingsProvidersAttribute = cloneConfig.defaultLanguageSettingsProvidersAttribute; + if(cloneConfig.defaultLanguageSettingsProviderIds != null) { + defaultLanguageSettingsProviderIds = cloneConfig.defaultLanguageSettingsProviderIds.clone(); + } // enableInternalBuilder(cloneConfig.isInternalBuilderEnabled()); // setInternalBuilderIgnoreErr(cloneConfig.getInternalBuilderIgnoreErr()); @@ -1352,7 +1361,6 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild */ @Override public String[] getDefaultLanguageSettingsProviderIds() { - defaultLanguageSettingsProviderIds = null; if (defaultLanguageSettingsProviderIds == null) { defaultLanguageSettingsProvidersAttribute = getDefaultLanguageSettingsProvidersAttribute(); if (defaultLanguageSettingsProvidersAttribute != null) { diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java index c778edd492c..7de39c1ac7c 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java @@ -158,19 +158,45 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem BuildConfigurationData baseCfgData = (BuildConfigurationData)baseData; IConfiguration baseCfg = baseCfgData.getConfiguration(); - BuildConfigurationData appliedCfg; + BuildConfigurationData appliedCfgData; if(context.isBaseDataCached() && !baseCfg.isDirty()){ - appliedCfg = baseCfgData; + appliedCfgData = baseCfgData; context.setConfigurationSettingsFlags(IModificationContext.CFG_DATA_STORAGE_UNMODIFIED | IModificationContext.CFG_DATA_SETTINGS_UNMODIFIED); } else { - appliedCfg = writeConfiguration(cfgDescription, baseCfgData); + appliedCfgData = writeConfiguration(cfgDescription, baseCfgData); IManagedBuildInfo info = getBuildInfo(cfgDescription); ManagedProject mProj = (ManagedProject)info.getManagedProject(); - mProj.applyConfiguration((Configuration)appliedCfg.getConfiguration()); + mProj.applyConfiguration((Configuration)appliedCfgData.getConfiguration()); writeManagedProjectInfo(cfgDescription.getProjectDescription(), mProj); + if (baseCfgDescription instanceof ILanguageSettingsProvidersKeeper) { + String[] defaultIds = ((ILanguageSettingsProvidersKeeper)baseCfgDescription).getDefaultLanguageSettingsProvidersIds(); + List providers; + if (defaultIds == null) { + ICProjectDescription prjDescription = baseCfgDescription.getProjectDescription(); + if (prjDescription != null) { + IProject project = prjDescription.getProject(); + // propagate the preference to project properties + ScannerDiscoveryLegacySupport.defineLanguageSettingsEnablement(project); + } + + IConfiguration cfg = appliedCfgData.getConfiguration(); + defaultIds = cfg != null ? cfg.getDefaultLanguageSettingsProviderIds() : null; + if (defaultIds == null) { + defaultIds = ScannerDiscoveryLegacySupport.getDefaultProviderIdsLegacy(baseCfgDescription); + } + providers = LanguageSettingsManager.createLanguageSettingsProviders(defaultIds); + } else { + providers = ((ILanguageSettingsProvidersKeeper)baseCfgDescription).getLanguageSettingProviders(); + } + if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { + ((ILanguageSettingsProvidersKeeper)cfgDescription).setDefaultLanguageSettingsProvidersIds(defaultIds); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + } + } + try { - CfgScannerConfigInfoFactory2.save(appliedCfg, cfgDescription.getProjectDescription(), baseCfgDescription.getProjectDescription(), !isPersistedCfg(cfgDescription)); + CfgScannerConfigInfoFactory2.save(appliedCfgData, cfgDescription.getProjectDescription(), baseCfgDescription.getProjectDescription(), !isPersistedCfg(cfgDescription)); } catch (CoreException e){ ManagedBuilderCorePlugin.log(e); } @@ -184,7 +210,7 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem } if(cfgDescription.isActive()){ - IConfiguration cfg = appliedCfg.getConfiguration(); + IConfiguration cfg = appliedCfgData.getConfiguration(); IBuilder builder = cfg.getEditableBuilder(); IProject project = context.getProject(); IProjectDescription eDes = context.getEclipseProjectDescription(); @@ -199,7 +225,7 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem } } - return appliedCfg; + return appliedCfgData; } private void setPersistedFlag(ICConfigurationDescription cfgDescription){ @@ -530,66 +556,28 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem IManagedBuildInfo info = getBuildInfo(cfgDescription); Configuration cfg = load(cfgDescription, (ManagedProject)info.getManagedProject(), false); - if(cfg != null) { + if (cfg != null) { + IProject project = cfgDescription.getProjectDescription().getProject(); cfg.setConfigurationDescription(cfgDescription); info.setValid(true); setPersistedFlag(cfgDescription); cacheNaturesIdsUsedOnCache(cfgDescription); // Update the ManagedBuildInfo in the ManagedBuildManager map. Doing this creates a barrier for subsequent // ManagedBuildManager#getBuildInfo(...) see Bug 305146 for more - ManagedBuildManager.setLoaddedBuildInfo(cfgDescription.getProjectDescription().getProject(), info); - setDefaultLanguageSettingsProvidersIds(cfg, cfgDescription); + ManagedBuildManager.setLoaddedBuildInfo(project, info); + + if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { + String[] defaultIds = cfg.getDefaultLanguageSettingsProviderIds(); + if (defaultIds != null) { + ((ILanguageSettingsProvidersKeeper) cfgDescription).setDefaultLanguageSettingsProvidersIds(defaultIds); + } + } + return cfg.getConfigurationData(); } return null; } - private static List getDefaultLanguageSettingsProviders(IConfiguration cfg) { - List providers = new ArrayList(); - String[] ids = cfg != null ? cfg.getDefaultLanguageSettingsProviderIds() : null; - if (ids != null) { - for (String id : ids) { - ILanguageSettingsProvider provider = null; - if (!LanguageSettingsManager.isPreferShared(id)) { - provider = LanguageSettingsManager.getExtensionProviderCopy(id, false); - } - if (provider == null) { - provider = LanguageSettingsManager.getWorkspaceProvider(id); - } - providers.add(provider); - } - } else { - providers = ScannerDiscoveryLegacySupport.getDefaultProvidersLegacy(); - } - - return providers; - } - - private static void setDefaultLanguageSettingsProvidersIds(IConfiguration cfg, ICConfigurationDescription cfgDescription) { - if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { - List providers = getDefaultLanguageSettingsProviders(cfg); - String[] ids = new String[providers.size()]; - for (int i = 0; i < ids.length; i++) { - ILanguageSettingsProvider provider = providers.get(i); - ids[i] = provider.getId(); - } - ((ILanguageSettingsProvidersKeeper) cfgDescription).setDefaultLanguageSettingsProvidersIds(ids); - } - - } - - public static void setDefaultLanguageSettingsProviders(IProject project, IConfiguration cfg, ICConfigurationDescription cfgDescription) { - // propagate the preference to project properties - boolean isPreferenceEnabled = ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(null); - ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, isPreferenceEnabled); - - if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { - ConfigurationDataProvider.setDefaultLanguageSettingsProvidersIds(cfg, cfgDescription); - List providers = ConfigurationDataProvider.getDefaultLanguageSettingsProviders(cfg); - ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); - } - } - private boolean isPersistedCfg(ICConfigurationDescription cfgDescription) { return cfgDescription.getSessionProperty(CFG_PERSISTED_PROPERTY) != null; } diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSWizardHandler.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSWizardHandler.java index 34a8ce00fdd..73ffb9e0739 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSWizardHandler.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSWizardHandler.java @@ -41,7 +41,6 @@ import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.internal.core.Configuration; import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo; import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject; -import org.eclipse.cdt.managedbuilder.internal.dataprovider.ConfigurationDataProvider; import org.eclipse.cdt.managedbuilder.internal.ui.Messages; import org.eclipse.cdt.managedbuilder.ui.properties.ManagedBuilderUIPlugin; import org.eclipse.cdt.ui.newui.CDTPrefUtil; @@ -616,9 +615,6 @@ public class MBSWizardHandler extends CWizardHandler { cfgDebug = cfgDes; if (cfgFirst == null) // select at least first configuration cfgFirst = cfgDes; - - ConfigurationDataProvider.setDefaultLanguageSettingsProviders(project, config, cfgDes); - monitor.worked(work); } mngr.setProjectDescription(project, des); diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewMakeProjFromExisting.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewMakeProjFromExisting.java index ab46facdf03..2f3d26f27c2 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewMakeProjFromExisting.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewMakeProjFromExisting.java @@ -26,7 +26,6 @@ import org.eclipse.cdt.managedbuilder.internal.core.Configuration; import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo; import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject; import org.eclipse.cdt.managedbuilder.internal.core.ToolChain; -import org.eclipse.cdt.managedbuilder.internal.dataprovider.ConfigurationDataProvider; import org.eclipse.cdt.managedbuilder.internal.ui.Messages; import org.eclipse.cdt.managedbuilder.ui.properties.ManagedBuilderUIPlugin; import org.eclipse.core.resources.IProject; @@ -112,10 +111,7 @@ public class NewMakeProjFromExisting extends Wizard implements IImportWizard, IN IBuilder builder = config.getEditableBuilder(); builder.setManagedBuildOn(false); CConfigurationData data = config.getConfigurationData(); - ICConfigurationDescription cfgDes = projDesc.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data); - - ConfigurationDataProvider.setDefaultLanguageSettingsProviders(project, config, cfgDes); - + projDesc.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data); monitor.worked(1); pdMgr.setProjectDescription(project, projDesc); diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/STDWizardHandler.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/STDWizardHandler.java index 231c82953b6..97368ac1d83 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/STDWizardHandler.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/STDWizardHandler.java @@ -24,7 +24,6 @@ import org.eclipse.cdt.managedbuilder.internal.core.Configuration; import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo; import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject; import org.eclipse.cdt.managedbuilder.internal.core.ToolChain; -import org.eclipse.cdt.managedbuilder.internal.dataprovider.ConfigurationDataProvider; import org.eclipse.cdt.managedbuilder.internal.ui.Messages; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; @@ -102,10 +101,7 @@ public class STDWizardHandler extends MBSWizardHandler { } cfg.setArtifactName(mProj.getDefaultArtifactName()); CConfigurationData data = cfg.getConfigurationData(); - ICConfigurationDescription cfgDes = des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data); - - ConfigurationDataProvider.setDefaultLanguageSettingsProviders(project, cfg, cfgDes); - + des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data); monitor.worked(work); } mngr.setProjectDescription(project, des); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManagerTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManagerTests.java index 17f861e4010..59487adc246 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManagerTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManagerTests.java @@ -695,12 +695,16 @@ public class LanguageSettingsManagerTests extends BaseTestCase { ICConfigurationDescription cfgDescription = cfgDescriptions[0]; assertTrue(cfgDescription instanceof CConfigurationDescription); + // Select a sample workspace provider for the test ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID); assertNotNull(workspaceProvider); + { - // ensure no test provider is set yet + // ensure no test provider is set yet but default providers List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); - assertEquals(0, providers.size()); + assertEquals(ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID, providers.get(0).getId()); + assertEquals(ScannerDiscoveryLegacySupport.PATH_ENTRY_MANAGER_LANGUAGE_SETTINGS_PROVIDER_ID, providers.get(1).getId()); + assertEquals(2, providers.size()); } { // set test provider diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java index 578d5475c32..c66c25bd986 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java @@ -457,23 +457,34 @@ public class IndexBugsTests extends BaseTestCase { public void test160281_1() throws Exception { waitForIndexer(); - IFile include= TestSourceReader.createFile(fCProject.getProject(), "inc/test160281_1.h", ""); + IProject project = fCProject.getProject(); + IFile include= TestSourceReader.createFile(project, "inc/test160281_1.h", ""); TestScannerProvider.sIncludes= new String[]{include.getLocation().removeLastSegments(1).toString()}; TestScannerProvider.sIncludeFiles= new String[]{include.getName()}; - IFile file= TestSourceReader.createFile(fCProject.getProject(), "test160281_1.cpp", ""); + IFile file= TestSourceReader.createFile(project, "test160281_1.cpp", ""); TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEXER_TIMEOUT_SEC * 1000); fIndex.acquireReadLock(); try { IIndexFile ifile= getIndexFile(file); IIndexInclude[] includes= ifile.getIncludes(); - assertEquals(1, includes.length); - IIndexInclude i= includes[0]; - assertEquals(file.getLocationURI(), i.getIncludedByLocation().getURI()); - assertEquals(include.getLocationURI(), i.getIncludesLocation().getURI()); - assertEquals(true, i.isSystemInclude()); - assertEquals(0, i.getNameOffset()); - assertEquals(0, i.getNameLength()); + + // the first directory searched for file is the preprocessor's working directory (build directory), see gcc manual -include option + IIndexInclude i1= includes[0]; + assertEquals(file.getLocationURI(), i1.getIncludedByLocation().getURI()); + assertEquals(project.getFile(TestScannerProvider.sIncludeFiles[0]).getLocation(), new Path(i1.getFullName())); + // the include file is not in the working directory + assertEquals(null, i1.getIncludesLocation()); + + // the second directory is the directory containing the main source file + IIndexInclude i2= includes[1]; + assertEquals(file.getLocationURI(), i2.getIncludedByLocation().getURI()); + assertEquals(include.getLocationURI(), i2.getIncludesLocation().getURI()); + assertEquals(true, i2.isSystemInclude()); + assertEquals(0, i2.getNameOffset()); + assertEquals(0, i2.getNameLength()); + + assertEquals(2, includes.length); } finally { fIndex.releaseReadLock(); } @@ -481,26 +492,37 @@ public class IndexBugsTests extends BaseTestCase { public void test160281_2() throws Exception { waitForIndexer(); - IFile include= TestSourceReader.createFile(fCProject.getProject(), "inc/test160281_2.h", "#define X y\n"); + IProject project = fCProject.getProject(); + IFile include= TestSourceReader.createFile(project, "inc/test160281_2.h", "#define X y\n"); TestScannerProvider.sIncludes= new String[]{include.getLocation().removeLastSegments(1).toString()}; TestScannerProvider.sMacroFiles= new String[]{include.getName()}; - IFile file= TestSourceReader.createFile(fCProject.getProject(), "test160281_2.cpp", "int X;"); + IFile file= TestSourceReader.createFile(project, "test160281_2.cpp", "int X;"); TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEXER_TIMEOUT_SEC * 1000); fIndex.acquireReadLock(); try { IIndexFile ifile= getIndexFile(file); IIndexInclude[] includes= ifile.getIncludes(); - assertEquals(1, includes.length); - IIndexInclude i= includes[0]; - assertEquals(file.getLocationURI(), i.getIncludedByLocation().getURI()); - assertEquals(include.getLocationURI(), i.getIncludesLocation().getURI()); - assertEquals(true, i.isSystemInclude()); - assertEquals(0, i.getNameOffset()); - assertEquals(0, i.getNameLength()); + + // the first directory searched for file is the preprocessor's working directory (build directory), see gcc manual -imacros option + IIndexInclude i1= includes[0]; + assertEquals(file.getLocationURI(), i1.getIncludedByLocation().getURI()); + assertEquals(project.getFile(TestScannerProvider.sMacroFiles[0]).getLocation(), new Path(i1.getFullName())); + // the include file is not in the working directory + assertEquals(null, i1.getIncludesLocation()); + + // the second directory is the directory containing the main source file + IIndexInclude i2= includes[1]; + assertEquals(file.getLocationURI(), i2.getIncludedByLocation().getURI()); + assertEquals(include.getLocationURI(), i2.getIncludesLocation().getURI()); + assertEquals(true, i2.isSystemInclude()); + assertEquals(0, i2.getNameOffset()); + assertEquals(0, i2.getNameLength()); IIndexBinding[] bindings= fIndex.findBindings("y".toCharArray(), IndexFilter.ALL, npm()); assertEquals(1, bindings.length); assertTrue(bindings[0] instanceof IVariable); + + assertEquals(2, includes.length); } finally { fIndex.releaseReadLock(); } diff --git a/core/org.eclipse.cdt.core/.settings/.api_filters b/core/org.eclipse.cdt.core/.settings/.api_filters new file mode 100644 index 00000000000..db12f3ab020 --- /dev/null +++ b/core/org.eclipse.cdt.core/.settings/.api_filters @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManager.java index 124ee5506fe..7c470e470e9 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManager.java @@ -130,7 +130,7 @@ public class LanguageSettingsManager { * @return raw underlying provider for workspace provider or provider itself if no wrapper is used. */ public static ILanguageSettingsProvider getRawProvider(ILanguageSettingsProvider provider) { - if (LanguageSettingsManager.isWorkspaceProvider(provider)) { + if (isWorkspaceProvider(provider)) { provider = LanguageSettingsProvidersSerializer.getRawWorkspaceProvider(provider.getId()); } return provider; @@ -376,4 +376,32 @@ public class LanguageSettingsManager { public static void serializeLanguageSettingsWorkspaceInBackground() { LanguageSettingsProvidersSerializer.serializeLanguageSettingsWorkspaceInBackground(); } + + /** + * Create a list of providers with intention to assign to a configuration description. + * + * The list will contain global providers for ones where attribute "prefer-non-shared" is {@code true} + * and a new copy for those where attribute "prefer-non-shared" is {@code false}. Attribute "prefer-non-shared" + * is defined in extension point {@code org.eclipse.cdt.core.LanguageSettingsProvider}. + * + * @param ids - list of providers id which cannot be {@code null}. + * @return a list of language settings providers with given ids. + * + * @since 5.5 + */ + public static List createLanguageSettingsProviders(String[] ids) { + List providers = new ArrayList(); + for (String id : ids) { + ILanguageSettingsProvider provider = null; + if (!isPreferShared(id)) { + provider = getExtensionProviderCopy(id, false); + } + if (provider == null) { + provider = getWorkspaceProvider(id); + } + providers.add(provider); + } + return providers; + } + } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ScannerDiscoveryLegacySupport.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ScannerDiscoveryLegacySupport.java index 807b8f31128..1597377ff08 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ScannerDiscoveryLegacySupport.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ScannerDiscoveryLegacySupport.java @@ -11,7 +11,6 @@ package org.eclipse.cdt.core.language.settings.providers; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -21,8 +20,6 @@ import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.internal.core.LocalProjectScope; -import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsExtensionManager; -import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer; import org.eclipse.cdt.internal.core.language.settings.providers.ScannerInfoExtensionLanguageSettingsProvider; import org.eclipse.cdt.internal.core.model.PathEntryManager; import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; @@ -144,10 +141,9 @@ public class ScannerDiscoveryLegacySupport { /** * Check if legacy Scanner Discovery should be active. - * @noreference This is internal helper method to support compatibility with previous versions * which is not intended to be referenced by clients. */ - public static boolean isLegacyProviderOn(ICConfigurationDescription cfgDescription) { + private static boolean isLegacyProviderOn(ICConfigurationDescription cfgDescription) { if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { List lsProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); for (ILanguageSettingsProvider lsp : lsProviders) { @@ -237,19 +233,17 @@ public class ScannerDiscoveryLegacySupport { } /** - * Return list containing User and MBS providers. Used to initialize older MBS tool-chains (backward compatibility). + * If not defined yet, define property that controls if language settings providers functionality enabled for a given project. + * Workspace preference is checked and the project property is set to match it. * - * @noreference This is internal helper method to support compatibility with previous versions - * which is not intended to be referenced by clients. + * @param project - project to define enablement. + * @since 5.5 */ - public static List getDefaultProvidersLegacy() { - List providers = new ArrayList(2); - ILanguageSettingsProvider provider = LanguageSettingsExtensionManager.getExtensionProviderCopy((USER_LANGUAGE_SETTINGS_PROVIDER_ID), false); - if (provider != null) { - providers.add(provider); + public static void defineLanguageSettingsEnablement(IProject project) { + if (project != null && ! ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityDefined(project)) { + boolean isPreferenceEnabled = ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(null); + ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, isPreferenceEnabled); } - providers.add(LanguageSettingsProvidersSerializer.getWorkspaceProvider(MBS_LANGUAGE_SETTINGS_PROVIDER_ID)); - return providers; } /** diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CConfigurationDataProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CConfigurationDataProvider.java index 728c1186bfa..2d46d53610d 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CConfigurationDataProvider.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CConfigurationDataProvider.java @@ -10,9 +10,16 @@ *******************************************************************************/ package org.eclipse.cdt.core.settings.model.extension; +import java.util.List; + +import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; +import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper; +import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager; +import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.IModificationContext; +import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; @@ -108,7 +115,28 @@ public abstract class CConfigurationDataProvider { ICConfigurationDescription baseCfgDescription, CConfigurationData baseData, IModificationContext context, IProgressMonitor monitor) throws CoreException { - return applyConfiguration(cfgDescription, baseCfgDescription, baseData, monitor); + CConfigurationData data = applyConfiguration(cfgDescription, baseCfgDescription, baseData, monitor); + if (baseCfgDescription instanceof ILanguageSettingsProvidersKeeper) { + String[] defaultIds = ((ILanguageSettingsProvidersKeeper)baseCfgDescription).getDefaultLanguageSettingsProvidersIds(); + List providers; + if (defaultIds != null) { + providers = ((ILanguageSettingsProvidersKeeper)baseCfgDescription).getLanguageSettingProviders(); + } else { + ICProjectDescription prjDescription = baseCfgDescription.getProjectDescription(); + if (prjDescription != null) { + IProject project = prjDescription.getProject(); + // propagate the preference to project properties + ScannerDiscoveryLegacySupport.defineLanguageSettingsEnablement(project); + } + defaultIds = ScannerDiscoveryLegacySupport.getDefaultProviderIdsLegacy(baseCfgDescription); + providers = LanguageSettingsManager.createLanguageSettingsProviders(defaultIds); + } + if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { + ((ILanguageSettingsProvidersKeeper)cfgDescription).setDefaultLanguageSettingsProvidersIds(defaultIds); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + } + } + return data; } /** diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java index ddb1b76f6f5..03895b892b3 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java @@ -35,7 +35,6 @@ import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICSettingEntry; -import org.eclipse.cdt.core.settings.model.ICStorageElement; import org.eclipse.cdt.internal.core.XmlUtil; import org.eclipse.cdt.internal.core.settings.model.CConfigurationSpecSettings; import org.eclipse.cdt.internal.core.settings.model.IInternalCCfgInfo; @@ -834,11 +833,6 @@ public class LanguageSettingsProvidersSerializer { try { // Add the storage module to .cpoject and persist on disk as a side effect of adding prjDescription.getStorage(CPROJECT_STORAGE_MODULE_LANGUAGE_SETTINGS_PROVIDERS, true); - if (!ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityDefined(project)) { - // set the flag if was not previously set by the user - to the default value - ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, - ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(project)); - } } catch (CoreException e) { CCorePlugin.log("Internal error while trying to serialize language settings", e); //$NON-NLS-1$ } @@ -1136,7 +1130,6 @@ public class LanguageSettingsProvidersSerializer { IProject project = prjDescription.getProject(); IFile storeInPrjArea = getStoreInProjectArea(project); boolean isStoreInProjectAreaExist = storeInPrjArea.exists(); - boolean enableLSP = isStoreInProjectAreaExist; if (isStoreInProjectAreaExist) { Document doc = null; try { @@ -1161,17 +1154,8 @@ public class LanguageSettingsProvidersSerializer { } catch (Exception e) { CCorePlugin.log("Can't load preferences from file " + storeInPrjArea.getLocation(), e); //$NON-NLS-1$ } - - } else { // Storage in project area does not exist - ICStorageElement lspStorageModule = null; - try { - lspStorageModule = prjDescription.getStorage(CPROJECT_STORAGE_MODULE_LANGUAGE_SETTINGS_PROVIDERS, false); - } catch (CoreException e) { - String msg = "Internal error while trying to load language settings"; //$NON-NLS-1$ - CCorePlugin.log(msg, e); - } - - // set default providers defined in the tool-chain + } else { + // If storage in project area does not exist set default providers defined in the tool-chain for (ICConfigurationDescription cfgDescription : prjDescription.getConfigurations()) { if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { String[] ids = ((ILanguageSettingsProvidersKeeper) cfgDescription).getDefaultLanguageSettingsProvidersIds(); @@ -1188,15 +1172,10 @@ public class LanguageSettingsProvidersSerializer { } } } - - enableLSP = lspStorageModule != null; - } - - if (!ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityDefined(project)) { - // set the flag if was not previously set by the user - ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, enableLSP); } + // propagate the preference to project properties + ScannerDiscoveryLegacySupport.defineLanguageSettingsEnablement(project); } /** diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ScannerInfoExtensionLanguageSettingsProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ScannerInfoExtensionLanguageSettingsProvider.java index fb2d1e637bc..956b7919d1a 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ScannerInfoExtensionLanguageSettingsProvider.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ScannerInfoExtensionLanguageSettingsProvider.java @@ -70,7 +70,7 @@ public class ScannerInfoExtensionLanguageSettingsProvider extends LanguageSettin * @return an instance of ScannerInfoProvider or {@code null}. */ public IScannerInfoProvider getScannerInfoProvider(ICConfigurationDescription cfgDescription) { - if (cfgDescription == null) { + if (cfgDescription == null || cfgDescription.isPreferenceConfiguration()) { return null; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescription.java index a545b61b779..c3e01c007ef 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescription.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescription.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Intel Corporation and others. + * Copyright (c) 2007, 2013 Intel Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -20,6 +20,8 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor; import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper; +import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager; +import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport; import org.eclipse.cdt.core.settings.model.CConfigurationStatus; import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent; import org.eclipse.cdt.core.settings.model.ICBuildSetting; @@ -158,6 +160,14 @@ public class CConfigurationDescription extends CDataProxyContainer CConfigurationDataProvider dataProvider = CProjectDescriptionManager.getInstance().getProvider(this); CConfigurationData data = dataProvider.loadConfiguration(this, new NullProgressMonitor()); setData(data); + + if (!fCfgSpecSettings.isLanguageSettingProvidersLoaded()) { + // default ids would come from the preference configuration, ensure sensible defaults + String[] defaultIds = ScannerDiscoveryLegacySupport.getDefaultProviderIdsLegacy(this); + List providers = LanguageSettingsManager.createLanguageSettingsProviders(defaultIds); + setDefaultLanguageSettingsProvidersIds(defaultIds); + setLanguageSettingProviders(providers); + } } void doWritable() throws CoreException { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescriptionCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescriptionCache.java index 52bd82b26d1..a2e473fe27e 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescriptionCache.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescriptionCache.java @@ -135,6 +135,18 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData CConfigurationDataProvider dataProvider = CProjectDescriptionManager.getInstance().getProvider(this); fData = dataProvider.loadConfiguration(this, new NullProgressMonitor()); + if (getDefaultLanguageSettingsProvidersIds() == null) { + // default ids would come from toolchain configuration, ensure sensible defaults + String[] defaultIds = ScannerDiscoveryLegacySupport.getDefaultProviderIdsLegacy(this); + setDefaultLanguageSettingsProvidersIds(defaultIds); + } + if (!fSpecSettings.isLanguageSettingProvidersLoaded()) { + // when loading - providers come from xml file, ensure defaults if no xml file present + String[] defaultIds = getDefaultLanguageSettingsProvidersIds(); + List providers = LanguageSettingsManager.createLanguageSettingsProviders(defaultIds); + setLanguageSettingProviders(providers); + } + copySettingsFrom(fData, true); fSpecSettings.reconcileExtensionSettings(true); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationSpecSettings.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationSpecSettings.java index d932e819661..10c52b88f47 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationSpecSettings.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationSpecSettings.java @@ -97,7 +97,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage, ILanguageS // private CConfigBasedDescriptor fDescriptor; // private Map fExternalSettingsProviderMap; - private List fLanguageSettingsProviders = new ArrayList(0); + private List fLanguageSettingsProviders = null; private LinkedHashMap lspPersistedState = new LinkedHashMap(); private String[] defaultLanguageSettingsProvidersIds = null; @@ -195,7 +195,16 @@ public class CConfigurationSpecSettings implements ICSettingsStorage, ILanguageS copyExtensionInfo(base); - fLanguageSettingsProviders = LanguageSettingsProvidersSerializer.cloneProviders(base.getLanguageSettingProviders()); + if (base.defaultLanguageSettingsProvidersIds != null) { + defaultLanguageSettingsProvidersIds = base.defaultLanguageSettingsProvidersIds.clone(); + } else { + defaultLanguageSettingsProvidersIds = null; + } + if (base.fLanguageSettingsProviders != null) { + fLanguageSettingsProviders = LanguageSettingsProvidersSerializer.cloneProviders(base.fLanguageSettingsProviders); + } else { + fLanguageSettingsProviders = base.fLanguageSettingsProviders; + } for (String providerId : base.lspPersistedState.keySet()) { try { LanguageSettingsStorage clone = base.lspPersistedState.get(providerId).clone(); @@ -204,11 +213,6 @@ public class CConfigurationSpecSettings implements ICSettingsStorage, ILanguageS CCorePlugin.log("Not able to clone language settings storage:" + e); //$NON-NLS-1$ } } - if (base.defaultLanguageSettingsProvidersIds != null) { - defaultLanguageSettingsProvidersIds = base.defaultLanguageSettingsProvidersIds.clone(); - } else { - defaultLanguageSettingsProvidersIds = null; - } } // private void copyRefInfos(Map infosMap){ @@ -1035,7 +1039,8 @@ public class CConfigurationSpecSettings implements ICSettingsStorage, ILanguageS @Override public List getLanguageSettingProviders() { - return Collections.unmodifiableList(fLanguageSettingsProviders); + List providers = isLanguageSettingProvidersLoaded() ? fLanguageSettingsProviders : new ArrayList(0); + return Collections.unmodifiableList(providers); } @Override @@ -1043,6 +1048,15 @@ public class CConfigurationSpecSettings implements ICSettingsStorage, ILanguageS defaultLanguageSettingsProvidersIds = ids; } + /** + * Check if language settings providers loaded into configuration settings yet + * + * @return {@code true} if loaded, {@code false} otherwise. + */ + public boolean isLanguageSettingProvidersLoaded() { + return fLanguageSettingsProviders != null; + } + @Override public String[] getDefaultLanguageSettingsProvidersIds() { return defaultLanguageSettingsProvidersIds; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java index 199deec8c8e..4d173d9f8d5 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java @@ -52,7 +52,6 @@ import javax.xml.transform.stream.StreamResult; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper; -import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElementDelta; @@ -2470,7 +2469,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } public boolean isNewStyleCfg(ICConfigurationDescription cfgDes){ - if(cfgDes == null) + if(cfgDes == null || cfgDes.isPreferenceConfiguration()) return false; CConfigurationData data = ((IInternalCCfgInfo)cfgDes).getConfigurationData(false); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlProjectDescriptionStorage.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlProjectDescriptionStorage.java index 3f0d15fa2ec..eafe5997e1f 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlProjectDescriptionStorage.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlProjectDescriptionStorage.java @@ -490,9 +490,9 @@ public class XmlProjectDescriptionStorage extends AbstractCProjectDescriptionSto CProjectDescription des = new CProjectDescription(project, new XmlStorage(storage), storage, true, false); try { setThreadLocalProjectDesc(des); - des.loadDatas(); LanguageSettingsProvidersSerializer.loadLanguageSettings(des); + des.loadDatas(); des.doneLoading(); } finally { setThreadLocalProjectDesc(null); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderTab.java index 41ada730f5f..9a008a05f5c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderTab.java @@ -1136,20 +1136,7 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab { if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { List cfgProviders = new ArrayList(((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders()); String[] defaultIds = ((ILanguageSettingsProvidersKeeper) cfgDescription).getDefaultLanguageSettingsProvidersIds(); - - List newProviders = new ArrayList(defaultIds.length); - for (String id : defaultIds) { - boolean preferShared = LanguageSettingsManager.isPreferShared(id); - ILanguageSettingsProvider newProvider = null; - if (!preferShared) { - newProvider = LanguageSettingsManager.getExtensionProviderCopy(id, true); - } - if (newProvider == null) { - newProvider = LanguageSettingsManager.getWorkspaceProvider(id); - } - newProviders.add(newProvider); - } - + List newProviders = LanguageSettingsManager.createLanguageSettingsProviders(defaultIds); if (!cfgProviders.equals(newProviders)) { ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(newProviders); }