1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-04 07:35:24 +02:00

Bug 367061 - Language mappings as created in a Helios project are ignored when imported in Indigo (backward compatibility issue)

This commit is contained in:
Anton Leherbauer 2011-12-19 15:44:08 +01:00
parent 11bfe7ab1a
commit 79f305532d

View file

@ -34,6 +34,7 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CCorePreferenceConstants; import org.eclipse.cdt.core.CCorePreferenceConstants;
import org.eclipse.cdt.core.language.ProjectLanguageConfiguration; import org.eclipse.cdt.core.language.ProjectLanguageConfiguration;
import org.eclipse.cdt.core.language.WorkspaceLanguageConfiguration; 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.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICStorageElement; import org.eclipse.cdt.core.settings.model.ICStorageElement;
import org.eclipse.cdt.internal.core.Util; import org.eclipse.cdt.internal.core.Util;
@ -71,6 +72,13 @@ public class LanguageMappingStore {
ICProjectDescription descriptor = getProjectDescription(project, false); ICProjectDescription descriptor = getProjectDescription(project, false);
if (descriptor != null) { if (descriptor != null) {
ICStorageElement rootElement = descriptor.getStorage(LANGUAGE_MAPPING_ID, false); 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) { if (rootElement != null) {
ICStorageElement[] mappingElements = rootElement.getChildrenByName(PROJECT_MAPPINGS); ICStorageElement[] mappingElements = rootElement.getChildrenByName(PROJECT_MAPPINGS);
if (mappingElements.length > 0) { if (mappingElements.length > 0) {
@ -143,6 +151,11 @@ public class LanguageMappingStore {
public void storeMappings(IProject project, ProjectLanguageConfiguration config) throws CoreException { public void storeMappings(IProject project, ProjectLanguageConfiguration config) throws CoreException {
ICProjectDescription descriptor = getProjectDescription(project, true); 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); ICStorageElement rootElement = descriptor.getStorage(LANGUAGE_MAPPING_ID, true);
// clear all children and settings // clear all children and settings
rootElement.clear(); rootElement.clear();