1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-06 16:45:25 +02:00

bug 398056: Regression: LanguageSettingsProviders can get enabled unexpectedly on project-import when they should not

This commit is contained in:
Andrew Gvozdev 2013-02-07 17:22:40 -05:00
parent dfdb59e599
commit 6e5916b9ea
9 changed files with 277 additions and 91 deletions

View file

@ -10,8 +10,6 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.core.tests; package org.eclipse.cdt.managedbuilder.core.tests;
import java.io.File;
import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
@ -24,7 +22,6 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener; import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
import org.eclipse.cdt.core.parser.IScannerInfoProvider; import org.eclipse.cdt.core.parser.IScannerInfoProvider;
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsScannerInfoProvider;
import org.eclipse.cdt.managedbuilder.core.BuildException; import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
@ -201,26 +198,6 @@ public class ManagedBuildCoreTests20 extends TestCase {
} }
/**
* Convert path to OS specific representation
*/
private String toOSLocation(String path) {
File file = new File(path);
try {
path = file.getCanonicalPath();
} catch (IOException e) {
}
return path;
}
/**
* Convert path to OS specific representation
*/
private String toOSString(String path) {
return new Path(path).toOSString();
}
/** /**
* The purpose of this test is to exercise the build path info interface. * The purpose of this test is to exercise the build path info interface.
* To get to that point, a new project/config has to be created in the test * To get to that point, a new project/config has to be created in the test
@ -241,38 +218,18 @@ public class ManagedBuildCoreTests20 extends TestCase {
} }
//These are the expected path settings //These are the expected path settings
IPath buildCWD = project.getLocation().append("Sub Config"); final String[] expectedPaths = new String[5];
final String[] expectedPaths; // This first path is a built-in, so it will not be manipulated by build manager
if (new Path("C:\\home\\tester/include").isAbsolute()) { expectedPaths[0] = (new Path("/usr/include")).toOSString();
// Windows expectedPaths[1] = (new Path("/opt/gnome/include")).toOSString();
expectedPaths = new String[] { IPath path = new Path("C:\\home\\tester/include");
toOSLocation("/usr/include"), if(path.isAbsolute()) // for win32 path is treated as absolute
toOSLocation("/opt/gnome/include"), expectedPaths[2] = path.toOSString();
toOSLocation("C:\\home\\tester/include"), else // for Linux path is relative
// relative paths from MBS will make 3 entries expectedPaths[2] = project.getLocation().append("Sub Config").append(path).toOSString();
project.getLocation().append("includes").toOSString(), expectedPaths[3] = project.getLocation().append( "includes" ).toOSString();
buildCWD.append("includes").toOSString(), expectedPaths[4] = (new Path("/usr/gnu/include")).toOSString();
toOSString("includes"),
"/usr/gnu/include", // Not converted to OS string due to being flagged as ICSettingEntry.RESOLVED
};
} else {
// Unix
expectedPaths = new String[] {
toOSLocation("/usr/include"),
toOSLocation("/opt/gnome/include"),
// on unix "C:\\home\\tester/include" is relative path
// looks like nonsense but has to be this way as MBS converts entry to keep "Sub Config/C:\\home\\tester/include" in its storage
project.getLocation().append("Sub Config/C:\\home\\tester/include").toOSString(),
buildCWD.append("Sub Config/C:\\home\\tester/include").toOSString(),
toOSString("Sub Config/C:\\home\\tester/include"),
// relative paths from MBS will make 3 entries
project.getLocation().append("includes").toOSString(),
buildCWD.append("includes").toOSString(),
toOSString("includes"),
"/usr/gnu/include", // Not converted to OS string due to being flagged as ICSettingEntry.RESOLVED
};
}
// Create a new managed project based on the sub project type // Create a new managed project based on the sub project type
IProjectType projType = ManagedBuildManager.getExtensionProjectType("test.sub"); IProjectType projType = ManagedBuildManager.getExtensionProjectType("test.sub");
@ -324,7 +281,6 @@ public class ManagedBuildCoreTests20 extends TestCase {
// Find the first IScannerInfoProvider that supplies build info for the project // Find the first IScannerInfoProvider that supplies build info for the project
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project); IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
assertNotNull(provider); assertNotNull(provider);
assertTrue(provider instanceof LanguageSettingsScannerInfoProvider);
// Now subscribe (note that the method will be called after a change // Now subscribe (note that the method will be called after a change
provider.subscribe(project, new IScannerInfoChangeListener () { provider.subscribe(project, new IScannerInfoChangeListener () {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2011 Andrew Gvozdev and others. * Copyright (c) 2009, 2013 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -23,6 +23,8 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.internal.core.LocalProjectScope; import org.eclipse.cdt.internal.core.LocalProjectScope;
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsExtensionManager; import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsExtensionManager;
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer; import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer;
import org.eclipse.cdt.internal.core.language.settings.providers.ScannerInfoExtensionLanguageSettingsProvider;
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.core.runtime.preferences.InstanceScope;
import org.osgi.service.prefs.BackingStoreException; import org.osgi.service.prefs.BackingStoreException;
@ -42,6 +44,8 @@ public class ScannerDiscoveryLegacySupport {
public static final String USER_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.ui.UserLanguageSettingsProvider"; //$NON-NLS-1$ public static final String USER_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.ui.UserLanguageSettingsProvider"; //$NON-NLS-1$
/** ID of MBS language settings provider (from org.eclipse.cdt.managedbuilder.core) */ /** 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.MBSLanguageSettingsProvider"; //$NON-NLS-1$ public static final String MBS_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider"; //$NON-NLS-1$
/** ID of ScannerInfo language settings provider wrapping ScannerInfoProvider defined by org.eclipse.cdt.core.ScannerInfoProvider extension point */
private static final String SI_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.core.LegacyScannerInfoLanguageSettingsProvider"; //$NON-NLS-1$
private static String DISABLE_LSP_PREFERENCE = "language.settings.providers.disabled"; //$NON-NLS-1$ private static String DISABLE_LSP_PREFERENCE = "language.settings.providers.disabled"; //$NON-NLS-1$
// the default for project needs to be "disabled" - for legacy projects to be open with old SD enabled for MBS provider // the default for project needs to be "disabled" - for legacy projects to be open with old SD enabled for MBS provider
@ -156,15 +160,60 @@ public class ScannerDiscoveryLegacySupport {
} }
/** /**
* Return list containing MBS and User provider. Used to initialize for unaware tool-chains (backward compatibility). * Return list containing User provider and one of wrapper providers to support legacy projects (backward compatibility).
*
* @noreference This is internal helper method to support compatibility with previous versions
* which is not intended to be referenced by clients.
* @since 5.5
*/
public static String[] getDefaultProviderIdsLegacy(ICConfigurationDescription cfgDescription) {
boolean useScannerInfoProviderExtension = new ScannerInfoExtensionLanguageSettingsProvider().getScannerInfoProvider(cfgDescription) != null;
if (useScannerInfoProviderExtension) {
return new String[] {USER_LANGUAGE_SETTINGS_PROVIDER_ID, SI_LANGUAGE_SETTINGS_PROVIDER_ID};
}
if (CProjectDescriptionManager.getInstance().isNewStyleCfg(cfgDescription)) {
return new String[] {USER_LANGUAGE_SETTINGS_PROVIDER_ID, MBS_LANGUAGE_SETTINGS_PROVIDER_ID};
}
return null;
}
/**
* Checks if the provider is applicable for configuration from backward compatibility point of view
*
* @noreference This is internal helper method to support compatibility with previous versions
* which is not intended to be referenced by clients.
* @since 5.5
*/
public static boolean isProviderCompatible(String providerId, ICConfigurationDescription cfgDescription) {
if (cfgDescription != null) {
boolean useScannerInfoProviderExtension = new ScannerInfoExtensionLanguageSettingsProvider().getScannerInfoProvider(cfgDescription) != null;
if (SI_LANGUAGE_SETTINGS_PROVIDER_ID.equals(providerId)) {
return useScannerInfoProviderExtension;
}
if (MBS_LANGUAGE_SETTINGS_PROVIDER_ID.equals(providerId)) {
boolean isNewStyleCfg = CProjectDescriptionManager.getInstance().isNewStyleCfg(cfgDescription);
return !useScannerInfoProviderExtension && isNewStyleCfg;
}
}
return true;
}
/**
* Return list containing User and MBS providers. Used to initialize older MBS tool-chains (backward compatibility).
*
* @noreference This is internal helper method to support compatibility with previous versions
* which is not intended to be referenced by clients.
*/ */
public static List<ILanguageSettingsProvider> getDefaultProvidersLegacy() { public static List<ILanguageSettingsProvider> getDefaultProvidersLegacy() {
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(2); List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(2);
ILanguageSettingsProvider provider = LanguageSettingsExtensionManager.getExtensionProviderCopy((ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID), false); ILanguageSettingsProvider provider = LanguageSettingsExtensionManager.getExtensionProviderCopy((USER_LANGUAGE_SETTINGS_PROVIDER_ID), false);
if (provider != null) { if (provider != null) {
providers.add(provider); providers.add(provider);
} }
providers.add(LanguageSettingsProvidersSerializer.getWorkspaceProvider(ScannerDiscoveryLegacySupport.MBS_LANGUAGE_SETTINGS_PROVIDER_ID)); providers.add(LanguageSettingsProvidersSerializer.getWorkspaceProvider(MBS_LANGUAGE_SETTINGS_PROVIDER_ID));
return providers; return providers;
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2011 Andrew Gvozdev and others. * Copyright (c) 2009, 2013 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -82,7 +82,7 @@ public class LanguageSettingsProvidersSerializer {
public static final String JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_WORKSPACE = "CDT_JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_WORKSPACE"; //$NON-NLS-1$ public static final String JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_WORKSPACE = "CDT_JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_WORKSPACE"; //$NON-NLS-1$
private static final String PREFERENCE_WORSPACE_PROVIDERS_SET = "language.settings.providers.workspace.prefs.toggle"; //$NON-NLS-1$ 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 CPROJECT_STORAGE_MODULE_LANGUAGE_SETTINGS_PROVIDERS = "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 STORAGE_WORKSPACE_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 STORAGE_PROJECT_PATH = ".settings/language.settings.xml"; //$NON-NLS-1$
@ -827,8 +827,13 @@ public class LanguageSettingsProvidersSerializer {
public static void serializeLanguageSettings(ICProjectDescription prjDescription) throws CoreException { public static void serializeLanguageSettings(ICProjectDescription prjDescription) throws CoreException {
IProject project = prjDescription.getProject(); IProject project = prjDescription.getProject();
try { try {
// Using side effect of adding the module to the storage // Add the storage module to .cpoject and persist on disk as a side effect of adding
prjDescription.getStorage(CPROJECT_STORAGE_MODULE, true); prjDescription.getStorage(CPROJECT_STORAGE_MODULE_LANGUAGE_SETTINGS_PROVIDERS, true);
if (!ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityDefined(project)) {
// set the flag if was not previously set by the user - to the default value
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project,
ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(project));
}
} catch (CoreException e) { } catch (CoreException e) {
CCorePlugin.log("Internal error while trying to serialize language settings", e); //$NON-NLS-1$ CCorePlugin.log("Internal error while trying to serialize language settings", e); //$NON-NLS-1$
} }
@ -1125,7 +1130,9 @@ public class LanguageSettingsProvidersSerializer {
public static void loadLanguageSettings(ICProjectDescription prjDescription) { public static void loadLanguageSettings(ICProjectDescription prjDescription) {
IProject project = prjDescription.getProject(); IProject project = prjDescription.getProject();
IFile storeInPrjArea = getStoreInProjectArea(project); IFile storeInPrjArea = getStoreInProjectArea(project);
if (storeInPrjArea.exists()) { boolean isStoreInProjectAreaExist = storeInPrjArea.exists();
boolean enableLSP = isStoreInProjectAreaExist;
if (isStoreInProjectAreaExist) {
Document doc = null; Document doc = null;
try { try {
doc = XmlUtil.loadXml(storeInPrjArea); doc = XmlUtil.loadXml(storeInPrjArea);
@ -1150,19 +1157,18 @@ public class LanguageSettingsProvidersSerializer {
CCorePlugin.log("Can't load preferences from file " + storeInPrjArea.getLocation(), e); //$NON-NLS-1$ CCorePlugin.log("Can't load preferences from file " + storeInPrjArea.getLocation(), e); //$NON-NLS-1$
} }
} else { } else { // Storage in project area does not exist
// Storage in project area does not exist ICStorageElement lspStorageModule = null;
ICStorageElement storageElement = null;
try { try {
storageElement = prjDescription.getStorage(CPROJECT_STORAGE_MODULE, false); lspStorageModule = prjDescription.getStorage(CPROJECT_STORAGE_MODULE_LANGUAGE_SETTINGS_PROVIDERS, false);
} catch (CoreException e) { } catch (CoreException e) {
String msg = "Internal error while trying to load language settings"; //$NON-NLS-1$ String msg = "Internal error while trying to load language settings"; //$NON-NLS-1$
CCorePlugin.log(msg, e); CCorePlugin.log(msg, e);
} }
if (storageElement != null) { // set default providers defined in the tool-chain
// set default providers defined in the tool-chain for (ICConfigurationDescription cfgDescription : prjDescription.getConfigurations()) {
for (ICConfigurationDescription cfgDescription : prjDescription.getConfigurations()) { if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
String[] ids = ((ILanguageSettingsProvidersKeeper) cfgDescription).getDefaultLanguageSettingsProvidersIds(); String[] ids = ((ILanguageSettingsProvidersKeeper) cfgDescription).getDefaultLanguageSettingsProvidersIds();
if (ids != null) { if (ids != null) {
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(ids.length); List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(ids.length);
@ -1176,23 +1182,16 @@ public class LanguageSettingsProvidersSerializer {
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); ((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) {
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(ScannerDiscoveryLegacySupport.getDefaultProvidersLegacy());
}
}
}
if (!ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityDefined(project)) {
// if not yet defined by user - set preference to tell if this is legacy .cproject (i.e. no LSP storageElement)
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, storageElement != null);
} }
enableLSP = lspStorageModule != null;
} }
if (!ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityDefined(project)) {
// set the flag if was not previously set by the user
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, enableLSP);
}
} }
/** /**

View file

@ -0,0 +1,158 @@
/*******************************************************************************
* Copyright (c) 2013, 2013 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.internal.core.language.settings.providers;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
import org.eclipse.cdt.core.AbstractCExtension;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsBaseProvider;
import org.eclipse.cdt.core.parser.IExtendedScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.core.settings.model.util.CExtensionUtil;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
/**
* Wrapper class intended to provide backward compatibility with ScannerInfoProvider defined by org.eclipse.cdt.core.ScannerInfoProvider extension point
*/
public class ScannerInfoExtensionLanguageSettingsProvider extends LanguageSettingsBaseProvider {
@Override
public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
IScannerInfoProvider scannerInfoProvider = getScannerInfoProvider(cfgDescription);
if (scannerInfoProvider != null) {
IScannerInfo si = scannerInfoProvider.getScannerInformation(rc);
if (si != null) {
if (si instanceof IExtendedScannerInfo) {
addLocalIncludePaths(entries, (IExtendedScannerInfo) si);
}
addSystemIncludePaths(entries, si);
addDefinedSymbols(entries, si);
if (si instanceof IExtendedScannerInfo) {
addIncludeFiles(entries, (IExtendedScannerInfo) si);
addMacroFiles(entries, (IExtendedScannerInfo) si);
}
if (!entries.isEmpty()) {
return LanguageSettingsSerializableStorage.getPooledList(entries);
}
}
}
return null;
}
/**
* Return ScannerInfoProvider defined in configuration metadata in .cproject.
*
* @param cfgDescription - configuration description.
* @return an instance of ScannerInfoProvider or {@code null}.
*/
public IScannerInfoProvider getScannerInfoProvider(ICConfigurationDescription cfgDescription) {
if (cfgDescription == null) {
return null;
}
IScannerInfoProvider scannerInfoProvider = null;
ICConfigExtensionReference[] refs = cfgDescription.get(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID);
if (refs != null && refs.length > 0) {
ICConfigExtensionReference ref = refs[0];
try {
AbstractCExtension cExtension = null;
IConfigurationElement el = CExtensionUtil.getFirstConfigurationElement(ref, "cextension", false); //$NON-NLS-1$
cExtension = (AbstractCExtension)el.createExecutableExtension("run"); //$NON-NLS-1$
cExtension.setExtensionReference(ref);
cExtension.setProject(ref.getConfiguration().getProjectDescription().getProject());
if (cExtension instanceof IScannerInfoProvider) {
scannerInfoProvider = (IScannerInfoProvider) cExtension;
}
} catch (CoreException e) {
CCorePlugin.log(e);
}
}
return scannerInfoProvider;
}
/**
* Add local include paths to the list of entries.
*/
private void addLocalIncludePaths(List<ICLanguageSettingEntry> entries, IExtendedScannerInfo esi) {
String[] localIncludePaths = esi.getLocalIncludePath();
if (localIncludePaths != null) {
for (String path : localIncludePaths) {
entries.add(CDataUtil.createCIncludePathEntry(path, ICSettingEntry.LOCAL));
}
}
}
/**
* Add system include paths to the list of entries.
*/
private void addSystemIncludePaths(List<ICLanguageSettingEntry> entries, IScannerInfo si) {
String[] includePaths = si.getIncludePaths();
if (includePaths != null) {
for (String path : includePaths) {
entries.add(CDataUtil.createCIncludePathEntry(path, 0));
}
}
}
/**
* Add defined macros to the list of entries.
*/
private void addDefinedSymbols(List<ICLanguageSettingEntry> entries, IScannerInfo si) {
Map<String, String> definedSymbols = si.getDefinedSymbols();
if (definedSymbols != null) {
for (Entry<String, String> entry : new TreeMap<String, String>(definedSymbols).entrySet()) {
String name = entry.getKey();
String value = entry.getValue();
entries.add(CDataUtil.createCMacroEntry(name, value, 0));
}
}
}
/**
* Add include files to the list of entries.
*/
private void addIncludeFiles(List<ICLanguageSettingEntry> entries, IExtendedScannerInfo esi) {
String[] includeFiles = esi.getIncludeFiles();
if (includeFiles != null) {
for (String path : includeFiles) {
entries.add(CDataUtil.createCIncludeFileEntry(path, 0));
}
}
}
/**
* Add macro files to the list of entries.
*/
private void addMacroFiles(List<ICLanguageSettingEntry> entries, IExtendedScannerInfo esi) {
String[] macroFiles = esi.getMacroFiles();
if (macroFiles != null) {
for (String path : macroFiles) {
entries.add(CDataUtil.createCMacroFileEntry(path, 0));
}
}
}
}

View file

@ -52,6 +52,7 @@ import javax.xml.transform.stream.StreamResult;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; 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.ILanguageSettingsProvidersKeeper;
import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport;
import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICElementDelta; import org.eclipse.cdt.core.model.ICElementDelta;
@ -1141,7 +1142,15 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
monitor = new NullProgressMonitor(); monitor = new NullProgressMonitor();
CConfigurationDataProvider provider = getProvider(des); CConfigurationDataProvider provider = getProvider(des);
return provider.loadConfiguration(des, monitor); CConfigurationData data = provider.loadConfiguration(des, monitor);
if (des instanceof ILanguageSettingsProvidersKeeper && ! des.isPreferenceConfiguration()) {
String[] defaultIds = ((ILanguageSettingsProvidersKeeper) des).getDefaultLanguageSettingsProvidersIds();
if (defaultIds == null) {
((ILanguageSettingsProvidersKeeper) des).setDefaultLanguageSettingsProvidersIds(ScannerDiscoveryLegacySupport.getDefaultProviderIdsLegacy(des));
}
}
return data;
} }
CConfigurationData applyData(CConfigurationDescriptionCache des, ICConfigurationDescription baseDescription, CConfigurationData base, SettingsContext context, IProgressMonitor monitor) throws CoreException { CConfigurationData applyData(CConfigurationDescriptionCache des, ICConfigurationDescription baseDescription, CConfigurationData base, SettingsContext context, IProgressMonitor monitor) throws CoreException {

View file

@ -132,4 +132,5 @@ CProjectStorageType.separatefile.name = Xml Storage (Separate Files)
scannerInfoProvider2.name = Scanner Info Provider scannerInfoProvider2.name = Scanner Info Provider
efsExtensionProvider.name = EFSExtensionProvider efsExtensionProvider.name = EFSExtensionProvider
refreshExclusionFactory.name = Refresh Exclusion Factory refreshExclusionFactory.name = Refresh Exclusion Factory
uncPathConverter.name = UNC Path Converter uncPathConverter.name = UNC Path Converter
ScannerInfoExtensionLanguageSettingsProvider.name=Contributed ScannerInfo Entries

View file

@ -2,7 +2,7 @@
<?eclipse version="3.0"?> <?eclipse version="3.0"?>
<plugin> <plugin>
<!-- =================================================================================== --> <!-- =================================================================================== -->
<!-- Obsolete extension point no longer in use, will be remove. --> <!-- Obsolete extension point no longer in use, will be remove. -->
<!-- =================================================================================== --> <!-- =================================================================================== -->
@ -782,5 +782,13 @@
factoryClass="org.eclipse.cdt.internal.core.resources.ResourceExclusionFactory"> factoryClass="org.eclipse.cdt.internal.core.resources.ResourceExclusionFactory">
</exclusionFactory> </exclusionFactory>
</extension> </extension>
<extension
point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider
class="org.eclipse.cdt.internal.core.language.settings.providers.ScannerInfoExtensionLanguageSettingsProvider"
id="org.eclipse.cdt.core.LegacyScannerInfoLanguageSettingsProvider"
name="%ScannerInfoExtensionLanguageSettingsProvider.name">
</provider>
</extension>
</plugin> </plugin>

View file

@ -926,7 +926,7 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
for (ILanguageSettingsProvider provider : allAvailableProvidersSet) { for (ILanguageSettingsProvider provider : allAvailableProvidersSet) {
String id = provider.getId(); String id = provider.getId();
if (!idsList.contains(id)) { if (!idsList.contains(id) && ScannerDiscoveryLegacySupport.isProviderCompatible(id, cfgDescription)) {
providers.add(provider); providers.add(provider);
idsList.add(id); idsList.add(id);
} }

View file

@ -276,11 +276,17 @@ public class ManageConfigDialog extends Dialog {
for (int i=0; i<cfgds.length; i++ ) { for (int i=0; i<cfgds.length; i++ ) {
TableItem t = new TableItem(table, 0); TableItem t = new TableItem(table, 0);
t.setText(0, cfgds[i].getName()); t.setText(0, cfgds[i].getName());
t.setText(1, cfgds[i].getDescription()); String description = cfgds[i].getDescription();
if (description == null) {
description = ""; //$NON-NLS-1$
}
t.setText(1, description);
t.setText(2, cfgds[i].isActive() ? Messages.ManageConfigDialog_5 : ""); //$NON-NLS-1$ t.setText(2, cfgds[i].isActive() ? Messages.ManageConfigDialog_5 : ""); //$NON-NLS-1$
t.setData(cfgds[i]); t.setData(cfgds[i]);
} }
if (table.getItemCount() > 0) table.select(0); if (table.getItemCount() > 0) {
table.select(0);
}
table.setFocus(); table.setFocus();
updateButtons(); updateButtons();
} }