mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-07 00:05:53 +02:00
bug 401961: Use more general CConfigurationDataProvider facilities to initialize language settings providers rather than do it in each New Project Wizard
This commit is contained in:
parent
4a20097fd3
commit
9002a13eb1
22 changed files with 292 additions and 208 deletions
|
@ -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);
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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<ILanguageSettingsProvider> 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){
|
||||
|
@ -531,65 +557,27 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
|
|||
Configuration cfg = load(cfgDescription, (ManagedProject)info.getManagedProject(), false);
|
||||
|
||||
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<ILanguageSettingsProvider> getDefaultLanguageSettingsProviders(IConfiguration cfg) {
|
||||
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
|
||||
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<ILanguageSettingsProvider> 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<ILanguageSettingsProvider> providers = ConfigurationDataProvider.getDefaultLanguageSettingsProviders(cfg);
|
||||
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isPersistedCfg(ICConfigurationDescription cfgDescription) {
|
||||
return cfgDescription.getSessionProperty(CFG_PERSISTED_PROPERTY) != null;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<ILanguageSettingsProvider> 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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
11
core/org.eclipse.cdt.core/.settings/.api_filters
Normal file
11
core/org.eclipse.cdt.core/.settings/.api_filters
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<component id="org.eclipse.cdt.core" version="2">
|
||||
<resource path="model/org/eclipse/cdt/core/language/settings/providers/ScannerDiscoveryLegacySupport.java" type="org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport">
|
||||
<filter comment="Former @noreference metod has been discontinued" id="338792546">
|
||||
<message_arguments>
|
||||
<message_argument value="org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport"/>
|
||||
<message_argument value="getDefaultProvidersLegacy()"/>
|
||||
</message_arguments>
|
||||
</filter>
|
||||
</resource>
|
||||
</component>
|
|
@ -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<ILanguageSettingsProvider> createLanguageSettingsProviders(String[] ids) {
|
||||
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<ILanguageSettingsProvider> 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<ILanguageSettingsProvider> getDefaultProvidersLegacy() {
|
||||
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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<ILanguageSettingsProvider> 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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<ILanguageSettingsProvider> providers = LanguageSettingsManager.createLanguageSettingsProviders(defaultIds);
|
||||
setDefaultLanguageSettingsProvidersIds(defaultIds);
|
||||
setLanguageSettingProviders(providers);
|
||||
}
|
||||
}
|
||||
|
||||
void doWritable() throws CoreException {
|
||||
|
|
|
@ -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<ILanguageSettingsProvider> providers = LanguageSettingsManager.createLanguageSettingsProviders(defaultIds);
|
||||
setLanguageSettingProviders(providers);
|
||||
}
|
||||
|
||||
copySettingsFrom(fData, true);
|
||||
|
||||
fSpecSettings.reconcileExtensionSettings(true);
|
||||
|
|
|
@ -97,7 +97,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage, ILanguageS
|
|||
// private CConfigBasedDescriptor fDescriptor;
|
||||
// private Map fExternalSettingsProviderMap;
|
||||
|
||||
private List<ILanguageSettingsProvider> fLanguageSettingsProviders = new ArrayList<ILanguageSettingsProvider>(0);
|
||||
private List<ILanguageSettingsProvider> fLanguageSettingsProviders = null;
|
||||
private LinkedHashMap<String /*provider*/, LanguageSettingsStorage> lspPersistedState = new LinkedHashMap<String, LanguageSettingsStorage>();
|
||||
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<ILanguageSettingsProvider> getLanguageSettingProviders() {
|
||||
return Collections.unmodifiableList(fLanguageSettingsProviders);
|
||||
List<ILanguageSettingsProvider> providers = isLanguageSettingProvidersLoaded() ? fLanguageSettingsProviders : new ArrayList<ILanguageSettingsProvider>(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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1136,20 +1136,7 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
|
|||
if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
|
||||
List<ILanguageSettingsProvider> cfgProviders = new ArrayList<ILanguageSettingsProvider>(((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders());
|
||||
String[] defaultIds = ((ILanguageSettingsProvidersKeeper) cfgDescription).getDefaultLanguageSettingsProvidersIds();
|
||||
|
||||
List<ILanguageSettingsProvider> newProviders = new ArrayList<ILanguageSettingsProvider>(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<ILanguageSettingsProvider> newProviders = LanguageSettingsManager.createLanguageSettingsProviders(defaultIds);
|
||||
if (!cfgProviders.equals(newProviders)) {
|
||||
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(newProviders);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue