From 79f305532d496f0e69b557bd177d2716aabd73be Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Mon, 19 Dec 2011 15:44:08 +0100 Subject: [PATCH] Bug 367061 - Language mappings as created in a Helios project are ignored when imported in Indigo (backward compatibility issue) --- .../core/language/LanguageMappingStore.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/LanguageMappingStore.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/LanguageMappingStore.java index 09a00f89f14..29f72e6ab35 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/LanguageMappingStore.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/LanguageMappingStore.java @@ -34,6 +34,7 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePreferenceConstants; import org.eclipse.cdt.core.language.ProjectLanguageConfiguration; import org.eclipse.cdt.core.language.WorkspaceLanguageConfiguration; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICStorageElement; import org.eclipse.cdt.internal.core.Util; @@ -71,6 +72,13 @@ public class LanguageMappingStore { ICProjectDescription descriptor = getProjectDescription(project, false); if (descriptor != null) { ICStorageElement rootElement = descriptor.getStorage(LANGUAGE_MAPPING_ID, false); + if (rootElement == null) { + // bug 367061 - backwards compatibility: fallback to default configuration settings + ICConfigurationDescription cfgDesc = descriptor.getDefaultSettingConfiguration(); + if (cfgDesc != null) { + rootElement = cfgDesc.getStorage(LANGUAGE_MAPPING_ID, false); + } + } if (rootElement != null) { ICStorageElement[] mappingElements = rootElement.getChildrenByName(PROJECT_MAPPINGS); if (mappingElements.length > 0) { @@ -143,6 +151,11 @@ public class LanguageMappingStore { public void storeMappings(IProject project, ProjectLanguageConfiguration config) throws CoreException { ICProjectDescription descriptor = getProjectDescription(project, true); + ICConfigurationDescription cfgDesc = descriptor.getDefaultSettingConfiguration(); + // remove old storage location if any + if (cfgDesc != null && cfgDesc.getStorage(LANGUAGE_MAPPING_ID, false) != null) { + cfgDesc.removeStorage(LANGUAGE_MAPPING_ID); + } ICStorageElement rootElement = descriptor.getStorage(LANGUAGE_MAPPING_ID, true); // clear all children and settings rootElement.clear();