diff options
Diffstat (limited to 'core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/LanguageMappingResolver.java')
-rw-r--r-- | core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/LanguageMappingResolver.java | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/LanguageMappingResolver.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/LanguageMappingResolver.java index a2a97bcffec..7f6383920c3 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/LanguageMappingResolver.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/LanguageMappingResolver.java @@ -35,15 +35,15 @@ public class LanguageMappingResolver { public static final int WORKSPACE_MAPPING = 1; public static final int PROJECT_MAPPING = 2; public static final int FILE_MAPPING = 3; - + /** * Returns the effective language for the file specified by the given path. * If <code>fetchAll</code> is <code>true</code> all inherited language * mappings will be returned in order of precedence. Otherwise, only the * effective language will be returned. - * + * * This method will always return at least one mapping. - * + * * @param project the project that contains the given file * @param filePath the path to the file * @param contentTypeId the content type of the file (optional) @@ -52,17 +52,18 @@ public class LanguageMappingResolver { * @return the effective language for the file specified by the given path. * @throws CoreException */ - public static LanguageMapping[] computeLanguage(IProject project, String filePath, ICConfigurationDescription configuration, String contentTypeId, boolean fetchAll) throws CoreException { - LanguageManager manager = LanguageManager.getInstance(); + public static LanguageMapping[] computeLanguage(IProject project, String filePath, + ICConfigurationDescription configuration, String contentTypeId, boolean fetchAll) throws CoreException { + LanguageManager manager = LanguageManager.getInstance(); List<LanguageMapping> inheritedLanguages = new LinkedList<LanguageMapping>(); - + if (project != null) { ProjectLanguageConfiguration mappings = manager.getLanguageConfiguration(project); - + if (mappings != null) { // File-level mappings if (filePath != null) { - + String id = mappings.getLanguageForFile(configuration, filePath); if (id != null) { inheritedLanguages.add(new LanguageMapping(manager.getLanguage(id), FILE_MAPPING)); @@ -70,7 +71,7 @@ public class LanguageMappingResolver { return createLanguageMappingArray(inheritedLanguages); } } - + // Check for a file mapping that's global across all configurations in // the project. if (configuration != null) { @@ -81,10 +82,10 @@ public class LanguageMappingResolver { return createLanguageMappingArray(inheritedLanguages); } } - + } } - + // Project-level mappings String id = mappings.getLanguageForContentType(configuration, contentTypeId); if (id != null) { @@ -93,7 +94,7 @@ public class LanguageMappingResolver { return createLanguageMappingArray(inheritedLanguages); } } - + // Check for a content type mapping that's global across all configurations in // the project. if (configuration != null) { @@ -107,7 +108,7 @@ public class LanguageMappingResolver { } } } - + // Workspace mappings WorkspaceLanguageConfiguration workspaceMappings = manager.getWorkspaceLanguageConfiguration(); String id = workspaceMappings.getLanguageForContentType(contentTypeId); @@ -117,7 +118,7 @@ public class LanguageMappingResolver { return createLanguageMappingArray(inheritedLanguages); } } - + // Platform mappings IContentType contentType = Platform.getContentTypeManager().getContentType(contentTypeId); inheritedLanguages.add(new LanguageMapping(manager.getLanguage(contentType), DEFAULT_MAPPING)); |