diff --git a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF index 45747394448..4b16b1ed430 100644 --- a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF @@ -24,6 +24,7 @@ Export-Package: org.eclipse.cdt.core, org.eclipse.cdt.core.index, org.eclipse.cdt.core.index.export, org.eclipse.cdt.core.index.provider, + org.eclipse.cdt.core.language, org.eclipse.cdt.core.model, org.eclipse.cdt.core.model.util, org.eclipse.cdt.core.parser, diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/LanguageMappingConfiguration.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/LanguageMappingConfiguration.java new file mode 100644 index 00000000000..55fdf694e12 --- /dev/null +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/LanguageMappingConfiguration.java @@ -0,0 +1,78 @@ +/******************************************************************************* + * Copyright (c) 2007 IBM Corporation 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: + * IBM Corporation - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.language; + +import java.util.Collections; +import java.util.Map; +import java.util.TreeMap; + +/** + * Provides programmatic access to language mappings for a project. + * + *

+ * EXPERIMENTAL. This class or interface has been added as + * part of a work in progress. There is no guarantee that this API will work or + * that it will remain the same. Please do not use this API without consulting + * with the CDT team. + *

+ * + * @since 4.0 + */ +public class LanguageMappingConfiguration { + + /** + * Project-wide mappings. + */ + private Map fProjectMappings; + + /** + * Creates a new LanguageMappingConfiguration with no + * mappings defined. + */ + public LanguageMappingConfiguration() { + fProjectMappings = new TreeMap(); + } + + /** + * Returns a read-only copy of the project-wide language mappings. + * @return a read-only copy of the project-wide language mappings. + */ + public Map getProjectMappings() { + return Collections.unmodifiableMap(fProjectMappings); + } + + /** + * Replaces the existing language mappings with the given + * mappings. The given mappings should be between content type ids + * (String) and language ids (String) + * @param projectMappings + */ + public void setProjectMappings(Map/**/ projectMappings) { + fProjectMappings = new TreeMap(projectMappings); + } + + /** + * Maps a content type id to a language id. + * @param contentType + * @param language + */ + public void addProjectMapping(String contentType, String language) { + fProjectMappings.put(contentType, language); + } + + /** + * Removes the given content type mapping (if it exists). + * @param contentType + */ + public void removeProjectMapping(String contentType) { + fProjectMappings.remove(contentType); + } +} diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/LanguageManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/LanguageManager.java index ac0d2f3e150..633ee9245a8 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/LanguageManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/LanguageManager.java @@ -22,8 +22,8 @@ import java.util.Set; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ILinkage; +import org.eclipse.cdt.core.language.LanguageMappingConfiguration; import org.eclipse.cdt.internal.core.CContentTypes; -import org.eclipse.cdt.internal.core.language.LanguageMappingConfiguration; import org.eclipse.cdt.internal.core.language.LanguageMappingStore; import org.eclipse.cdt.internal.core.model.LanguageDescriptor; import org.eclipse.cdt.internal.core.model.TranslationUnit; @@ -385,7 +385,7 @@ public class LanguageManager { */ public ILanguage getLanguageForFile(String fullPathToFile, IProject project) throws CoreException { if (project == null) - throw new IllegalArgumentException("project must not be null in call to LanguageManager.getLanguageForFile(String, IProject)"); + throw new IllegalArgumentException("project must not be null in call to LanguageManager.getLanguageForFile(String, IProject)"); //$NON-NLS-1$ IContentType contentType = CContentTypes.getContentType(project, fullPathToFile); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/LanguageMappingConfiguration.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/LanguageMappingConfiguration.java deleted file mode 100644 index 70a5349cb73..00000000000 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/LanguageMappingConfiguration.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation 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: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.internal.core.language; - -import java.util.Collections; -import java.util.Map; -import java.util.TreeMap; - -public class LanguageMappingConfiguration { - - private Map fProjectMappings; - - public LanguageMappingConfiguration() { - fProjectMappings = new TreeMap(); - } - - public Map getProjectMappings() { - return Collections.unmodifiableMap(fProjectMappings); - } - - public void setProjectMappings(Map projectMappings) { - fProjectMappings = projectMappings; - } - - public void addProjectMapping(String contentType, String language) { - fProjectMappings.put(contentType, language); - } - - public void removeProjectMapping(String contentType) { - fProjectMappings.remove(contentType); - } - -} 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 9c4c3f0d35e..6ac7152bfdd 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 @@ -17,6 +17,7 @@ import java.util.Map.Entry; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.ICDescriptor; +import org.eclipse.cdt.core.language.LanguageMappingConfiguration; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.w3c.dom.Document; @@ -25,15 +26,15 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class LanguageMappingStore { - private static final String LANGUAGE_MAPPING_ID = "org.eclipse.cdt.core.language.mapping"; + private static final String LANGUAGE_MAPPING_ID = "org.eclipse.cdt.core.language.mapping"; //$NON-NLS-1$ - private static final String PROJECT_MAPPINGS = "project-mappings"; + private static final String PROJECT_MAPPINGS = "project-mappings"; //$NON-NLS-1$ - private static final String PROJECT_MAPPING = "project-mapping"; + private static final String PROJECT_MAPPING = "project-mapping"; //$NON-NLS-1$ - private static final String ATTRIBUTE_CONTENT_TYPE = "content-type"; + private static final String ATTRIBUTE_CONTENT_TYPE = "content-type"; //$NON-NLS-1$ - private static final String ATTRIBUTE_LANGUAGE = "language"; + private static final String ATTRIBUTE_LANGUAGE = "language"; //$NON-NLS-1$ private IProject fProject; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingPropertyPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingPropertyPage.java index f94a5a3504a..4ea1ed6aea5 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingPropertyPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingPropertyPage.java @@ -36,9 +36,9 @@ import org.eclipse.swt.widgets.TableItem; import org.eclipse.ui.dialogs.PropertyPage; import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.language.LanguageMappingConfiguration; import org.eclipse.cdt.core.model.LanguageManager; -import org.eclipse.cdt.internal.core.language.LanguageMappingConfiguration; import org.eclipse.cdt.internal.ui.preferences.PreferencesMessages;