mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Serialization of default providers
This commit is contained in:
parent
ded3f9e212
commit
2e2d1f833e
37 changed files with 974 additions and 278 deletions
|
@ -188,7 +188,8 @@
|
|||
class="org.eclipse.cdt.make.internal.core.scannerconfig.GCCBuildCommandParser"
|
||||
id="org.eclipse.cdt.make.core.build.command.parser.gcc"
|
||||
name="CDT GCC Build Output Parser"
|
||||
parameter="(gcc)|([gc]\+\+)">
|
||||
parameter="(gcc)|([gc]\+\+)"
|
||||
prefer-non-shared="true">
|
||||
</provider>
|
||||
</extension>
|
||||
|
||||
|
|
|
@ -546,7 +546,6 @@
|
|||
class="org.eclipse.cdt.make.core.scannerconfig.AbstractBuildCommandParser"
|
||||
icon="icons/obj16/log_obj.gif"
|
||||
page="org.eclipse.cdt.make.internal.ui.preferences.GCCBuildCommandParserOptionPage"
|
||||
shared="false"
|
||||
ui-clear-entries="true"
|
||||
ui-edit-entries="false">
|
||||
</class-association>
|
||||
|
@ -554,7 +553,6 @@
|
|||
class="org.eclipse.cdt.make.core.scannerconfig.AbstractBuiltinSpecsDetector"
|
||||
icon="icons/obj16/inspect_system.gif"
|
||||
page="org.eclipse.cdt.make.internal.ui.scannerconfig.BuiltinSpecsDetectorOptionPage"
|
||||
shared="true"
|
||||
ui-clear-entries="true"
|
||||
ui-edit-entries="false">
|
||||
</class-association>
|
||||
|
|
|
@ -15,8 +15,8 @@ package org.eclipse.cdt.managedbuilder.tests.suite;
|
|||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.build.core.scannerconfig.tests.AllLanguageSettingsProvidersMBSTests;
|
||||
import org.eclipse.cdt.build.core.scannerconfig.tests.CfgScannerConfigProfileManagerTests;
|
||||
import org.eclipse.cdt.build.core.scannerconfig.tests.GCCBuiltinSpecsDetectorTest;
|
||||
import org.eclipse.cdt.build.core.scannerconfig.tests.GCCSpecsConsoleParserTest;
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
|
@ -61,7 +61,9 @@ public class AllManagedBuildTests {
|
|||
// build.core.scannerconfig.tests
|
||||
suite.addTest(CfgScannerConfigProfileManagerTests.suite());
|
||||
suite.addTestSuite(GCCSpecsConsoleParserTest.class);
|
||||
suite.addTestSuite(GCCBuiltinSpecsDetectorTest.class);
|
||||
|
||||
// language settings providers tests
|
||||
suite.addTest(AllLanguageSettingsProvidersMBSTests.suite());
|
||||
|
||||
// managedbuilder.core.tests
|
||||
suite.addTest(ManagedBuildDependencyLibsTests.suite());
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
|
||||
package org.eclipse.cdt.build.core.scannerconfig.tests;
|
||||
|
||||
import org.eclipse.cdt.build.core.scannerconfig.tests.GCCBuiltinSpecsDetectorTest;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
public class AllLanguageSettingsProvidersMBSTests extends TestSuite {
|
||||
|
@ -24,6 +22,7 @@ public class AllLanguageSettingsProvidersMBSTests extends TestSuite {
|
|||
public AllLanguageSettingsProvidersMBSTests() {
|
||||
super(AllLanguageSettingsProvidersMBSTests.class.getName());
|
||||
|
||||
addTestSuite(LanguageSettingsProvidersMBSTest.class);
|
||||
addTestSuite(GCCBuiltinSpecsDetectorTest.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,173 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010, 2012 Andrew Gvozdev 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Gvozdev - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.build.core.scannerconfig.tests;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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.LanguageSettingsPersistenceProjectTests;
|
||||
import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport;
|
||||
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;
|
||||
|
||||
public class LanguageSettingsProvidersMBSTest extends BaseTestCase {
|
||||
private static final String MBS_LANGUAGE_SETTINGS_PROVIDER_ID = ScannerDiscoveryLegacySupport.MBS_LANGUAGE_SETTINGS_PROVIDER_ID;
|
||||
private static final String USER_LANGUAGE_SETTINGS_PROVIDER_ID = ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID;
|
||||
private static final String GCC_SPECS_DETECTOR_ID = "org.eclipse.cdt.managedbuilder.core.gcc.specs.detector";
|
||||
private static final String PROJECT_TYPE_EXECUTABLE_GNU = "cdt.managedbuild.target.gnu.exe";
|
||||
private static final String LANGUAGE_SETTINGS_PROJECT_XML = LanguageSettingsPersistenceProjectTests.LANGUAGE_SETTINGS_PROJECT_XML;
|
||||
private static final String LANGUAGE_SETTINGS_WORKSPACE_XML = LanguageSettingsPersistenceProjectTests.LANGUAGE_SETTINGS_WORKSPACE_XML;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
ManagedBuildTestHelper.removeProject(this.getName());
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* New Project Wizards do all these things
|
||||
*/
|
||||
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);
|
||||
|
||||
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, true);
|
||||
IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(cfgDescription);
|
||||
ConfigurationDataProvider.setDefaultLanguageSettingsProviders(cfg, cfgDescription);
|
||||
|
||||
assertTrue(((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders().size() > 0);
|
||||
}
|
||||
|
||||
CoreModel.getDefault().setProjectDescription(project, prjDescription);
|
||||
|
||||
return project;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void testGnuToolchainProviders() throws Exception {
|
||||
IProject project = imitateNewProjectWizard(this.getName(), PROJECT_TYPE_EXECUTABLE_GNU);
|
||||
|
||||
ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project, false);
|
||||
assertNotNull(prjDescription);
|
||||
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
|
||||
for (ICConfigurationDescription cfgDescription : cfgDescriptions) {
|
||||
assertNotNull(cfgDescription);
|
||||
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
|
||||
|
||||
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
|
||||
{
|
||||
ILanguageSettingsProvider provider = providers.get(0);
|
||||
String id = provider.getId();
|
||||
assertEquals(USER_LANGUAGE_SETTINGS_PROVIDER_ID, id);
|
||||
assertEquals(false, LanguageSettingsManager.isPreferShared(id));
|
||||
assertEquals(false, LanguageSettingsManager.isWorkspaceProvider(provider));
|
||||
}
|
||||
{
|
||||
ILanguageSettingsProvider provider = providers.get(1);
|
||||
String id = provider.getId();
|
||||
assertEquals(MBS_LANGUAGE_SETTINGS_PROVIDER_ID, id);
|
||||
assertEquals(true, LanguageSettingsManager.isPreferShared(id));
|
||||
assertEquals(true, LanguageSettingsManager.isWorkspaceProvider(provider));
|
||||
}
|
||||
{
|
||||
ILanguageSettingsProvider provider = providers.get(2);
|
||||
String id = provider.getId();
|
||||
assertEquals(GCC_SPECS_DETECTOR_ID, id);
|
||||
assertEquals(true, LanguageSettingsManager.isPreferShared(id));
|
||||
assertEquals(true, LanguageSettingsManager.isWorkspaceProvider(provider));
|
||||
}
|
||||
assertEquals(3, providers.size());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void testProjectPersistence_NoProviders() throws Exception {
|
||||
IProject project = imitateNewProjectWizard(this.getName(), PROJECT_TYPE_EXECUTABLE_GNU);
|
||||
|
||||
ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project, true);
|
||||
assertNotNull(prjDescription);
|
||||
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
|
||||
for (ICConfigurationDescription cfgDescription : cfgDescriptions) {
|
||||
assertNotNull(cfgDescription);
|
||||
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
|
||||
|
||||
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(new ArrayList<ILanguageSettingsProvider>());
|
||||
assertTrue(((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders().size() == 0);
|
||||
}
|
||||
|
||||
CoreModel.getDefault().setProjectDescription(project, prjDescription);
|
||||
|
||||
IFile xmlStorageFile = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
|
||||
assertEquals(true, xmlStorageFile.exists());
|
||||
|
||||
String xmlPrjWspStorageFileLocation = LanguageSettingsPersistenceProjectTests.getStoreLocationInWorkspaceArea(project.getName()+'.'+LANGUAGE_SETTINGS_WORKSPACE_XML);
|
||||
java.io.File xmlStorageFilePrjWsp = new java.io.File(xmlPrjWspStorageFileLocation);
|
||||
assertEquals(false, xmlStorageFilePrjWsp.exists());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void testProjectPersistence_Defaults() throws Exception {
|
||||
IProject project = imitateNewProjectWizard(this.getName(), PROJECT_TYPE_EXECUTABLE_GNU);
|
||||
|
||||
ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project, false);
|
||||
assertNotNull(prjDescription);
|
||||
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
|
||||
for (ICConfigurationDescription cfgDescription : cfgDescriptions) {
|
||||
assertNotNull(cfgDescription);
|
||||
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
|
||||
|
||||
String[] defaultIds = ((ILanguageSettingsProvidersKeeper) cfgDescription).getDefaultLanguageSettingsProvidersIds();
|
||||
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
|
||||
assertEquals(defaultIds.length, providers.size());
|
||||
for (int i = 0; i < defaultIds.length; i++) {
|
||||
assertEquals(providers.get(i).getId(), defaultIds[i]);
|
||||
}
|
||||
assertTrue(defaultIds.length > 0);
|
||||
}
|
||||
|
||||
IFile xmlStorageFile = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
|
||||
assertEquals(false, xmlStorageFile.exists());
|
||||
assertEquals(false, xmlStorageFile.getParent().exists()); // .settings folder
|
||||
|
||||
String xmlPrjWspStorageFileLocation = LanguageSettingsPersistenceProjectTests.getStoreLocationInWorkspaceArea(project.getName()+'.'+LANGUAGE_SETTINGS_WORKSPACE_XML);
|
||||
java.io.File xmlStorageFilePrjWsp = new java.io.File(xmlPrjWspStorageFileLocation);
|
||||
assertEquals(false, xmlStorageFilePrjWsp.exists());
|
||||
}
|
||||
|
||||
}
|
|
@ -15,6 +15,7 @@ Export-Package: org.eclipse.cdt.build.core.scannerconfig,
|
|||
org.eclipse.cdt.managedbuilder.envvar,
|
||||
org.eclipse.cdt.managedbuilder.internal.buildmodel;x-friends:="org.eclipse.cdt.managedbuilder.ui",
|
||||
org.eclipse.cdt.managedbuilder.internal.core;x-friends:="org.eclipse.cdt.managedbuilder.ui",
|
||||
org.eclipse.cdt.managedbuilder.internal.dataprovider;x-internal:=true,
|
||||
org.eclipse.cdt.managedbuilder.internal.envvar;x-internal:=true,
|
||||
org.eclipse.cdt.managedbuilder.internal.macros;x-friends:="org.eclipse.cdt.managedbuilder.ui",
|
||||
org.eclipse.cdt.managedbuilder.internal.scannerconfig;x-internal:=true,
|
||||
|
|
|
@ -172,8 +172,13 @@ public interface IConfiguration extends IBuildObject, IBuildObjectPropertiesCont
|
|||
*/
|
||||
public String[] getErrorParserList();
|
||||
|
||||
/** @since 8.1 */
|
||||
public String getDefaultLanguageSettingsProvidersIds();
|
||||
/**
|
||||
* Returns default language settings providers IDs specified for the configuration.
|
||||
* @return default language settings providers IDs.
|
||||
*
|
||||
* @since 8.1
|
||||
*/
|
||||
public String[] getDefaultLanguageSettingsProvidersIds();
|
||||
|
||||
/**
|
||||
* Projects have C or CC natures. Tools can specify a filter so they are not
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2003, 2011 IBM Corporation and others.
|
||||
* Copyright (c) 2003, 2012 IBM 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
|
||||
|
@ -26,6 +26,7 @@ import java.util.Vector;
|
|||
|
||||
import org.eclipse.cdt.build.core.scannerconfig.ICfgScannerConfigBuilderInfo2Set;
|
||||
import org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager.PathInfoCache;
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.ErrorParserManager;
|
||||
import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
|
||||
import org.eclipse.cdt.core.settings.model.CLibraryFileEntry;
|
||||
|
@ -86,8 +87,10 @@ import org.eclipse.core.resources.IResource;
|
|||
import org.eclipse.core.resources.IResourceDelta;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
import org.osgi.framework.Version;
|
||||
|
||||
|
@ -95,6 +98,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
|
|||
|
||||
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
|
||||
private static final String EMPTY_CFG_ID = "org.eclipse.cdt.build.core.emptycfg"; //$NON-NLS-1$
|
||||
private static final String LANGUAGE_SETTINGS_PROVIDER_DELIMITER = ";"; //$NON-NLS-1$
|
||||
|
||||
// Parent and children
|
||||
private String parentId;
|
||||
|
@ -105,7 +109,8 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
|
|||
private String cleanCommand;
|
||||
private String artifactExtension;
|
||||
private String errorParserIds;
|
||||
private String defaultLanguageSettingsProvidersIds;
|
||||
private String defaultLanguageSettingsProvidersAttribute;
|
||||
private String[] defaultLanguageSettingsProvidersIds;
|
||||
private String prebuildStep;
|
||||
private String postbuildStep;
|
||||
private String preannouncebuildStep;
|
||||
|
@ -786,7 +791,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
|
|||
errorParserIds = SafeStringInterner.safeIntern(element.getAttribute(ERROR_PARSERS));
|
||||
|
||||
// Get the initial/default language setttings providers IDs
|
||||
defaultLanguageSettingsProvidersIds = SafeStringInterner.safeIntern(element.getAttribute(LANGUAGE_SETTINGS_PROVIDERS));
|
||||
defaultLanguageSettingsProvidersAttribute = SafeStringInterner.safeIntern(element.getAttribute(LANGUAGE_SETTINGS_PROVIDERS));
|
||||
|
||||
// Get the artifact extension
|
||||
artifactExtension = SafeStringInterner.safeIntern(element.getAttribute(EXTENSION));
|
||||
|
@ -1460,8 +1465,52 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
|
|||
return set;
|
||||
}
|
||||
|
||||
private String getDefaultLanguageSettingsProvidersAttribute() {
|
||||
if (defaultLanguageSettingsProvidersAttribute == null && parent instanceof Configuration) {
|
||||
defaultLanguageSettingsProvidersAttribute = ((Configuration) parent).getDefaultLanguageSettingsProvidersAttribute();
|
||||
}
|
||||
|
||||
return defaultLanguageSettingsProvidersAttribute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultLanguageSettingsProvidersIds() {
|
||||
public String[] getDefaultLanguageSettingsProvidersIds() {
|
||||
defaultLanguageSettingsProvidersIds = null;
|
||||
if (defaultLanguageSettingsProvidersIds == null) {
|
||||
getDefaultLanguageSettingsProvidersAttribute();
|
||||
if (defaultLanguageSettingsProvidersAttribute != null) {
|
||||
List<String> ids = new ArrayList<String>();
|
||||
String[] defaultIds = defaultLanguageSettingsProvidersAttribute.split(LANGUAGE_SETTINGS_PROVIDER_DELIMITER);
|
||||
for (String id : defaultIds) {
|
||||
if (id != null && !id.isEmpty()) {
|
||||
if (id.startsWith("-")) {
|
||||
id = id.substring(1);
|
||||
ids.remove(id);
|
||||
} else if (!ids.contains(id)){
|
||||
if (id.contains("${Toolchain}")) {
|
||||
IToolChain toolchain = getToolChain();
|
||||
if (toolchain != null) {
|
||||
String toolchainProvidersIds = toolchain.getDefaultLanguageSettingsProvidersIds();
|
||||
if (toolchainProvidersIds != null) {
|
||||
ids.addAll(Arrays.asList(toolchainProvidersIds.split(LANGUAGE_SETTINGS_PROVIDER_DELIMITER)));
|
||||
} else {
|
||||
String message = "Invalid use of ${Toolchain} tag, toolchain does not specify language settings providers. cfg=" + getId();
|
||||
ManagedBuilderCorePlugin.log(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, IStatus.ERROR, message, new Exception()));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ids.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
defaultLanguageSettingsProvidersIds = ids.toArray(new String[ids.size()]);
|
||||
} else if (parent != null) {
|
||||
defaultLanguageSettingsProvidersIds = parent.getDefaultLanguageSettingsProvidersIds();
|
||||
}
|
||||
}
|
||||
|
||||
return defaultLanguageSettingsProvidersIds;
|
||||
}
|
||||
|
||||
|
|
|
@ -441,7 +441,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultLanguageSettingsProvidersIds() {
|
||||
public String[] getDefaultLanguageSettingsProvidersIds() {
|
||||
ManagedBuilderCorePlugin.error("Default Language Settings Providers are not supported in multiconfiguration mode");
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -1538,6 +1538,11 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
|
||||
@Override
|
||||
public String getDefaultLanguageSettingsProvidersIds() {
|
||||
if (defaultLanguageSettingsProvidersIds == null) {
|
||||
if (superClass instanceof IToolChain) {
|
||||
defaultLanguageSettingsProvidersIds = ((IToolChain) superClass).getDefaultLanguageSettingsProvidersIds();
|
||||
}
|
||||
}
|
||||
return defaultLanguageSettingsProvidersIds;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,10 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.build.internal.core.scannerconfig2.CfgScannerConfigInfoFactory2;
|
||||
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.model.ILanguageDescriptor;
|
||||
import org.eclipse.cdt.core.model.LanguageManager;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
|
@ -532,28 +536,74 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
|
|||
}
|
||||
|
||||
@Override
|
||||
public CConfigurationData loadConfiguration(ICConfigurationDescription des,
|
||||
IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
if(des.isPreferenceConfiguration())
|
||||
return loadPreferences(des);
|
||||
public CConfigurationData loadConfiguration(ICConfigurationDescription cfgDescription, IProgressMonitor monitor) throws CoreException {
|
||||
if(cfgDescription.isPreferenceConfiguration())
|
||||
return loadPreferences(cfgDescription);
|
||||
|
||||
IManagedBuildInfo info = getBuildInfo(des);
|
||||
Configuration cfg = load(des, (ManagedProject)info.getManagedProject(), false);
|
||||
IManagedBuildInfo info = getBuildInfo(cfgDescription);
|
||||
Configuration cfg = load(cfgDescription, (ManagedProject)info.getManagedProject(), false);
|
||||
|
||||
if(cfg != null){
|
||||
cfg.setConfigurationDescription(des);
|
||||
cfg.setConfigurationDescription(cfgDescription);
|
||||
info.setValid(true);
|
||||
setPersistedFlag(des);
|
||||
cacheNaturesIdsUsedOnCache(des);
|
||||
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(des.getProjectDescription().getProject(), info);
|
||||
ManagedBuildManager.setLoaddedBuildInfo(cfgDescription.getProjectDescription().getProject(), info);
|
||||
setDefaultLanguageSettingsProvidersIds(cfg, cfgDescription);
|
||||
return cfg.getConfigurationData();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static List<ILanguageSettingsProvider> getDefaultLanguageSettingsProviders(IConfiguration cfg) {
|
||||
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
|
||||
String[] ids = cfg.getDefaultLanguageSettingsProvidersIds();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
if (providers.isEmpty()) {
|
||||
// Add MBS and User provider for unsuspecting toolchains (backward compatibility)
|
||||
ILanguageSettingsProvider userProvider = LanguageSettingsManager.getExtensionProviderCopy(ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID, true);
|
||||
ILanguageSettingsProvider mbsProvider = LanguageSettingsManager.getWorkspaceProvider(ScannerDiscoveryLegacySupport.MBS_LANGUAGE_SETTINGS_PROVIDER_ID);
|
||||
providers.add(userProvider);
|
||||
providers.add(mbsProvider);
|
||||
}
|
||||
|
||||
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(IConfiguration cfg, ICConfigurationDescription cfgDescription) {
|
||||
setDefaultLanguageSettingsProvidersIds(cfg, cfgDescription);
|
||||
List<ILanguageSettingsProvider> providers = getDefaultLanguageSettingsProviders(cfg);
|
||||
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
|
||||
}
|
||||
|
||||
|
||||
private boolean isPersistedCfg(ICConfigurationDescription cfgDes){
|
||||
return cfgDes.getSessionProperty(CFG_PERSISTED_PROPERTY) != null;
|
||||
}
|
||||
|
|
|
@ -208,7 +208,7 @@ public class TestConfiguration implements IConfiguration {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultLanguageSettingsProvidersIds() {
|
||||
public String[] getDefaultLanguageSettingsProvidersIds() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -653,7 +653,6 @@
|
|||
<id-association
|
||||
id="org.eclipse.cdt.managedbuilder.core.LanguageSettingsProvider"
|
||||
icon="icons/obj16/mbs.gif"
|
||||
shared="true"
|
||||
ui-clear-entries="false"
|
||||
ui-edit-entries="false">
|
||||
</id-association>
|
||||
|
|
|
@ -33,7 +33,6 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
|||
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
|
||||
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
|
||||
import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
|
||||
import org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProviderAssociationManager;
|
||||
import org.eclipse.cdt.internal.ui.wizards.ICDTCommonProjectWizard;
|
||||
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty;
|
||||
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
|
||||
|
@ -46,6 +45,7 @@ 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;
|
||||
|
@ -93,11 +93,6 @@ public class MBSWizardHandler extends CWizardHandler {
|
|||
private static final String PROPERTY = "org.eclipse.cdt.build.core.buildType"; //$NON-NLS-1$
|
||||
private static final String PROP_VAL = PROPERTY + ".debug"; //$NON-NLS-1$
|
||||
|
||||
private static final String UI_USER_LANGUAGE_SETTINGS_PROVIDER = "org.eclipse.cdt.ui.user.LanguageSettingsProvider";
|
||||
/** @since 8.1 */
|
||||
public static final String MBS_LANGUAGE_SETTINGS_PROVIDER = "org.eclipse.cdt.managedbuilder.core.LanguageSettingsProvider";
|
||||
private static final String LANGUAGE_SETTINGS_PROVIDER_DELIMITER = ";";
|
||||
|
||||
private static final String tooltip =
|
||||
Messages.CWizardHandler_1 +
|
||||
Messages.CWizardHandler_2 +
|
||||
|
@ -613,12 +608,12 @@ public class MBSWizardHandler extends CWizardHandler {
|
|||
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, isTryingNewSD);
|
||||
List<ILanguageSettingsProvider> providers;
|
||||
if (isTryingNewSD) {
|
||||
providers = MBSWizardHandler.getLanguageSettingsProviders(config);
|
||||
ConfigurationDataProvider.setDefaultLanguageSettingsProviders(config, cfgDes);
|
||||
} else {
|
||||
providers = new ArrayList<ILanguageSettingsProvider>();
|
||||
providers.add(LanguageSettingsManager.getWorkspaceProvider(MBSWizardHandler.MBS_LANGUAGE_SETTINGS_PROVIDER));
|
||||
}
|
||||
providers.add(LanguageSettingsManager.getWorkspaceProvider(ScannerDiscoveryLegacySupport.MBS_LANGUAGE_SETTINGS_PROVIDER_ID));
|
||||
((ILanguageSettingsProvidersKeeper) cfgDes).setLanguageSettingProviders(providers);
|
||||
}
|
||||
} else {
|
||||
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, false);
|
||||
}
|
||||
|
@ -866,93 +861,4 @@ public class MBSWizardHandler extends CWizardHandler {
|
|||
return super.canFinish();
|
||||
}
|
||||
|
||||
private static String getLanguageSettingsProvidersStr(IToolChain toolchain) {
|
||||
for (;toolchain!=null;toolchain=toolchain.getSuperClass()) {
|
||||
String providersIdsStr = toolchain.getDefaultLanguageSettingsProvidersIds();
|
||||
if (providersIdsStr!=null) {
|
||||
return providersIdsStr;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private static String getLanguageSettingsProvidersStr(IConfiguration cfg) {
|
||||
for (;cfg!=null;cfg=cfg.getParent()) {
|
||||
String providersIdsStr = cfg.getDefaultLanguageSettingsProvidersIds();
|
||||
if (providersIdsStr!=null) {
|
||||
return providersIdsStr;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 8.1
|
||||
*/
|
||||
public static List<ILanguageSettingsProvider> getLanguageSettingsProviders(IConfiguration cfg) {
|
||||
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
|
||||
|
||||
String providersIdsStr = getLanguageSettingsProvidersStr(cfg);
|
||||
if (providersIdsStr!=null) {
|
||||
if (providersIdsStr.contains("${Toolchain}")) {
|
||||
IToolChain toolchain = cfg.getToolChain();
|
||||
String toolchainProvidersIds = getLanguageSettingsProvidersStr(toolchain);
|
||||
if (toolchainProvidersIds==null) {
|
||||
toolchainProvidersIds="";
|
||||
}
|
||||
providersIdsStr = providersIdsStr.replaceAll("\\$\\{Toolchain\\}", toolchainProvidersIds);
|
||||
}
|
||||
List<String> providersIds = Arrays.asList(providersIdsStr.split(LANGUAGE_SETTINGS_PROVIDER_DELIMITER));
|
||||
for (String id : providersIds) {
|
||||
id = id.trim();
|
||||
ILanguageSettingsProvider provider = null;
|
||||
if (id.startsWith("-")) {
|
||||
id = id.substring(1);
|
||||
for (ILanguageSettingsProvider pr : providers) {
|
||||
if (pr.getId().equals(id)) {
|
||||
providers.remove(pr);
|
||||
// Has to break as the collection is invalidated
|
||||
// TODO: remove all elements or better use unique list
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (id.length()>0) {
|
||||
ILanguageSettingsProvider providerExt = LanguageSettingsManager.getExtensionProviderCopy(id, false);
|
||||
if (providerExt == null || LanguageSettingsProviderAssociationManager.shouldBeShared(providerExt)) {
|
||||
provider = LanguageSettingsManager.getWorkspaceProvider(id);
|
||||
} else {
|
||||
provider = providerExt;
|
||||
}
|
||||
}
|
||||
if (provider!=null) {
|
||||
providers.add(provider);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (providers.isEmpty()) {
|
||||
// Add MBS provider for unsuspecting toolchains (backward compatibility)
|
||||
ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(MBS_LANGUAGE_SETTINGS_PROVIDER);
|
||||
providers.add(provider);
|
||||
}
|
||||
|
||||
if (!isProviderThere(providers, UI_USER_LANGUAGE_SETTINGS_PROVIDER)) {
|
||||
ILanguageSettingsProvider provider = LanguageSettingsManager.getExtensionProviderCopy(UI_USER_LANGUAGE_SETTINGS_PROVIDER, true);
|
||||
providers.add(0, provider);
|
||||
}
|
||||
|
||||
return providers;
|
||||
}
|
||||
|
||||
private static boolean isProviderThere(List<ILanguageSettingsProvider> providers, String id) {
|
||||
for (ILanguageSettingsProvider provider : providers) {
|
||||
if (provider.getId().equals(id)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ 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;
|
||||
|
@ -122,14 +123,13 @@ public class NewMakeProjFromExisting extends Wizard implements IImportWizard, IN
|
|||
|
||||
if (cfgDes instanceof ILanguageSettingsProvidersKeeper) {
|
||||
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, isTryingNewSD);
|
||||
List<ILanguageSettingsProvider> providers;
|
||||
if (isTryingNewSD) {
|
||||
providers = MBSWizardHandler.getLanguageSettingsProviders(config);
|
||||
ConfigurationDataProvider.setDefaultLanguageSettingsProviders(config, cfgDes);
|
||||
} else {
|
||||
providers = new ArrayList<ILanguageSettingsProvider>();
|
||||
providers.add(LanguageSettingsManager.getWorkspaceProvider(MBSWizardHandler.MBS_LANGUAGE_SETTINGS_PROVIDER));
|
||||
}
|
||||
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
|
||||
providers.add(LanguageSettingsManager.getWorkspaceProvider(ScannerDiscoveryLegacySupport.MBS_LANGUAGE_SETTINGS_PROVIDER_ID));
|
||||
((ILanguageSettingsProvidersKeeper) cfgDes).setLanguageSettingProviders(providers);
|
||||
}
|
||||
} else {
|
||||
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, false);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ 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.ui.wizards.CDTMainWizardPage;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -120,14 +121,13 @@ public class STDWizardHandler extends MBSWizardHandler {
|
|||
}
|
||||
|
||||
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, isTryingNewSD);
|
||||
List<ILanguageSettingsProvider> providers;
|
||||
if (isTryingNewSD) {
|
||||
providers = MBSWizardHandler.getLanguageSettingsProviders(cfg);
|
||||
ConfigurationDataProvider.setDefaultLanguageSettingsProviders(cfg, cfgDes);
|
||||
} else {
|
||||
providers = new ArrayList<ILanguageSettingsProvider>();
|
||||
providers.add(LanguageSettingsManager.getWorkspaceProvider(MBSWizardHandler.MBS_LANGUAGE_SETTINGS_PROVIDER));
|
||||
}
|
||||
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
|
||||
providers.add(LanguageSettingsManager.getWorkspaceProvider(ScannerDiscoveryLegacySupport.MBS_LANGUAGE_SETTINGS_PROVIDER_ID));
|
||||
((ILanguageSettingsProvidersKeeper) cfgDes).setLanguageSettingProviders(providers);
|
||||
}
|
||||
} else {
|
||||
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, false);
|
||||
}
|
||||
|
@ -136,7 +136,10 @@ public class STDWizardHandler extends MBSWizardHandler {
|
|||
}
|
||||
mngr.setProjectDescription(project, des);
|
||||
}
|
||||
public boolean canCreateWithoutToolchain() { return true; }
|
||||
|
||||
public boolean canCreateWithoutToolchain() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void convertProject(IProject proj, IProgressMonitor monitor) throws CoreException {
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.eclipse.cdt.core.settings.model.CMacroFileEntry;
|
|||
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
||||
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsExtensionManager;
|
||||
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
|
@ -356,6 +357,7 @@ public class LanguageSettingsExtensionsTests extends BaseTestCase {
|
|||
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(providerExt);
|
||||
assertTrue(rawProvider instanceof LanguageSettingsSerializableProvider);
|
||||
assertTrue(LanguageSettingsManager.isEqualExtensionProvider(rawProvider, true));
|
||||
assertEquals(true, LanguageSettingsExtensionManager.isPreferShared(EXTENSION_SERIALIZABLE_PROVIDER_ID));
|
||||
}
|
||||
|
||||
// Editable providers are retrieved by copy
|
||||
|
@ -365,6 +367,7 @@ public class LanguageSettingsExtensionsTests extends BaseTestCase {
|
|||
assertFalse(LanguageSettingsManager.isWorkspaceProvider(providerExt));
|
||||
assertTrue(providerExt instanceof ILanguageSettingsEditableProvider);
|
||||
assertTrue(LanguageSettingsManager.isEqualExtensionProvider(providerExt, true));
|
||||
assertEquals(LanguageSettingsExtensionManager.isPreferShared(EXTENSION_EDITABLE_PROVIDER_ID), false);
|
||||
|
||||
// test that different copies are not same
|
||||
ILanguageSettingsProvider providerExt2 = LanguageSettingsManager.getExtensionProviderCopy(EXTENSION_EDITABLE_PROVIDER_ID, true);
|
||||
|
|
|
@ -60,6 +60,8 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
|
|||
|
||||
class MockConfigurationDescription extends CModelMock.DummyCConfigurationDescription implements ILanguageSettingsProvidersKeeper {
|
||||
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
|
||||
String[] defaultProvidersIds = null;
|
||||
|
||||
public MockConfigurationDescription(String id) {
|
||||
super(id);
|
||||
}
|
||||
|
@ -73,6 +75,16 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
|
|||
public List<ILanguageSettingsProvider> getLanguageSettingProviders() {
|
||||
return providers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultLanguageSettingsProvidersIds(String[] ids) {
|
||||
defaultProvidersIds = ids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getDefaultLanguageSettingsProvidersIds() {
|
||||
return defaultProvidersIds;
|
||||
}
|
||||
}
|
||||
|
||||
private class MockProvider extends AbstractExecutableExtensionBase implements ILanguageSettingsProvider {
|
||||
|
@ -127,7 +139,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test ICConfigurationDescription API (getters and setters).
|
||||
* Test ILanguageSettingsProvidersKeeper API (getters and setters).
|
||||
*/
|
||||
public void testConfigurationDescription_Providers() throws Exception {
|
||||
MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID);
|
||||
|
@ -146,6 +158,13 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
|
|||
assertEquals(provider2, actual.get(1));
|
||||
assertEquals(providers.size(), actual.size());
|
||||
assertNotSame(actual, providers);
|
||||
|
||||
// set default providers
|
||||
String[] defaultProviders = { PROVIDER_0, PROVIDER_1 };
|
||||
cfgDescription.setDefaultLanguageSettingsProvidersIds(defaultProviders);
|
||||
|
||||
// get default providers
|
||||
assertEquals(defaultProviders, cfgDescription.getDefaultLanguageSettingsProvidersIds());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
package org.eclipse.cdt.core.language.settings.providers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
@ -44,21 +45,26 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
|||
private static final String EXTENSION_BASE_PROVIDER_ID = LanguageSettingsExtensionsTests.EXTENSION_BASE_PROVIDER_ID;
|
||||
private static final String EXTENSION_BASE_PROVIDER_NAME = LanguageSettingsExtensionsTests.EXTENSION_BASE_PROVIDER_NAME;
|
||||
private static final String EXTENSION_SERIALIZABLE_PROVIDER_ID = LanguageSettingsExtensionsTests.EXTENSION_SERIALIZABLE_PROVIDER_ID;
|
||||
private static final String EXTENSION_EDITABLE_PROVIDER_ID = LanguageSettingsExtensionsTests.EXTENSION_EDITABLE_PROVIDER_ID;
|
||||
private static final String EXTENSION_USER_PROVIDER_ID = LanguageSettingsExtensionsTests.EXTENSION_USER_PROVIDER_ID;
|
||||
private static final ICLanguageSettingEntry EXTENSION_SERIALIZABLE_PROVIDER_ENTRY = LanguageSettingsExtensionsTests.EXTENSION_SERIALIZABLE_PROVIDER_ENTRY;
|
||||
|
||||
private static final String LANGUAGE_SETTINGS_PROJECT_XML = ".settings/language.settings.xml";
|
||||
private static final String LANGUAGE_SETTINGS_WORKSPACE_XML = "language.settings.xml";
|
||||
public static final String LANGUAGE_SETTINGS_PROJECT_XML = ".settings/language.settings.xml";
|
||||
public static final String LANGUAGE_SETTINGS_WORKSPACE_XML = "language.settings.xml";
|
||||
|
||||
private static final String CFG_ID = "test.configuration.id.0";
|
||||
private static final String CFG_ID_2 = "test.configuration.id.2";
|
||||
private static final String PROVIDER_0 = "test.provider.0.id";
|
||||
private static final String PROVIDER_1 = "test.provider.1.id";
|
||||
private static final String PROVIDER_2 = "test.provider.2.id";
|
||||
private static final String PROVIDER_NAME_0 = "test.provider.0.name";
|
||||
private static final String PROVIDER_NAME_1 = "test.provider.1.name";
|
||||
private static final String PROVIDER_NAME_2 = "test.provider.2.name";
|
||||
private static final String ATTR_PARAMETER = "parameter";
|
||||
private static final String CUSTOM_PARAMETER = "custom parameter";
|
||||
private static final String ELEM_TEST = "test";
|
||||
private static final String ELEM_PROVIDER = "provider "; // keep space for more reliable comparison
|
||||
private static final String ELEM_PROVIDER_REFERENCE = "provider-reference";
|
||||
|
||||
private static CoreModel coreModel = CoreModel.getDefault();
|
||||
|
||||
|
@ -77,6 +83,15 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
|||
public List<ILanguageSettingsProvider> getLanguageSettingProviders() {
|
||||
return providers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultLanguageSettingsProvidersIds(String[] ids) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getDefaultLanguageSettingsProvidersIds() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
class MockProjectDescription extends CModelMock.DummyCProjectDescription {
|
||||
ICConfigurationDescription[] cfgDescriptions;
|
||||
|
@ -215,7 +230,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
|||
assertNotNull(cfgDescription);
|
||||
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
|
||||
|
||||
// try to write to it
|
||||
// try to write to it providers
|
||||
try {
|
||||
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
|
||||
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
|
||||
|
@ -223,6 +238,14 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
|||
} catch (WriteAccessException e) {
|
||||
// exception is expected
|
||||
}
|
||||
|
||||
// try to write to it default providers ids
|
||||
try {
|
||||
((ILanguageSettingsProvidersKeeper) cfgDescription).setDefaultLanguageSettingsProvidersIds(new String[] { PROVIDER_0 });
|
||||
fail("WriteAccessException was expected but it was not throw.");
|
||||
} catch (WriteAccessException e) {
|
||||
// exception is expected
|
||||
}
|
||||
}
|
||||
|
||||
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
|
||||
|
@ -238,8 +261,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
|||
assertNotNull(cfgDescription);
|
||||
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
|
||||
|
||||
// create a provider
|
||||
LanguageSettingsSerializableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_0, PROVIDER_NAME_0);
|
||||
// create a provider and write to cfgDescription
|
||||
LanguageSettingsSerializableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1);
|
||||
LanguageSettingsManager.setStoringEntriesInProjectArea(mockProvider, true);
|
||||
mockProvider.setSettingEntries(cfgDescription, null, null, entries);
|
||||
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
|
||||
|
@ -248,6 +271,9 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
|||
List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
|
||||
assertEquals(1, storedProviders.size());
|
||||
|
||||
// write to cfgDescription default providers ids
|
||||
((ILanguageSettingsProvidersKeeper) cfgDescription).setDefaultLanguageSettingsProvidersIds(new String[] { PROVIDER_0 });
|
||||
|
||||
// apply new project description to the project model
|
||||
coreModel.setProjectDescription(project, writableProjDescription);
|
||||
}
|
||||
|
@ -261,16 +287,21 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
|||
assertNotNull(cfgDescription);
|
||||
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
|
||||
|
||||
// double-check providers
|
||||
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
|
||||
assertEquals(1, providers.size());
|
||||
ILanguageSettingsProvider loadedProvider = providers.get(0);
|
||||
assertTrue(loadedProvider instanceof MockLanguageSettingsEditableProvider);
|
||||
assertEquals(PROVIDER_0, loadedProvider.getId());
|
||||
assertEquals(PROVIDER_NAME_0, loadedProvider.getName());
|
||||
|
||||
assertEquals(PROVIDER_1, loadedProvider.getId());
|
||||
assertEquals(PROVIDER_NAME_1, loadedProvider.getName());
|
||||
// double-check provider's setting entries
|
||||
List<ICLanguageSettingEntry> actual = loadedProvider.getSettingEntries(cfgDescription, null, null);
|
||||
assertEquals(entries.get(0), actual.get(0));
|
||||
assertEquals(entries.size(), actual.size());
|
||||
|
||||
// double-check default providers ids
|
||||
String[] actualDefaultProvidersIds = ((ILanguageSettingsProvidersKeeper) cfgDescription).getDefaultLanguageSettingsProvidersIds();
|
||||
assertTrue(Arrays.equals(new String[] { PROVIDER_0 }, actualDefaultProvidersIds));
|
||||
}
|
||||
{
|
||||
// get writable project descriptions
|
||||
|
@ -282,16 +313,21 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
|||
assertNotNull(cfgDescription);
|
||||
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
|
||||
|
||||
// check providers
|
||||
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
|
||||
assertEquals(1, providers.size());
|
||||
ILanguageSettingsProvider loadedProvider = providers.get(0);
|
||||
assertTrue(loadedProvider instanceof MockLanguageSettingsEditableProvider);
|
||||
assertEquals(PROVIDER_0, loadedProvider.getId());
|
||||
assertEquals(PROVIDER_NAME_0, loadedProvider.getName());
|
||||
|
||||
assertEquals(PROVIDER_1, loadedProvider.getId());
|
||||
assertEquals(PROVIDER_NAME_1, loadedProvider.getName());
|
||||
// check provider's setting entries
|
||||
List<ICLanguageSettingEntry> actual = loadedProvider.getSettingEntries(cfgDescription, null, null);
|
||||
assertEquals(entries.get(0), actual.get(0));
|
||||
assertEquals(entries.size(), actual.size());
|
||||
|
||||
// check default providers ids
|
||||
String[] actualDefaultProvidersIds = ((ILanguageSettingsProvidersKeeper) cfgDescription).getDefaultLanguageSettingsProvidersIds();
|
||||
assertTrue(Arrays.equals(new String[] { PROVIDER_0 }, actualDefaultProvidersIds));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1188,7 +1224,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
|||
* @param store - name of the store
|
||||
* @return location of the store in the plug-in state area
|
||||
*/
|
||||
private static String getStoreLocationInWorkspaceArea(String store) {
|
||||
public static String getStoreLocationInWorkspaceArea(String store) {
|
||||
IPath location = CCorePlugin.getDefault().getStateLocation().append(store);
|
||||
return location.toString();
|
||||
}
|
||||
|
@ -1358,5 +1394,174 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void testProjectPersistence_ProviderExtensionReferenceDOM() throws Exception {
|
||||
Document doc = XmlUtil.newDocument();
|
||||
Element storageElement = XmlUtil.appendElement(doc, ELEM_TEST);
|
||||
|
||||
ILanguageSettingsProvider providerExt = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID);
|
||||
assertNotNull(providerExt);
|
||||
|
||||
{
|
||||
// create a provider
|
||||
MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID));
|
||||
|
||||
ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations();
|
||||
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
|
||||
assertNotNull(cfgDescription);
|
||||
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
|
||||
|
||||
|
||||
ArrayList<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
|
||||
providers.add(providerExt);
|
||||
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
|
||||
|
||||
// prepare DOM storage
|
||||
LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(storageElement, null, mockPrjDescription);
|
||||
|
||||
String xml = XmlUtil.toString(doc);
|
||||
assertTrue(xml.contains(ELEM_PROVIDER_REFERENCE));
|
||||
assertTrue(xml.contains(EXTENSION_BASE_PROVIDER_ID));
|
||||
assertTrue(xml.contains(LanguageSettingsProvidersSerializer.ATTR_ID));
|
||||
assertFalse(xml.contains(LanguageSettingsProvidersSerializer.ATTR_CLASS));
|
||||
}
|
||||
{
|
||||
// re-load and check language settings of the newly loaded provider
|
||||
MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID));
|
||||
LanguageSettingsProvidersSerializer.loadLanguageSettingsInternal(storageElement, null, mockPrjDescription);
|
||||
|
||||
ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations();
|
||||
assertNotNull(cfgDescriptions);
|
||||
assertEquals(1, cfgDescriptions.length);
|
||||
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
|
||||
assertNotNull(cfgDescription);
|
||||
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
|
||||
|
||||
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
|
||||
assertNotNull(providers);
|
||||
assertEquals(1, providers.size());
|
||||
ILanguageSettingsProvider provider = providers.get(0);
|
||||
assertEquals(providerExt, provider);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void testProjectPersistence_ProviderExtensionCopyDOM() throws Exception {
|
||||
Document doc = XmlUtil.newDocument();
|
||||
Element storageElement = XmlUtil.appendElement(doc, ELEM_TEST);
|
||||
|
||||
ILanguageSettingsProvider providerExt = LanguageSettingsManager.getExtensionProviderCopy(EXTENSION_EDITABLE_PROVIDER_ID, true);
|
||||
assertNotNull(providerExt);
|
||||
|
||||
{
|
||||
// create a provider
|
||||
MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID));
|
||||
|
||||
ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations();
|
||||
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
|
||||
assertNotNull(cfgDescription);
|
||||
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
|
||||
|
||||
|
||||
ArrayList<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
|
||||
providers.add(providerExt);
|
||||
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
|
||||
|
||||
// prepare DOM storage
|
||||
LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(storageElement, null, mockPrjDescription);
|
||||
|
||||
String xml = XmlUtil.toString(doc);
|
||||
assertTrue(xml.contains(ELEM_PROVIDER));
|
||||
assertTrue(xml.contains(EXTENSION_EDITABLE_PROVIDER_ID));
|
||||
assertTrue(xml.contains(LanguageSettingsProvidersSerializer.ATTR_ID));
|
||||
assertFalse(xml.contains(LanguageSettingsProvidersSerializer.ATTR_CLASS));
|
||||
}
|
||||
{
|
||||
// re-load and check language settings of the newly loaded provider
|
||||
MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID));
|
||||
LanguageSettingsProvidersSerializer.loadLanguageSettingsInternal(storageElement, null, mockPrjDescription);
|
||||
|
||||
ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations();
|
||||
assertNotNull(cfgDescriptions);
|
||||
assertEquals(1, cfgDescriptions.length);
|
||||
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
|
||||
assertNotNull(cfgDescription);
|
||||
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
|
||||
|
||||
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
|
||||
assertNotNull(providers);
|
||||
assertEquals(1, providers.size());
|
||||
ILanguageSettingsProvider provider = providers.get(0);
|
||||
assertEquals(providerExt, provider);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void testProjectPersistence_Defaults() throws Exception {
|
||||
// AG TODO - create and check real MBS projects with some providers
|
||||
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
|
||||
IFile xmlStorageFile = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
|
||||
assertFalse(xmlStorageFile.exists());
|
||||
|
||||
String xmlPrjWspStorageFileLocation = getStoreLocationInWorkspaceArea(project.getName()+'.'+LANGUAGE_SETTINGS_WORKSPACE_XML);
|
||||
java.io.File xmlStorageFilePrjWsp = new java.io.File(xmlPrjWspStorageFileLocation);
|
||||
assertFalse(xmlStorageFilePrjWsp.exists());
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void testWorkspacePersistence_ProviderExtensionCopy() throws Exception {
|
||||
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
|
||||
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
|
||||
entries.add(new CIncludePathEntry("path0", 0));
|
||||
{
|
||||
// get extension provider
|
||||
ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID);
|
||||
LanguageSettingsSerializableProvider rawProvider = (LanguageSettingsSerializableProvider) LanguageSettingsManager.getRawProvider(provider);
|
||||
assertNotNull(rawProvider);
|
||||
assertEquals(EXTENSION_EDITABLE_PROVIDER_ID, rawProvider.getId());
|
||||
|
||||
// add non-modified provider to the list
|
||||
providers.add(provider);
|
||||
}
|
||||
{
|
||||
// get another extension provider
|
||||
ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
|
||||
LanguageSettingsSerializableProvider rawProvider = (LanguageSettingsSerializableProvider) LanguageSettingsManager.getRawProvider(provider);
|
||||
assertNotNull(rawProvider);
|
||||
assertEquals(EXTENSION_SERIALIZABLE_PROVIDER_ID, rawProvider.getId());
|
||||
// modify it and add it to the list
|
||||
rawProvider.setSettingEntries(null, null, null, entries);
|
||||
providers.add(rawProvider);
|
||||
|
||||
// set and serialize language settings of workspace providers
|
||||
LanguageSettingsManager.setWorkspaceProviders(providers);
|
||||
LanguageSettingsManager.serializeLanguageSettingsWorkspace();
|
||||
}
|
||||
{
|
||||
String xmlWspStorageFileLocation = getStoreLocationInWorkspaceArea(LANGUAGE_SETTINGS_WORKSPACE_XML);
|
||||
String xml = ResourceHelper.getContents(xmlWspStorageFileLocation);
|
||||
// provider matching extension is not saved (extensions added automatically during loading providers)
|
||||
assertFalse(xml.contains(EXTENSION_EDITABLE_PROVIDER_ID));
|
||||
// provider that differs is saved
|
||||
assertTrue(xml.contains(EXTENSION_SERIALIZABLE_PROVIDER_ID));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void testWorkspacePersistence_Defaults() throws Exception {
|
||||
// reset and serialize workspace providers
|
||||
LanguageSettingsManager.setWorkspaceProviders(null);
|
||||
LanguageSettingsManager.serializeLanguageSettingsWorkspace();
|
||||
|
||||
// check that XML file is not created
|
||||
String xmlWspStorageFileLocation = getStoreLocationInWorkspaceArea(LANGUAGE_SETTINGS_WORKSPACE_XML);
|
||||
java.io.File xmlStorageFileWsp = new java.io.File(xmlWspStorageFileLocation);
|
||||
assertFalse(xmlStorageFileWsp.exists());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -192,7 +192,8 @@
|
|||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.cdt.core.LanguageSettingsProvider">
|
||||
<!-- uncomment to test message about missing class in the log
|
||||
<!-- uncomment to test message about missing class in the log -->
|
||||
<!--
|
||||
<provider
|
||||
class="org.eclipse.cdt.core.language.settings.providers.MissingClass"
|
||||
id="org.eclipse.cdt.core.tests.missing.language.settings.provider"
|
||||
|
@ -265,7 +266,8 @@
|
|||
<provider
|
||||
class="org.eclipse.cdt.core.language.settings.providers.MockLanguageSettingsEditableProvider"
|
||||
id="org.eclipse.cdt.core.tests.custom.editable.language.settings.provider"
|
||||
name="Test Plugin Mock Editable Language Settings Provider">
|
||||
name="Test Plugin Mock Editable Language Settings Provider"
|
||||
prefer-non-shared="true">
|
||||
<entry
|
||||
kind="macro"
|
||||
name="MACRO"
|
||||
|
|
|
@ -15,11 +15,14 @@ package org.eclipse.cdt.core.testplugin;
|
|||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
@ -675,6 +678,42 @@ public class ResourceHelper {
|
|||
return windowsPath.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get contents of file on file-system.
|
||||
*
|
||||
* @param fullPath - full path to the file on the file-system.
|
||||
* @return contents of the file.
|
||||
* @throws IOException on IO problem.
|
||||
*/
|
||||
public static String getContents(IPath fullPath) throws IOException {
|
||||
FileInputStream stream = new FileInputStream(fullPath.toFile());
|
||||
try {
|
||||
// Avoid using java.nio.channels.FileChannel,
|
||||
// see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4715154
|
||||
Reader reader = new BufferedReader(new InputStreamReader(stream, Charset.defaultCharset()));
|
||||
StringBuilder builder = new StringBuilder();
|
||||
char[] buffer = new char[8192];
|
||||
int read;
|
||||
while ((read = reader.read(buffer, 0, buffer.length)) > 0) {
|
||||
builder.append(buffer, 0, read);
|
||||
}
|
||||
return builder.toString();
|
||||
} finally {
|
||||
stream.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get contents of file on file-system.
|
||||
*
|
||||
* @param fullPath - full path to the file on the file-system.
|
||||
* @return contents of the file.
|
||||
* @throws IOException on IO problem.
|
||||
*/
|
||||
public static String getContents(String fullPath) throws IOException {
|
||||
return getContents(new Path(fullPath));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean-up any files created as part of a unit test.
|
||||
* This method removes *all* Workspace IResources and any external
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2011, 2011 Andrew Gvozdev and others.
|
||||
* Copyright (c) 2011, 2012 Andrew Gvozdev 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
|
||||
|
@ -47,4 +47,23 @@ public interface ILanguageSettingsProvidersKeeper {
|
|||
*/
|
||||
public List<ILanguageSettingsProvider> getLanguageSettingProviders();
|
||||
|
||||
/**
|
||||
* Sets the list of IDs of default language settings providers.
|
||||
* <br><br>
|
||||
* The method is intended to be used by MBS to set the list from tool-chain definition.
|
||||
* The default list from the tool-chain is used, for example, while resetting
|
||||
* configuration providers to default in UI.
|
||||
*
|
||||
* @param ids - default provider IDs specified in the tool-chain.
|
||||
*/
|
||||
public void setDefaultLanguageSettingsProvidersIds(String[] ids);
|
||||
|
||||
/**
|
||||
* Retrieve the list of IDs of default language settings providers.
|
||||
* Normally the list would come from the tool-chain definition.
|
||||
*
|
||||
* @return default provider IDs or {@code null} if default providers are not defined.
|
||||
*/
|
||||
public String[] getDefaultLanguageSettingsProvidersIds();
|
||||
|
||||
}
|
||||
|
|
|
@ -57,12 +57,13 @@ public class LanguageSettingsManager {
|
|||
return LanguageSettingsProvidersSerializer.getSettingEntriesUpResourceTree(provider, cfgDescription, rc, languageId);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get Language Settings Provider from the list of workspace providers,
|
||||
* see {@link #getWorkspaceProviders()}.
|
||||
*
|
||||
* @param id - id of provider to find.
|
||||
* @return the provider or {@code null} if provider is not defined.
|
||||
* @return the workspace provider. If workspace provider is not defined
|
||||
* a new instance is created and returned.
|
||||
*/
|
||||
public static ILanguageSettingsProvider getWorkspaceProvider(String id) {
|
||||
return LanguageSettingsProvidersSerializer.getWorkspaceProvider(id);
|
||||
|
@ -174,7 +175,7 @@ public class LanguageSettingsManager {
|
|||
* @return - {@code true} if the provider matches the extension or {@code false} otherwise.
|
||||
*/
|
||||
public static boolean isEqualExtensionProvider(ILanguageSettingsProvider provider, boolean deep) {
|
||||
return LanguageSettingsExtensionManager.isEqualsExtensionProvider(provider, deep);
|
||||
return LanguageSettingsExtensionManager.isEqualExtensionProvider(provider, deep);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -278,6 +279,21 @@ public class LanguageSettingsManager {
|
|||
LanguageSettingsProvidersSerializer.unregisterLanguageSettingsChangeListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells if the provider is meant to be shared between projects in workspace
|
||||
* or belong to a specific configuration. This attribute is defined in
|
||||
* {@code org.eclipse.cdt.core.LanguageSettingsProvider} extension point.
|
||||
* <br>Note that only {@link ILanguageSettingsEditableProvider} can be owned by
|
||||
* a configuration.
|
||||
*
|
||||
* @param id - ID of the provider to inquire.
|
||||
* @return {@code true} if the provider is designed to be shared,
|
||||
* {@code false} if configuration-owned.
|
||||
*/
|
||||
public static boolean isPreferShared(String id) {
|
||||
return LanguageSettingsExtensionManager.isPreferShared(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells if language settings entries of the provider are persisted with the project
|
||||
* (under .settings/ folder) or in workspace area. Persistence in the project area lets
|
||||
|
|
|
@ -33,8 +33,10 @@ import org.osgi.service.prefs.Preferences;
|
|||
* @since 5.4
|
||||
*/
|
||||
public class ScannerDiscoveryLegacySupport {
|
||||
/** Name of MBS language settings provider (from org.eclipse.cdt.managedbuilder.core) */
|
||||
public static final String MBS_LANGUAGE_SETTINGS_PROVIDER = "org.eclipse.cdt.managedbuilder.core.LanguageSettingsProvider"; //$NON-NLS-1$
|
||||
/** ID of User language settings provider (from org.eclipse.cdt.ui) */
|
||||
public static final String USER_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.ui.user.LanguageSettingsProvider"; //$NON-NLS-1$
|
||||
/** ID of MBS language settings provider (from org.eclipse.cdt.managedbuilder.core) */
|
||||
public static final String MBS_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.managedbuilder.core.LanguageSettingsProvider"; //$NON-NLS-1$
|
||||
|
||||
private static String USE_LANGUAGE_SETTINGS_PROVIDERS_PREFERENCE = "enabled"; //$NON-NLS-1$
|
||||
// the default needs to be "false" for legacy projects to be open with old SD enabled for MBS provider
|
||||
|
@ -91,7 +93,7 @@ public class ScannerDiscoveryLegacySupport {
|
|||
if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
|
||||
List<ILanguageSettingsProvider> lsProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
|
||||
for (ILanguageSettingsProvider lsp : lsProviders) {
|
||||
if (MBS_LANGUAGE_SETTINGS_PROVIDER.equals(lsp.getId())) {
|
||||
if (MBS_LANGUAGE_SETTINGS_PROVIDER_ID.equals(lsp.getId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ public class LanguageSettingsExtensionManager {
|
|||
static final String ATTR_ID = "id"; //$NON-NLS-1$
|
||||
static final String ATTR_NAME = "name"; //$NON-NLS-1$
|
||||
static final String ATTR_CLASS = "class"; //$NON-NLS-1$
|
||||
static final String ATTR_PREFER_NON_SHARED = "prefer-non-shared"; //$NON-NLS-1$
|
||||
|
||||
static final String ELEM_PROVIDER = "provider"; //$NON-NLS-1$
|
||||
static final String ELEM_LANGUAGE_SCOPE = "language-scope"; //$NON-NLS-1$
|
||||
|
@ -359,7 +360,7 @@ public class LanguageSettingsExtensionManager {
|
|||
* Shallow equality is applicable only for {@link ILanguageSettingsEditableProvider}.
|
||||
* @return - {@code true} if the provider matches the extension or {@code false} otherwise.
|
||||
*/
|
||||
public static boolean isEqualsExtensionProvider(ILanguageSettingsProvider provider, boolean deep) {
|
||||
public static boolean isEqualExtensionProvider(ILanguageSettingsProvider provider, boolean deep) {
|
||||
String id = provider.getId();
|
||||
if (deep || !(provider instanceof ILanguageSettingsEditableProvider)) {
|
||||
ILanguageSettingsProvider extensionProvider = fExtensionProviders.get(id);
|
||||
|
@ -372,4 +373,22 @@ public class LanguageSettingsExtensionManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells if the provider is meant to be shared between projects in workspace
|
||||
* or belong to a specific configuration. This attribute is defined in
|
||||
* {@code org.eclipse.cdt.core.LanguageSettingsProvider} extension point.
|
||||
* <br>Note that only {@link ILanguageSettingsEditableProvider} can be owned by
|
||||
* a configuration.
|
||||
*
|
||||
* @param id - ID of the provider to inquire.
|
||||
* @return {@code true} if the provider is designed to be shared,
|
||||
* {@code false} if configuration-owned.
|
||||
*/
|
||||
public static boolean isPreferShared(String id) {
|
||||
ILanguageSettingsProvider provider = fExtensionProviders.get(id);
|
||||
if (provider instanceof LanguageSettingsBaseProvider && provider instanceof ILanguageSettingsEditableProvider) {
|
||||
return ! ((LanguageSettingsBaseProvider) provider).getPropertyBool(ATTR_PREFER_NON_SHARED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ 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;
|
||||
|
@ -73,9 +74,9 @@ public class LanguageSettingsProvidersSerializer {
|
|||
public static final String ELEM_LANGUAGE_SCOPE = LanguageSettingsExtensionManager.ELEM_LANGUAGE_SCOPE;
|
||||
|
||||
private static final String PREFERENCE_WORSPACE_PROVIDERS_SET = "language.settings.providers.workspace.prefs.toggle"; //$NON-NLS-1$
|
||||
private static final String CPROJECT_STORAGE_MODULE = "org.eclipse.cdt.core.LanguageSettingsProviders"; //$NON-NLS-1$
|
||||
private static final String STORAGE_WORKSPACE_LANGUAGE_SETTINGS = "language.settings.xml"; //$NON-NLS-1$
|
||||
private static final String SETTINGS_FOLDER_NAME = ".settings/"; //$NON-NLS-1$
|
||||
private static final String STORAGE_PROJECT_LANGUAGE_SETTINGS = "language.settings.xml"; //$NON-NLS-1$
|
||||
private static final String STORAGE_PROJECT_PATH = ".settings/language.settings.xml"; //$NON-NLS-1$
|
||||
|
||||
private static final String ELEM_PLUGIN = "plugin"; //$NON-NLS-1$
|
||||
private static final String ELEM_EXTENSION = "extension"; //$NON-NLS-1$
|
||||
|
@ -85,6 +86,12 @@ public class LanguageSettingsProvidersSerializer {
|
|||
private static final String ELEM_PROVIDER_REFERENCE = "provider-reference"; //$NON-NLS-1$
|
||||
private static final String ATTR_STORE_ENTRIES_WITH_PROJECT = "store-entries-with-project"; //$NON-NLS-1$
|
||||
|
||||
// those are for readability of xml only
|
||||
private static final String ATTR_REF = "ref"; //$NON-NLS-1$
|
||||
private static final String VALUE_REF_SHARED_PROVIDER = "shared-provider"; //$NON-NLS-1$
|
||||
private static final String ATTR_COPY_OF = "copy-of"; //$NON-NLS-1$
|
||||
private static final String VALUE_COPY_OF_EXTENSION = "extension"; //$NON-NLS-1$
|
||||
|
||||
/** Cache of true (raw) workspace providers */
|
||||
private static Map<String, ILanguageSettingsProvider> rawGlobalWorkspaceProviders = new HashMap<String, ILanguageSettingsProvider>();
|
||||
/** Cache of workspace providers wrappers */
|
||||
|
@ -301,13 +308,8 @@ public class LanguageSettingsProvidersSerializer {
|
|||
* @param store - name of the store.
|
||||
* @return location of the store in the plug-in state area.
|
||||
*/
|
||||
private static IFile getStoreInProjectArea(IProject project) throws CoreException {
|
||||
IFolder folder = project.getFolder(SETTINGS_FOLDER_NAME);
|
||||
if (!folder.exists()) {
|
||||
folder.create(true, true, null);
|
||||
}
|
||||
IFile storage = folder.getFile(STORAGE_PROJECT_LANGUAGE_SETTINGS);
|
||||
return storage;
|
||||
private static IFile getStoreInProjectArea(IProject project) {
|
||||
return project.getFile(STORAGE_PROJECT_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -465,9 +467,11 @@ public class LanguageSettingsProvidersSerializer {
|
|||
List<LanguageSettingsSerializableProvider> serializableWorkspaceProviders = new ArrayList<LanguageSettingsSerializableProvider>();
|
||||
for (ILanguageSettingsProvider provider : rawGlobalWorkspaceProviders.values()) {
|
||||
if (provider instanceof LanguageSettingsSerializableProvider) {
|
||||
if (!LanguageSettingsManager.isEqualExtensionProvider(provider, true)) {
|
||||
serializableWorkspaceProviders.add((LanguageSettingsSerializableProvider)provider);
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
List<LanguageSettingsChangeEvent> events = null;
|
||||
if (serializableWorkspaceProviders.isEmpty()) {
|
||||
|
@ -487,10 +491,8 @@ public class LanguageSettingsProvidersSerializer {
|
|||
new String[] {ATTR_EXTENSION_POINT, PROVIDER_EXTENSION_POINT_ID});
|
||||
|
||||
for (LanguageSettingsSerializableProvider provider : serializableWorkspaceProviders) {
|
||||
if (!LanguageSettingsManager.isEqualExtensionProvider(provider, true)) {
|
||||
provider.serialize(elementExtension);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
serializingLock.acquire();
|
||||
|
@ -567,6 +569,7 @@ public class LanguageSettingsProvidersSerializer {
|
|||
if (!(cfgDescription instanceof ILanguageSettingsProvidersKeeper))
|
||||
continue;
|
||||
|
||||
// no lazy initialization as we may need to save 0 providers when it is different from default
|
||||
Element elementConfiguration = XmlUtil.appendElement(projectElementPrjStore, ELEM_CONFIGURATION, new String[] {
|
||||
ATTR_ID, cfgDescription.getId(),
|
||||
ATTR_NAME, cfgDescription.getName(),
|
||||
|
@ -574,27 +577,60 @@ public class LanguageSettingsProvidersSerializer {
|
|||
Element elementConfigurationWsp = null;
|
||||
|
||||
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
|
||||
if (providers.size()>0) {
|
||||
Element elementExtension = XmlUtil.appendElement(elementConfiguration, ELEM_EXTENSION, new String[] {
|
||||
ATTR_EXTENSION_POINT, PROVIDER_EXTENSION_POINT_ID});
|
||||
if (providers.size() > 0) {
|
||||
Element elementExtension = null;
|
||||
Element elementExtensionWsp = null;
|
||||
|
||||
for (ILanguageSettingsProvider provider : providers) {
|
||||
if (isWorkspaceProvider(provider)) {
|
||||
if (elementExtension == null) {
|
||||
elementExtension = XmlUtil.appendElement(elementConfiguration, ELEM_EXTENSION, new String[] {
|
||||
ATTR_EXTENSION_POINT, PROVIDER_EXTENSION_POINT_ID});
|
||||
}
|
||||
// Element elementProviderReference =
|
||||
XmlUtil.appendElement(elementExtension, ELEM_PROVIDER_REFERENCE, new String[] {
|
||||
ATTR_ID, provider.getId()});
|
||||
ATTR_ID, provider.getId(),
|
||||
ATTR_REF, VALUE_REF_SHARED_PROVIDER,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
if (provider instanceof LanguageSettingsSerializableProvider) {
|
||||
if (!(provider instanceof LanguageSettingsSerializableProvider)) {
|
||||
if (elementExtension == null) {
|
||||
elementExtension = XmlUtil.appendElement(elementConfiguration, ELEM_EXTENSION, new String[] {
|
||||
ATTR_EXTENSION_POINT, PROVIDER_EXTENSION_POINT_ID});
|
||||
}
|
||||
// Element elementProvider =
|
||||
XmlUtil.appendElement(elementExtension, ELEM_PROVIDER, new String[] {
|
||||
ATTR_ID, provider.getId(),
|
||||
ATTR_NAME, provider.getName(),
|
||||
ATTR_CLASS, provider.getClass().getCanonicalName(),
|
||||
});
|
||||
} else if (LanguageSettingsManager.isEqualExtensionProvider(provider, true)) {
|
||||
if (elementExtension == null) {
|
||||
elementExtension = XmlUtil.appendElement(elementConfiguration, ELEM_EXTENSION, new String[] {
|
||||
ATTR_EXTENSION_POINT, PROVIDER_EXTENSION_POINT_ID});
|
||||
}
|
||||
// Element elementProvider =
|
||||
XmlUtil.appendElement(elementExtension, ELEM_PROVIDER, new String[] {
|
||||
ATTR_ID, provider.getId(),
|
||||
ATTR_COPY_OF, VALUE_COPY_OF_EXTENSION,
|
||||
});
|
||||
} else {
|
||||
try {
|
||||
LanguageSettingsSerializableProvider lss = (LanguageSettingsSerializableProvider) provider;
|
||||
|
||||
boolean isWspStorageAvailable = (projectElementWspStore != null) && (projectElementPrjStore != projectElementWspStore);
|
||||
if (isStoringEntriesInProjectArea(lss) || !isWspStorageAvailable) {
|
||||
if (elementExtension == null) {
|
||||
elementExtension = XmlUtil.appendElement(elementConfiguration, ELEM_EXTENSION, new String[] {
|
||||
ATTR_EXTENSION_POINT, PROVIDER_EXTENSION_POINT_ID});
|
||||
}
|
||||
lss.serialize(elementExtension);
|
||||
} else {
|
||||
// lazy initialization of wsp storage elements - to avoid serialization of no-data file
|
||||
if (elementExtension == null) {
|
||||
elementExtension = XmlUtil.appendElement(elementConfiguration, ELEM_EXTENSION, new String[] {
|
||||
ATTR_EXTENSION_POINT, PROVIDER_EXTENSION_POINT_ID});
|
||||
}
|
||||
if (elementExtensionWsp == null) {
|
||||
if (elementConfigurationWsp == null) {
|
||||
elementConfigurationWsp = XmlUtil.appendElement(projectElementWspStore, ELEM_CONFIGURATION, new String[] {
|
||||
|
@ -606,7 +642,7 @@ public class LanguageSettingsProvidersSerializer {
|
|||
ATTR_EXTENSION_POINT, PROVIDER_EXTENSION_POINT_ID});
|
||||
}
|
||||
Element elementProviderWsp = XmlUtil.appendElement(elementExtensionWsp, ELEM_PROVIDER, new String[] {
|
||||
ATTR_ID, provider.getId()});
|
||||
ATTR_ID, provider.getId() }); // no attributes kept in workspace storage
|
||||
|
||||
// split storage
|
||||
lss.serializeAttributes(elementExtension);
|
||||
|
@ -616,19 +652,59 @@ public class LanguageSettingsProvidersSerializer {
|
|||
// protect from any exceptions from implementers
|
||||
CCorePlugin.log("Exception trying serialize provider "+provider.getId(), e); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if all the language settings providers in the project match defaults.
|
||||
*/
|
||||
private static boolean isEqualToDefaultProviders(ICProjectDescription prjDescription) {
|
||||
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
|
||||
for (ICConfigurationDescription cfgDescription : cfgDescriptions) {
|
||||
if (!(cfgDescription instanceof ILanguageSettingsProvidersKeeper)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String[] defaultIds = ((ILanguageSettingsProvidersKeeper) cfgDescription).getDefaultLanguageSettingsProvidersIds();
|
||||
if (defaultIds == null) {
|
||||
defaultIds = new String[0];
|
||||
}
|
||||
|
||||
// check size
|
||||
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
|
||||
if (providers.size() != defaultIds.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// check ids
|
||||
for (int i = 0; i < defaultIds.length; i++) {
|
||||
ILanguageSettingsProvider provider = providers.get(i);
|
||||
if (!provider.getId().equals(defaultIds[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// check equality (most expensive, so check last)
|
||||
for (ILanguageSettingsProvider provider : providers) {
|
||||
if (LanguageSettingsManager.isPreferShared(provider.getId())) {
|
||||
if (!isWorkspaceProvider(provider)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// Element elementProvider =
|
||||
XmlUtil.appendElement(elementExtension, ELEM_PROVIDER, new String[] {
|
||||
ATTR_ID, provider.getId(),
|
||||
ATTR_NAME, provider.getName(),
|
||||
ATTR_CLASS, provider.getClass().getCanonicalName(),
|
||||
});
|
||||
if (!LanguageSettingsManager.isEqualExtensionProvider(provider, true)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save language settings providers of a project to persistent storage.
|
||||
*
|
||||
|
@ -640,6 +716,14 @@ public class LanguageSettingsProvidersSerializer {
|
|||
// AG FIXME - temporary log to remove before CDT Juno release
|
||||
LanguageSettingsLogger.logWarning("LanguageSettingsProvidersSerializer.serializeLanguageSettings() for " + project);
|
||||
|
||||
try {
|
||||
// Using side effect of adding the module to the storage
|
||||
prjDescription.getStorage(CPROJECT_STORAGE_MODULE, true);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log("Internal error while trying to serialize language settings", e); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
// The storage could be split in two, one for provider properties, another one for entries,
|
||||
// depending on provider flag
|
||||
|
@ -651,19 +735,33 @@ public class LanguageSettingsProvidersSerializer {
|
|||
Document docStoreWsp = XmlUtil.newDocument();
|
||||
Element projectElementStoreWsp = XmlUtil.appendElement(docStoreWsp, ELEM_PROJECT);
|
||||
|
||||
// The project store should not be absent. Currently absent store means legacy project, not 0 providers.
|
||||
IFile fileStorePrj = getStoreInProjectArea(project);
|
||||
|
||||
URI uriStoreWsp = getStoreInWorkspaceArea(project.getName()+'.'+STORAGE_WORKSPACE_LANGUAGE_SETTINGS);
|
||||
LanguageSettingsChangeEvent event = null;
|
||||
|
||||
try {
|
||||
serializingLock.acquire();
|
||||
|
||||
// Note that need for serialization may exist even if LS *entries* event delta is empty,
|
||||
// as set of providers or their properties may differ
|
||||
|
||||
serializingLock.acquire();
|
||||
|
||||
if (!isEqualToDefaultProviders(prjDescription)) {
|
||||
serializeLanguageSettingsInternal(projectElementStorePrj, projectElementStoreWsp, prjDescription);
|
||||
}
|
||||
|
||||
// Absent store means default providers as specified in the toolchain
|
||||
IFile fileStorePrj = getStoreInProjectArea(project);
|
||||
boolean isProjectStoreEmpty = projectElementStorePrj.getChildNodes().getLength() == 0;
|
||||
if (isProjectStoreEmpty) {
|
||||
if (fileStorePrj.exists()) {
|
||||
fileStorePrj.delete(true, null);
|
||||
}
|
||||
} else {
|
||||
IContainer folder = fileStorePrj.getParent();
|
||||
if (folder instanceof IFolder && !folder.exists()) {
|
||||
((IFolder) folder).create(true, true, null);
|
||||
}
|
||||
XmlUtil.serializeXml(docStorePrj, fileStorePrj);
|
||||
}
|
||||
|
||||
// project-specific location in workspace area
|
||||
boolean isWorkspaceStoreEmpty = projectElementStoreWsp.getChildNodes().getLength() == 0;
|
||||
|
@ -733,6 +831,19 @@ public class LanguageSettingsProvidersSerializer {
|
|||
String providerId = XmlUtil.determineAttributeValue(providerNode, ATTR_ID);
|
||||
provider = getWorkspaceProvider(providerId);
|
||||
} else if (isElementWithName(providerNode, ELEM_PROVIDER)) {
|
||||
String providerClass = XmlUtil.determineAttributeValue(providerNode, ATTR_CLASS);
|
||||
if (providerClass == null || providerClass.isEmpty()) {
|
||||
// provider is copied from extension if "class" is not supplied
|
||||
String providerId = XmlUtil.determineAttributeValue(providerNode, ATTR_ID);
|
||||
provider = LanguageSettingsManager.getExtensionProviderCopy(providerId, true);
|
||||
|
||||
if (provider == null) {
|
||||
String msg = "Internal Error trying to copy extension provider id=" + providerId; //$NON-NLS-1$
|
||||
CCorePlugin.log(new Status(IStatus.WARNING, CCorePlugin.PLUGIN_ID, msg, new Exception(msg)));
|
||||
|
||||
provider = LanguageSettingsManager.getWorkspaceProvider(providerId);
|
||||
}
|
||||
} else {
|
||||
provider = loadProvider(providerNode);
|
||||
if (provider instanceof LanguageSettingsSerializableProvider) {
|
||||
LanguageSettingsSerializableProvider lss = (LanguageSettingsSerializableProvider) provider;
|
||||
|
@ -741,6 +852,7 @@ public class LanguageSettingsProvidersSerializer {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (provider != null) {
|
||||
providers.add(provider);
|
||||
}
|
||||
|
@ -748,10 +860,19 @@ public class LanguageSettingsProvidersSerializer {
|
|||
}
|
||||
|
||||
ICConfigurationDescription cfgDescription = prjDescription.getConfigurationById(cfgId);
|
||||
setProvidersWithoutNotification(cfgDescription, providers);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set providers into configuration description avoiding triggering an event.
|
||||
*/
|
||||
private static void setProvidersWithoutNotification(ICConfigurationDescription cfgDescription, List<ILanguageSettingsProvider> providers) {
|
||||
if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
|
||||
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
|
||||
if (cfgDescription instanceof IInternalCCfgInfo) {
|
||||
try {
|
||||
// swallow delta
|
||||
((IInternalCCfgInfo) cfgDescription).getSpecSettings().dropDelta();
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
|
@ -759,7 +880,6 @@ public class LanguageSettingsProvidersSerializer {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the node is {@code Element} and that the name matches.
|
||||
|
@ -837,11 +957,11 @@ public class LanguageSettingsProvidersSerializer {
|
|||
*/
|
||||
public static void loadLanguageSettings(ICProjectDescription prjDescription) {
|
||||
IProject project = prjDescription.getProject();
|
||||
IFile storeInPrjArea = project.getFile(SETTINGS_FOLDER_NAME + STORAGE_PROJECT_LANGUAGE_SETTINGS);
|
||||
IFile storeInPrjArea = getStoreInProjectArea(project);
|
||||
try {
|
||||
Job currentJob = Job.getJobManager().currentJob();
|
||||
ISchedulingRule currentRule = (currentJob != null) ? currentJob.getRule() : null;
|
||||
if (currentRule == null || currentRule.contains(storeInPrjArea)) {
|
||||
if ((currentRule == null || currentRule.contains(storeInPrjArea)) && !ResourcesPlugin.getWorkspace().isTreeLocked()) {
|
||||
storeInPrjArea.refreshLocal(IResource.DEPTH_ZERO, null);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
|
@ -874,16 +994,45 @@ public class LanguageSettingsProvidersSerializer {
|
|||
}
|
||||
|
||||
} else {
|
||||
// Already existing legacy projects
|
||||
// Storage in project area does not exist
|
||||
ICStorageElement storageElement = null;
|
||||
try {
|
||||
storageElement = prjDescription.getStorage(CPROJECT_STORAGE_MODULE, false);
|
||||
} catch (CoreException e) {
|
||||
String msg = "Internal error while trying to load language settings"; //$NON-NLS-1$
|
||||
CCorePlugin.log(msg, e);
|
||||
}
|
||||
|
||||
if (storageElement != null) {
|
||||
// set default providers defined in the tool-chain
|
||||
for (ICConfigurationDescription cfgDescription : prjDescription.getConfigurations()) {
|
||||
String[] ids = ((ILanguageSettingsProvidersKeeper) cfgDescription).getDefaultLanguageSettingsProvidersIds();
|
||||
if (ids != null) {
|
||||
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(ids.length);
|
||||
for (String id : ids) {
|
||||
if (LanguageSettingsExtensionManager.isPreferShared(id)) {
|
||||
providers.add(LanguageSettingsManager.getWorkspaceProvider(id));
|
||||
} else {
|
||||
providers.add(LanguageSettingsManager.getExtensionProviderCopy(id, true));
|
||||
}
|
||||
|
||||
}
|
||||
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// Older existing legacy projects unaware of Language Settings Providers and their persistence store
|
||||
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
|
||||
for (ICConfigurationDescription cfgDescription : cfgDescriptions) {
|
||||
if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
|
||||
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(2);
|
||||
ILanguageSettingsProvider providerMBS = getWorkspaceProvider(ScannerDiscoveryLegacySupport.MBS_LANGUAGE_SETTINGS_PROVIDER);
|
||||
providers.add(providerMBS);
|
||||
providers.add(LanguageSettingsExtensionManager.getExtensionProviderCopy((ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID), true));
|
||||
providers.add(getWorkspaceProvider(ScannerDiscoveryLegacySupport.MBS_LANGUAGE_SETTINGS_PROVIDER_ID));
|
||||
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -893,7 +1042,8 @@ public class LanguageSettingsProvidersSerializer {
|
|||
* see {@link #getWorkspaceProviders()}.
|
||||
*
|
||||
* @param id - ID of provider to find.
|
||||
* @return the provider or {@code null} if provider is not defined.
|
||||
* @return the workspace provider. If provider is not defined - still workspace
|
||||
* provider wrapper is created and returned.
|
||||
*/
|
||||
public static ILanguageSettingsProvider getWorkspaceProvider(String id) {
|
||||
ILanguageSettingsProvider provider = globalWorkspaceProviders.get(id);
|
||||
|
|
|
@ -832,8 +832,7 @@ public class CConfigurationDescription extends CDataProxyContainer
|
|||
@Override
|
||||
public void setLanguageSettingProviders(List<ILanguageSettingsProvider> providers) {
|
||||
try {
|
||||
CConfigurationSpecSettings specSettings = getSpecSettings();
|
||||
specSettings.setLanguageSettingProviders(providers);
|
||||
getSpecSettings().setLanguageSettingProviders(providers);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
|
@ -848,4 +847,23 @@ public class CConfigurationDescription extends CDataProxyContainer
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultLanguageSettingsProvidersIds(String[] ids) {
|
||||
try {
|
||||
getSpecSettings().setDefaultLanguageSettingsProvidersIds(ids);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getDefaultLanguageSettingsProvidersIds() {
|
||||
try {
|
||||
return getSpecSettings().getDefaultLanguageSettingsProvidersIds();
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -628,4 +628,16 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData
|
|||
public List<ILanguageSettingsProvider> getLanguageSettingProviders() {
|
||||
return fSpecSettings.getLanguageSettingProviders();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultLanguageSettingsProvidersIds(String[] ids) {
|
||||
if(!fInitializing)
|
||||
throw ExceptionFactory.createIsReadOnlyException();
|
||||
fSpecSettings.setDefaultLanguageSettingsProvidersIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getDefaultLanguageSettingsProvidersIds() {
|
||||
return fSpecSettings.getDefaultLanguageSettingsProvidersIds();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.Set;
|
|||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsBroadcastingProvider;
|
||||
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.LanguageSettingsStorage;
|
||||
import org.eclipse.cdt.core.settings.model.CExternalSetting;
|
||||
|
@ -57,7 +58,7 @@ import org.eclipse.core.runtime.QualifiedName;
|
|||
* This corresponds to the <cconfiguration id="....> elements within
|
||||
* the org.eclipse.cdt.core.settings storageModule in the project xml file
|
||||
*/
|
||||
public class CConfigurationSpecSettings implements ICSettingsStorage{
|
||||
public class CConfigurationSpecSettings implements ICSettingsStorage, ILanguageSettingsProvidersKeeper {
|
||||
static final String BUILD_SYSTEM_ID = "buildSystemId"; //$NON-NLS-1$
|
||||
// private final static String ELEMENT_REFERENCES = "references"; //$NON-NLS-1$
|
||||
private static final String PROJECT_EXTENSION_ATTR_POINT = "point"; //$NON-NLS-1$
|
||||
|
@ -98,6 +99,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
|
|||
|
||||
private List<ILanguageSettingsProvider> fLanguageSettingsProviders = new ArrayList<ILanguageSettingsProvider>(0);
|
||||
private LinkedHashMap<String /*provider*/, LanguageSettingsStorage> lspPersistedState = new LinkedHashMap<String, LanguageSettingsStorage>();
|
||||
private String[] defaultLanguageSettingsProvidersIds = null;
|
||||
|
||||
|
||||
private class DeltaSet {
|
||||
|
@ -202,6 +204,11 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
|
|||
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){
|
||||
|
@ -1007,6 +1014,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
|
|||
*
|
||||
* @param providers - list of providers to keep in the specs.
|
||||
*/
|
||||
@Override
|
||||
public void setLanguageSettingProviders(List<ILanguageSettingsProvider> providers) {
|
||||
fLanguageSettingsProviders = new ArrayList<ILanguageSettingsProvider>(0);
|
||||
Set<String> ids = new HashSet<String>();
|
||||
|
@ -1025,10 +1033,21 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
|
|||
fIsModified = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ILanguageSettingsProvider> getLanguageSettingProviders() {
|
||||
return Collections.unmodifiableList(fLanguageSettingsProviders);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultLanguageSettingsProvidersIds(String[] ids) {
|
||||
defaultLanguageSettingsProvidersIds = ids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getDefaultLanguageSettingsProvidersIds() {
|
||||
return defaultLanguageSettingsProvidersIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns delta and updates last persisted state to the new state.
|
||||
* That implies that the delta needs to be used to fire an event of it will
|
||||
|
|
|
@ -172,9 +172,9 @@ public class XmlProjectDescriptionStorage extends AbstractCProjectDescriptionSto
|
|||
}, null, IWorkspace.AVOID_UPDATE, null);
|
||||
// end Bug 249951 & Bug 310007
|
||||
serializingLock.acquire();
|
||||
LanguageSettingsManager.serializeLanguageSettings(fDes);
|
||||
projectModificaitonStamp = serialize(fDes.getProject(), ICProjectDescriptionStorageType.STORAGE_FILE_NAME, fElement);
|
||||
((ContributedEnvironment) CCorePlugin.getDefault().getBuildEnvironmentManager().getContributedEnvironment()).serialize(fDes);
|
||||
LanguageSettingsManager.serializeLanguageSettings(fDes);
|
||||
} finally {
|
||||
serializingLock.release();
|
||||
Job.getJobManager().removeJobChangeListener(notifyJobCanceller);
|
||||
|
|
|
@ -94,6 +94,14 @@ Default constructor (constructor without arguments) of this class must be public
|
|||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="prefer-non-shared" type="boolean" use="default" value="false">
|
||||
<annotation>
|
||||
<documentation>
|
||||
A flag indicating that the provider should be owned by a configuration rather than be global in workspace and shared between projects (when the choice has not been indicated yet by other means). This preference is consulted in order to initially set the "shared" attribute, for example when a user adds a provider from the list of extension providers.
|
||||
The value "true" of this attribute is meaningful only for providers capable of being non-shared, i.e. providers extending ILanguageSettingsEditableProvider.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
|
|
|
@ -4306,14 +4306,14 @@
|
|||
<provider
|
||||
class="org.eclipse.cdt.core.language.settings.providers.LanguageSettingsGenericProvider"
|
||||
id="org.eclipse.cdt.ui.user.LanguageSettingsProvider"
|
||||
name="CDT User Setting Entries">
|
||||
name="CDT User Setting Entries"
|
||||
prefer-non-shared="true">
|
||||
</provider>
|
||||
</extension>
|
||||
<extension point="org.eclipse.cdt.ui.LanguageSettingsProviderAssociation">
|
||||
<id-association
|
||||
id="org.eclipse.cdt.ui.user.LanguageSettingsProvider"
|
||||
icon="icons/obj16/person-me.gif"
|
||||
shared="false"
|
||||
ui-clear-entries="true"
|
||||
ui-edit-entries="true">
|
||||
</id-association>
|
||||
|
|
|
@ -77,13 +77,6 @@
|
|||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="shared" type="boolean">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="ui-edit-entries" type="boolean">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
@ -133,13 +126,6 @@
|
|||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="shared" type="boolean">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="ui-clear-entries" type="boolean">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
|
|
@ -29,7 +29,6 @@ public class LanguageSettingsProviderAssociationManager {
|
|||
private static final String ATTR_CLASS = "class"; //$NON-NLS-1$
|
||||
private static final String ATTR_ICON = "icon"; //$NON-NLS-1$
|
||||
private static final String ATTR_PAGE = "page"; //$NON-NLS-1$
|
||||
private static final String ATTR_SHARED = "shared"; //$NON-NLS-1$
|
||||
private static final String ATTR_UI_CLEAR_ENTRIES = "ui-clear-entries"; //$NON-NLS-1$
|
||||
private static final String ATTR_UI_EDIT_ENTRIES = "ui-edit-entries"; //$NON-NLS-1$
|
||||
|
||||
|
@ -71,7 +70,6 @@ public class LanguageSettingsProviderAssociationManager {
|
|||
|
||||
Map<String, String> properties = new HashMap<String, String>();
|
||||
sensiblePut(properties, ATTR_PAGE, cfgEl.getAttribute(ATTR_PAGE));
|
||||
sensiblePut(properties, ATTR_SHARED, cfgEl.getAttribute(ATTR_SHARED));
|
||||
sensiblePut(properties, ATTR_UI_CLEAR_ENTRIES, cfgEl.getAttribute(ATTR_UI_CLEAR_ENTRIES));
|
||||
sensiblePut(properties, ATTR_UI_EDIT_ENTRIES, cfgEl.getAttribute(ATTR_UI_EDIT_ENTRIES));
|
||||
fAssociationsById.put(id, properties);
|
||||
|
@ -86,7 +84,6 @@ public class LanguageSettingsProviderAssociationManager {
|
|||
|
||||
Map<String, String> properties = new HashMap<String, String>();
|
||||
sensiblePut(properties, ATTR_PAGE, cfgEl.getAttribute(ATTR_PAGE));
|
||||
sensiblePut(properties, ATTR_SHARED, cfgEl.getAttribute(ATTR_SHARED));
|
||||
sensiblePut(properties, ATTR_UI_CLEAR_ENTRIES, cfgEl.getAttribute(ATTR_UI_CLEAR_ENTRIES));
|
||||
sensiblePut(properties, ATTR_UI_EDIT_ENTRIES, cfgEl.getAttribute(ATTR_UI_EDIT_ENTRIES));
|
||||
fAssociationsByClass.put(className, properties);
|
||||
|
@ -304,16 +301,6 @@ public class LanguageSettingsProviderAssociationManager {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns TODO for id or closest superclass.
|
||||
* @param provider TODO
|
||||
* @return TODO
|
||||
*/
|
||||
public static boolean shouldBeShared(ILanguageSettingsProvider provider) {
|
||||
return getBooleanAttribute(provider, ATTR_SHARED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TODO for id or closest superclass.
|
||||
* @param provider TODO
|
||||
|
|
|
@ -315,9 +315,9 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
|
|||
tableProviders.setSelection(pos);
|
||||
|
||||
if (event.getChecked() && LanguageSettingsManager.isWorkspaceProvider(provider)) {
|
||||
if (!LanguageSettingsManager.isPreferShared(provider.getId())) {
|
||||
// Switch to non-shared provider instance
|
||||
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider);
|
||||
if (!LanguageSettingsProviderAssociationManager.shouldBeShared(rawProvider)) {
|
||||
// Switch to local provider instance
|
||||
if (rawProvider instanceof ILanguageSettingsEditableProvider) {
|
||||
ILanguageSettingsEditableProvider newProvider = LanguageSettingsManager.getProviderCopy((ILanguageSettingsEditableProvider) rawProvider, false);
|
||||
if (newProvider != null) {
|
||||
|
|
|
@ -90,7 +90,8 @@
|
|||
class="org.eclipse.cdt.make.internal.core.scannerconfig.GCCBuildCommandParser"
|
||||
id="org.eclipse.cdt.managedbuilder.xlc.core.xlc.build.command.parser"
|
||||
name="%XlcBuildCommandParserName"
|
||||
parameter="xl[cC]">
|
||||
parameter="xl[cC]"
|
||||
prefer-non-shared="true">
|
||||
</provider>
|
||||
</extension>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue