From 5cc43360724772fefa127a28023b67d4f8133f1f Mon Sep 17 00:00:00 2001 From: Ivan Furnadjiev Date: Wed, 19 Aug 2015 11:21:15 +0300 Subject: [PATCH] Bug 475342: Fix CoreException of file language mappings reset to inherit There is an assumption in FileLanguageMappingPropertyPage#computeInheritedMapping that there is only one overridden file mapping. If both project and workspace file mappings have been overridden, a CoreException is thrown when they both are reset to inherit together. Change-Id: I5c845831ac446eaf65c782b4428b3b72a274fb23 Signed-off-by: Ivan Furnadjiev --- .../ui/language/FileLanguageMappingPropertyPage.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/FileLanguageMappingPropertyPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/FileLanguageMappingPropertyPage.java index 7517051fd8a..37c12ff1ebf 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/FileLanguageMappingPropertyPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/FileLanguageMappingPropertyPage.java @@ -387,15 +387,16 @@ public class FileLanguageMappingPropertyPage extends PropertyPage { private LanguageMapping computeInheritedMapping(IProject project, IFile file, ICConfigurationDescription configuration) throws CoreException { LanguageMapping mappings[] = LanguageMappingResolver.computeLanguage(project, file.getProjectRelativePath().toPortableString(), configuration, fContentType.getId(), true); - LanguageMapping inheritedMapping = mappings[0]; // Skip over the file mapping because we want to know what mapping the file // mapping overrides. - if (inheritedMapping.inheritedFrom == LanguageMappingResolver.FILE_MAPPING ) { - inheritedMapping = mappings[1]; + for (int i = 0; i < mappings.length; i++) { + if (mappings[i].inheritedFrom != LanguageMappingResolver.FILE_MAPPING) { + return mappings[i]; + } } - return inheritedMapping; + return null; } private String[][] getLanguages(IProject project, IFile file, ICConfigurationDescription configuration) throws CoreException {