diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/ProjectLanguageConfiguration.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/ProjectLanguageConfiguration.java index d66d7f1dad6..0ab1367e442 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/ProjectLanguageConfiguration.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/ProjectLanguageConfiguration.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. + * Copyright (c) 2007, 2008 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 @@ -37,36 +37,36 @@ public class ProjectLanguageConfiguration { /** * Project-wide content type mappings (Configuration ID -> (Content Type ID -> Language ID)). */ - private Map/*>*/ fConfigurationContentTypeMappings; + private Map> fConfigurationContentTypeMappings; /** * Per-file mappings (Path -> (Configuration ID -> Language ID)). */ - private Map/*>*/ fFileConfigurationMappings; + private Map> fFileConfigurationMappings; /** * Creates a new ProjectLanguageConfiguration with no * language mappings defined. */ public ProjectLanguageConfiguration() { - fConfigurationContentTypeMappings = new TreeMap(); - fFileConfigurationMappings = new TreeMap(); + fConfigurationContentTypeMappings = new TreeMap>(); + fFileConfigurationMappings = new TreeMap>(); } /** * Returns the language id that is mapped to the given content type when - * the given configurationis active. + * the given configuration is active. * If configuration is null, the configuration-agnostic * mapping is returned. - * @return + * @return the language id that is mapped to the given content type. */ public String getLanguageForContentType(ICConfigurationDescription configuration, String contentTypeId) { String configurationId = getId(configuration); - Map contentTypeMappings = (Map) fConfigurationContentTypeMappings.get(configurationId); + Map contentTypeMappings = fConfigurationContentTypeMappings.get(configurationId); if (contentTypeMappings == null) { return null; } - return (String) contentTypeMappings.get(contentTypeId); + return contentTypeMappings.get(contentTypeId); } /** @@ -74,7 +74,7 @@ public class ProjectLanguageConfiguration { * configuration is active. * If configuration is null, the configuration-agnostic * mapping is returned. - * @return + * @return the language id that is mapped to the given file */ public String getLanguageForFile(ICConfigurationDescription configuration, IFile file) { return getLanguageForFile(configuration, file.getProjectRelativePath().toPortableString()); @@ -86,15 +86,15 @@ public class ProjectLanguageConfiguration { * If configuration is null, the configuration-agnostic * mapping is returned. * @param path - * @return + * @return the language id that is mapped to the file located at the given path */ public String getLanguageForFile(ICConfigurationDescription configuration, String path) { - Map configurationMappings = (Map) fFileConfigurationMappings.get(path); + Map configurationMappings = fFileConfigurationMappings.get(path); if (configurationMappings == null) { return null; } String configurationId = getId(configuration); - return (String) configurationMappings.get(configurationId); + return configurationMappings.get(configurationId); } @@ -108,9 +108,9 @@ public class ProjectLanguageConfiguration { */ public void addContentTypeMapping(ICConfigurationDescription configuration, String contentType, String language) { String configurationId = getId(configuration); - Map contentTypeMappings = (Map) fConfigurationContentTypeMappings.get(configurationId); + Map contentTypeMappings = fConfigurationContentTypeMappings.get(configurationId); if (contentTypeMappings == null) { - contentTypeMappings = new TreeMap(); + contentTypeMappings = new TreeMap(); fConfigurationContentTypeMappings.put(configurationId, contentTypeMappings); } contentTypeMappings.put(contentType, language); @@ -124,7 +124,7 @@ public class ProjectLanguageConfiguration { */ public void removeContentTypeMapping(ICConfigurationDescription configuration, String contentType) { String configurationId = getId(configuration); - Map contentTypeMappings = (Map) fConfigurationContentTypeMappings.get(configurationId); + Map contentTypeMappings = fConfigurationContentTypeMappings.get(configurationId); if (contentTypeMappings == null) { return; } @@ -155,9 +155,9 @@ public class ProjectLanguageConfiguration { * @param language */ public void addFileMapping(ICConfigurationDescription configuration, String filePath, String language) { - Map configurationMappings = (Map) fFileConfigurationMappings.get(filePath); + Map configurationMappings = fFileConfigurationMappings.get(filePath); if (configurationMappings == null) { - configurationMappings = new TreeMap(); + configurationMappings = new TreeMap(); fFileConfigurationMappings.put(filePath, configurationMappings); } String configurationId = getId(configuration); @@ -181,7 +181,7 @@ public class ProjectLanguageConfiguration { * @param filePath */ public void removeFileMapping(ICConfigurationDescription configuration, String filePath) { - Map fileMappings = (Map) fFileConfigurationMappings.get(filePath); + Map fileMappings = fFileConfigurationMappings.get(filePath); if (fileMappings == null) { return; } @@ -202,54 +202,57 @@ public class ProjectLanguageConfiguration { /** * Removes all language mappings for the given file. - * @param filePath + * @param file */ public void removeAllFileMappings(IFile file) { removeAllFileMappings(file.getProjectRelativePath().toPortableString()); } /** + * Returns a copy of all the per-configuration content type mappings stored in this configuration. + * * This method is used internally by CDT and should not be used outside of the CDT framework. - * @return + * @return a copy of all the per-configuration content type mappings */ - public Map getContentTypeMappings() { + public Map> getContentTypeMappings() { return copyLanguageMappings(fConfigurationContentTypeMappings, false); } /** * This method is used internally by CDT and should not be used outside of the CDT framework. */ - public void setContentTypeMappings(Map mappings) { + public void setContentTypeMappings(Map> mappings) { fConfigurationContentTypeMappings = copyLanguageMappings(mappings, false); } /** + * Returns a copy of all the per-file content type mappings stored in this configuration. + * * This method is used internally by CDT and should not be used outside of the CDT framework. - * @return + * @return a copy of all the per-file content type mappings */ - public Map getFileMappings() { + public Map> getFileMappings() { return copyLanguageMappings(fFileConfigurationMappings, false); } /** * This method is used internally by CDT and should not be used outside of the CDT framework. * @param file - * @return */ - public void setFileMappings(IFile file, Map mappings) { - fFileConfigurationMappings.put(file.getProjectRelativePath().toPortableString(), new TreeMap(mappings)); + public void setFileMappings(IFile file, Map mappings) { + fFileConfigurationMappings.put(file.getProjectRelativePath().toPortableString(), new TreeMap(mappings)); } - private Map copyLanguageMappings(Map mappings, boolean isReadOnly) { - Map result = new TreeMap(); - Iterator entries = mappings.entrySet().iterator(); + private Map> copyLanguageMappings(Map> mappings, boolean isReadOnly) { + Map> result = new TreeMap>(); + Iterator>> entries = mappings.entrySet().iterator(); while (entries.hasNext()) { - Entry entry = (Entry) entries.next(); - Map map = (Map) entry.getValue(); + Entry> entry = entries.next(); + Map map = entry.getValue(); if (isReadOnly) { map = Collections.unmodifiableMap(map); } else { - map = new TreeMap(map); + map = new TreeMap(map); } result.put(entry.getKey(), map); } @@ -261,10 +264,9 @@ public class ProjectLanguageConfiguration { /** * This method is used internally by CDT and should not be used outside of the CDT framework. - * @param file - * @return + * @param mappings */ - public void setFileMappings(Map mappings) { + public void setFileMappings(Map> mappings) { fFileConfigurationMappings = copyLanguageMappings(mappings, false); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/WorkspaceLanguageConfiguration.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/WorkspaceLanguageConfiguration.java index 7c21925c14b..21101bd0e83 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/WorkspaceLanguageConfiguration.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/WorkspaceLanguageConfiguration.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. + * Copyright (c) 2007, 2008 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 @@ -22,14 +22,14 @@ public class WorkspaceLanguageConfiguration { /** * Workspace-wide content type mappings. */ - private Map fMappings; + private Map fMappings; /** * Creates a new WorkspaceLanguageConfiguration with no * language mappings defined. */ public WorkspaceLanguageConfiguration() { - fMappings = new TreeMap(); + fMappings = new TreeMap(); } /** @@ -53,26 +53,26 @@ public class WorkspaceLanguageConfiguration { * 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 + * @param mappings */ - public void setWorkspaceMappings(Map/**/ mappings) { - fMappings = new TreeMap(mappings); + public void setWorkspaceMappings(Map mappings) { + fMappings = new TreeMap(mappings); } /** * Returns a read-only copy of the workspace-wide language mappings. * @return a read-only copy of the workspace-wide language mappings. */ - public Map getWorkspaceMappings() { + public Map getWorkspaceMappings() { return Collections.unmodifiableMap(fMappings); } /** * Returns the language id that is mapped to the given content type. * @param contentTypeId - * @return + * @return the language id that is mapped to the given content type. */ public String getLanguageForContentType(String contentTypeId) { - return (String) fMappings.get(contentTypeId); + return fMappings.get(contentTypeId); } } 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 07b0cf55e2b..1f099efeaca 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 QNX Software Systems and others. + * Copyright (c) 2005, 2008 QNX Software Systems 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 @@ -22,6 +22,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.Map.Entry; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ILinkage; @@ -62,13 +63,13 @@ public class LanguageManager { private static final String ATTRIBUTE_ID = "id"; //$NON-NLS-1$ private static LanguageManager instance; - private Map fLanguageCache = new HashMap(); + private Map fLanguageCache = new HashMap(); private Map fPDOMLinkageFactoryCache= new HashMap(); - private Map fContentTypeToLanguageCache= new HashMap(); - private Map fLanguageConfigurationCache = new HashMap(); + private Map fContentTypeToLanguageCache= new HashMap(); + private Map fLanguageConfigurationCache = new HashMap(); private boolean fIsFullyCached; - private HashMap fIdToLanguageDescriptorCache;//= new HashMap(); - private HashMap fContentTypeToDescriptorListCache; + private HashMap fIdToLanguageDescriptorCache;//= new HashMap(); + private HashMap> fContentTypeToDescriptorListCache; private ListenerList fLanguageChangeListeners = new ListenerList(ListenerList.IDENTITY); private WorkspaceLanguageConfiguration fWorkspaceMappings; @@ -79,11 +80,11 @@ public class LanguageManager { } public ILanguageDescriptor getLanguageDescriptor(String id) { - Map map = getDescriptorCache(); - return (ILanguageDescriptor)map.get(id); + Map map = getDescriptorCache(); + return map.get(id); } - private HashMap getDescriptorCache(){ + private HashMap getDescriptorCache(){ if(fIdToLanguageDescriptorCache == null){ fIdToLanguageDescriptorCache = createDescriptorCache(); } @@ -91,12 +92,12 @@ public class LanguageManager { } public ILanguageDescriptor[] getLanguageDescriptors(){ - HashMap map = getDescriptorCache(); - return (ILanguageDescriptor[])map.values().toArray(new ILanguageDescriptor[map.size()]); + HashMap map = getDescriptorCache(); + return map.values().toArray(new ILanguageDescriptor[map.size()]); } - private HashMap createDescriptorCache(){ - HashMap map = new HashMap(); + private HashMap createDescriptorCache(){ + HashMap map = new HashMap(); IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID); for (int j = 0; j < configs.length; ++j) { final IConfigurationElement languageElem = configs[j]; @@ -108,23 +109,23 @@ public class LanguageManager { return map; } - private HashMap getContentTypeToDescriptorCache(){ + private HashMap> getContentTypeToDescriptorCache(){ if(fContentTypeToDescriptorListCache == null){ fContentTypeToDescriptorListCache = createContentTypeToDescriptorCache(); } return fContentTypeToDescriptorListCache; } - public Map getContentTypeIdToLanguageDescriptionsMap(){ - HashMap map = (HashMap)getContentTypeToDescriptorCache().clone(); - for(Iterator iter = map.entrySet().iterator(); iter.hasNext();){ - Map.Entry entry = (Map.Entry)iter.next(); - List list = (List)entry.getValue(); + public Map getContentTypeIdToLanguageDescriptionsMap(){ + HashMap map = new HashMap(); + Map> cache = getContentTypeToDescriptorCache(); + + for(Iterator>> iter = cache.entrySet().iterator(); iter.hasNext();){ + Entry> entry = iter.next(); + List list = entry.getValue(); if(list.size() > 0){ - ILanguageDescriptor[] dess = (ILanguageDescriptor[])list.toArray(new ILanguageDescriptor[list.size()]); - entry.setValue(dess); - } else { - iter.remove(); + ILanguageDescriptor[] dess = list.toArray(new ILanguageDescriptor[list.size()]); + map.put(entry.getKey(), dess); } } @@ -132,22 +133,22 @@ public class LanguageManager { } - private HashMap createContentTypeToDescriptorCache(){ - HashMap map = new HashMap(); - Map dc = getDescriptorCache(); + private HashMap> createContentTypeToDescriptorCache(){ + HashMap> map = new HashMap>(); + Map dc = getDescriptorCache(); - List list; + List list; IContentType type; String id; - for(Iterator iter = dc.values().iterator(); iter.hasNext();){ - ILanguageDescriptor des = (ILanguageDescriptor)iter.next(); + for(Iterator iter = dc.values().iterator(); iter.hasNext();){ + ILanguageDescriptor des = iter.next(); IContentType types[] = des.getContentTypes(); for(int i = 0; i < types.length; i++){ type = types[i]; id = type.getId(); - list = (List)map.get(id); + list = map.get(id); if(list == null){ - list = new ArrayList(); + list = new ArrayList(); map.put(id, list); } list.add(des); @@ -157,7 +158,7 @@ public class LanguageManager { } public ILanguage getLanguage(String id) { - ILanguage language = (ILanguage)fLanguageCache.get(id); + ILanguage language = fLanguageCache.get(id); if (language != null) return language; @@ -199,7 +200,7 @@ public class LanguageManager { public ILanguage getLanguageForContentTypeID(String contentTypeID) { cacheAllLanguages(); - ILanguage language = (ILanguage)fContentTypeToLanguageCache.get(contentTypeID); + ILanguage language = fContentTypeToLanguageCache.get(contentTypeID); if (language != null || fContentTypeToLanguageCache.containsKey(contentTypeID)) return language; @@ -226,8 +227,8 @@ public class LanguageManager { * @deprecated use getRegisteredContentTypes() instead. */ @Deprecated - public ArrayList/**/ getAllContentTypes() { - ArrayList/**/ allTypes = new ArrayList(); + public ArrayList/**/ getAllContentTypes() { + ArrayList/**/ allTypes = new ArrayList(); allTypes.add(CCorePlugin.CONTENT_TYPE_ASMSOURCE); allTypes.add(CCorePlugin.CONTENT_TYPE_CHEADER); allTypes.add(CCorePlugin.CONTENT_TYPE_CSOURCE); @@ -255,12 +256,12 @@ public class LanguageManager { * @since 3.1.1 */ public String[] getRegisteredContentTypeIds() { - Set contentTypes= collectContentTypeIds(); - return (String[]) contentTypes.toArray(new String[contentTypes.size()]); + Set contentTypes= collectContentTypeIds(); + return contentTypes.toArray(new String[contentTypes.size()]); } - private Set collectContentTypeIds() { - HashSet/**/ allTypes = new HashSet(); + private Set collectContentTypeIds() { + HashSet/**/ allTypes = new HashSet(); allTypes.add(CCorePlugin.CONTENT_TYPE_ASMSOURCE); allTypes.add(CCorePlugin.CONTENT_TYPE_CHEADER); allTypes.add(CCorePlugin.CONTENT_TYPE_CSOURCE); @@ -335,9 +336,9 @@ public class LanguageManager { public ILanguage[] getRegisteredLanguages() { cacheAllLanguages(); ILanguage[] languages = new ILanguage[fLanguageCache.size()]; - Iterator values = fLanguageCache.values().iterator(); + Iterator values = fLanguageCache.values().iterator(); for (int i = 0; values.hasNext(); i++) { - languages[i] = (ILanguage) values.next(); + languages[i] = values.next(); } return languages; } @@ -371,7 +372,7 @@ public class LanguageManager { /** * Returns the language configuration for the workspace. - * @return + * @return the language configuration for the workspace * @throws CoreException * @since 4.0 */ @@ -414,13 +415,13 @@ public class LanguageManager { /** * Returns the language configuration for the given project. * @param project - * @return + * @return the language configuration for the given project * @throws CoreException * @since 4.0 */ public ProjectLanguageConfiguration getLanguageConfiguration(IProject project) throws CoreException { synchronized (this) { - ProjectLanguageConfiguration mappings = (ProjectLanguageConfiguration) fLanguageConfigurationCache.get(project); + ProjectLanguageConfiguration mappings = fLanguageConfigurationCache.get(project); if (mappings != null) { return mappings; } @@ -443,7 +444,7 @@ public class LanguageManager { */ public void storeLanguageMappingConfiguration(IProject project, IContentType[] affectedContentTypes) throws CoreException { synchronized (this) { - ProjectLanguageConfiguration mappings = (ProjectLanguageConfiguration) fLanguageConfigurationCache.get(project); + ProjectLanguageConfiguration mappings = fLanguageConfigurationCache.get(project); LanguageMappingStore store = new LanguageMappingStore(); store.storeMappings(project, mappings); } @@ -550,7 +551,7 @@ public class LanguageManager { * @param file the file for which the language is requested * @param configuration the active build configuration, or null if build configurations * are not relevant to determining the language. - * @param contentTypeID id of the content type, may be null. + * @param contentTypeId id of the content type, may be null. * @throws CoreException * @since 4.0 */ @@ -612,7 +613,7 @@ public class LanguageManager { public void storeLanguageMappingConfiguration(IFile file) throws CoreException { IProject project = file.getProject(); synchronized (this) { - ProjectLanguageConfiguration mappings = (ProjectLanguageConfiguration) fLanguageConfigurationCache.get(project); + ProjectLanguageConfiguration mappings = fLanguageConfigurationCache.get(project); LanguageMappingStore store = new LanguageMappingStore(); store.storeMappings(project, mappings); } 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 1c4b3487b34..f8f7dbd248b 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 @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. + * Copyright (c) 2007, 2008 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 + * IBM Corporation - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.language; @@ -51,7 +51,7 @@ public class LanguageMappingResolver { */ public static LanguageMapping[] computeLanguage(IProject project, String filePath, ICConfigurationDescription configuration, String contentTypeId, boolean fetchAll) throws CoreException { LanguageManager manager = LanguageManager.getInstance(); - List inheritedLanguages = new LinkedList(); + List inheritedLanguages = new LinkedList(); if (project != null) { ProjectLanguageConfiguration mappings = manager.getLanguageConfiguration(project); @@ -121,12 +121,12 @@ public class LanguageMappingResolver { return createLanguageMappingArray(inheritedLanguages); } - private static LanguageMapping[] createLanguageMappingArray(List inheritedLanguages) { + private static LanguageMapping[] createLanguageMappingArray(List inheritedLanguages) { LanguageMapping[] results = new LanguageMapping[inheritedLanguages.size()]; - Iterator mappings = inheritedLanguages.iterator(); + Iterator mappings = inheritedLanguages.iterator(); int i = 0; while (mappings.hasNext()) { - LanguageMapping mapping = (LanguageMapping) mappings.next(); + LanguageMapping mapping = mappings.next(); results[i] = mapping; i++; } 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 fb3b7f9d19f..1c3d15a6849 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 @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. + * Copyright (c) 2007, 2008 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 + * IBM Corporation - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.language; @@ -86,16 +86,16 @@ public class LanguageMappingStore { return config; } - private Map decodeProjectContentTypeMappings(Element rootElement) { - Map decodedMappings = new TreeMap(); + private Map> decodeProjectContentTypeMappings(Element rootElement) { + Map> decodedMappings = new TreeMap>(); NodeList mappingElements = rootElement.getElementsByTagName(CONTENT_TYPE_MAPPING); for (int j = 0; j < mappingElements.getLength(); j++) { Element mapping = (Element) mappingElements.item(j); String configuration = mapping.getAttribute(ATTRIBUTE_CONFIGURATION); - Map contentTypeMappings = (Map) decodedMappings.get(configuration); + Map contentTypeMappings = decodedMappings.get(configuration); if (contentTypeMappings == null) { - contentTypeMappings = new TreeMap(); + contentTypeMappings = new TreeMap(); decodedMappings.put(configuration, contentTypeMappings); } String contentType = mapping.getAttribute(ATTRIBUTE_CONTENT_TYPE); @@ -109,20 +109,20 @@ public class LanguageMappingStore { return CCorePlugin.getDefault().getCProjectDescription(project, true); } - private Map decodeContentTypeMappings(Element rootElement) throws CoreException { + private Map decodeContentTypeMappings(Element rootElement) throws CoreException { return decodeMappings(rootElement, CONTENT_TYPE_MAPPING, ATTRIBUTE_CONTENT_TYPE, ATTRIBUTE_LANGUAGE); } - private Map decodeFileMappings(Element rootElement) throws CoreException { - Map decodedMappings = new TreeMap(); + private Map> decodeFileMappings(Element rootElement) throws CoreException { + Map> decodedMappings = new TreeMap>(); NodeList mappingElements = rootElement.getElementsByTagName(FILE_MAPPING); for (int j = 0; j < mappingElements.getLength(); j++) { Element mapping = (Element) mappingElements.item(j); String path = mapping.getAttribute(ATTRIBUTE_PATH); - Map configurationMappings = (Map) decodedMappings.get(path); + Map configurationMappings = decodedMappings.get(path); if (configurationMappings == null) { - configurationMappings = new TreeMap(); + configurationMappings = new TreeMap(); decodedMappings.put(path, configurationMappings); } String configuration = mapping.getAttribute(ATTRIBUTE_CONFIGURATION); @@ -132,8 +132,8 @@ public class LanguageMappingStore { return decodedMappings; } - private Map decodeMappings(Element rootElement, String category, String keyName, String valueName) { - Map decodedMappings = new TreeMap(); + private Map decodeMappings(Element rootElement, String category, String keyName, String valueName) { + Map decodedMappings = new TreeMap(); NodeList mappingElements = rootElement.getElementsByTagName(category); for (int j = 0; j < mappingElements.getLength(); j++) { Element mapping = (Element) mappingElements.item(j); @@ -158,18 +158,18 @@ public class LanguageMappingStore { descriptor.saveProjectData(); } - private void addProjectContentTypeMappings(Map contentTypeMappings, Element rootElement) { + private void addProjectContentTypeMappings(Map> contentTypeMappings, Element rootElement) { Document document = rootElement.getOwnerDocument(); - Iterator entries = contentTypeMappings.entrySet().iterator(); + Iterator>> entries = contentTypeMappings.entrySet().iterator(); while (entries.hasNext()) { - Entry entry = (Entry) entries.next(); + Entry> entry = entries.next(); - String configuration = (String) entry.getKey(); - Iterator contentTypeEntries = ((Map) entry.getValue()).entrySet().iterator(); + String configuration = entry.getKey(); + Iterator> contentTypeEntries = entry.getValue().entrySet().iterator(); while (contentTypeEntries.hasNext()) { - Entry configurationEntry = (Entry) contentTypeEntries.next(); - String contentType = (String) configurationEntry.getKey(); - String language = (String) configurationEntry.getValue(); + Entry configurationEntry = contentTypeEntries.next(); + String contentType = configurationEntry.getKey(); + String language = configurationEntry.getValue(); Element mapping = document.createElement(CONTENT_TYPE_MAPPING); mapping.setAttribute(ATTRIBUTE_CONTENT_TYPE, contentType); @@ -246,35 +246,35 @@ public class LanguageMappingStore { } } - private void addMappings(Map mappings, Element rootElement, String category, String keyName, String valueName) { + private void addMappings(Map mappings, Element rootElement, String category, String keyName, String valueName) { Document document = rootElement.getOwnerDocument(); - Iterator entries = mappings.entrySet().iterator(); + Iterator> entries = mappings.entrySet().iterator(); while (entries.hasNext()) { - Entry entry = (Entry) entries.next(); + Entry entry = entries.next(); Element mapping = document.createElement(category); - mapping.setAttribute(keyName, (String) entry.getKey()); - mapping.setAttribute(valueName, (String) entry.getValue()); + mapping.setAttribute(keyName, entry.getKey()); + mapping.setAttribute(valueName, entry.getValue()); rootElement.appendChild(mapping); } } - private void addContentTypeMappings(Map mappings, Element rootElement) { + private void addContentTypeMappings(Map mappings, Element rootElement) { addMappings(mappings, rootElement, CONTENT_TYPE_MAPPING, ATTRIBUTE_CONTENT_TYPE, ATTRIBUTE_LANGUAGE); } - private void addFileMappings(Map mappings, Element rootElement) { + private void addFileMappings(Map> mappings, Element rootElement) { Document document = rootElement.getOwnerDocument(); - Iterator entries = mappings.entrySet().iterator(); + Iterator>> entries = mappings.entrySet().iterator(); while (entries.hasNext()) { - Entry entry = (Entry) entries.next(); + Entry> entry = entries.next(); Element mapping = document.createElement(FILE_MAPPING); - String path = (String) entry.getKey(); - Iterator configurationEntries = ((Map) entry.getValue()).entrySet().iterator(); + String path = entry.getKey(); + Iterator> configurationEntries = entry.getValue().entrySet().iterator(); while (configurationEntries.hasNext()) { - Entry configurationEntry = (Entry) configurationEntries.next(); - String configuration = (String) configurationEntry.getKey(); - String language = (String) configurationEntry.getValue(); + Entry configurationEntry = configurationEntries.next(); + String configuration = configurationEntry.getKey(); + String language = configurationEntry.getValue(); mapping.setAttribute(ATTRIBUTE_PATH, path); mapping.setAttribute(ATTRIBUTE_CONFIGURATION, configuration); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ContentTypeMappingDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ContentTypeMappingDialog.java index 7ca19e07c75..5add1acf6da 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ContentTypeMappingDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ContentTypeMappingDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. + * Copyright (c) 2007, 2008 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 @@ -34,13 +34,13 @@ public abstract class ContentTypeMappingDialog extends Dialog { String fSelectedLanguageID; String fSelectedConfigurationID; String fSelectedConfigurationName; - HashMap fContentTypeNamesToIDsMap; - HashMap fLanguageNamesToIDsMap; + HashMap fContentTypeNamesToIDsMap; + HashMap fLanguageNamesToIDsMap; public ContentTypeMappingDialog(Shell parentShell) { super(parentShell); - fContentTypeNamesToIDsMap = new HashMap(); - fLanguageNamesToIDsMap = new HashMap(); + fContentTypeNamesToIDsMap = new HashMap(); + fLanguageNamesToIDsMap = new HashMap(); } public String getSelectedContentTypeName() { 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 9ceb2d34a12..9935492a676 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. + * Copyright (c) 2007, 2008 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 @@ -71,7 +71,7 @@ public class FileLanguageMappingPropertyPage extends PropertyPage { private Composite fContents; private Table fTable; private ILanguage[] fLanguages; - private Map fLanguageIds; + private Map fLanguageIds; private boolean fHasChanges; public FileLanguageMappingPropertyPage() { @@ -213,7 +213,7 @@ public class FileLanguageMappingPropertyPage extends PropertyPage { ProjectLanguageConfiguration config = LanguageManager.getInstance().getLanguageConfiguration(project); - Set missingLanguages = LanguageVerifier.removeMissingLanguages(config, description, fLanguageIds); + Set missingLanguages = LanguageVerifier.removeMissingLanguages(config, description, fLanguageIds); if (missingLanguages.size() > 0) { MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK); messageBox.setText(PreferencesMessages.LanguageMappings_missingLanguageTitle); @@ -232,7 +232,7 @@ public class FileLanguageMappingPropertyPage extends PropertyPage { String languageId = config.getLanguageForFile(configurations[i], file); if (languageId != null) { - ILanguage language = (ILanguage) fLanguageIds.get(languageId); + ILanguage language = fLanguageIds.get(languageId); String languageName = language.getName(); item.setText(LANGUAGE_COLUMN, languageName); } @@ -322,7 +322,7 @@ public class FileLanguageMappingPropertyPage extends PropertyPage { LanguageManager manager = LanguageManager.getInstance(); ProjectLanguageConfiguration config = manager.getLanguageConfiguration(project); - Map mappings = new TreeMap(); + Map mappings = new TreeMap(); TableItem[] items = fTable.getItems(); for (int i = 0; i < items.length; i++) { TableItem item = items[i]; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageMappingWidget.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageMappingWidget.java index fc678ad1dcc..f62317e3fa0 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageMappingWidget.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageMappingWidget.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. + * Copyright (c) 2007, 2008 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 @@ -36,22 +36,22 @@ public abstract class LanguageMappingWidget { protected boolean fIsReadOnly; protected Table fTable; - protected HashMap fContentTypeNamesToIDsMap; - protected Set fAffectedContentTypes; + protected HashMap fContentTypeNamesToIDsMap; + protected Set fAffectedContentTypes; protected Font fOverriddenFont; protected LanguageMappingWidget fChild; protected IAdaptable fElement; - protected Set fOverriddenContentTypes; + protected Set fOverriddenContentTypes; private boolean fIsChanged; public LanguageMappingWidget() { fOverriddenFont = JFaceResources.getFontRegistry().getItalic(JFaceResources.DIALOG_FONT); - fOverriddenContentTypes = Collections.EMPTY_SET; + fOverriddenContentTypes = Collections.emptySet(); // keep a mapping of all registered content types and their names - fContentTypeNamesToIDsMap = new HashMap(); + fContentTypeNamesToIDsMap = new HashMap(); String[] contentTypesIDs = LanguageManager.getInstance().getRegisteredContentTypeIds(); IContentTypeManager contentTypeManager = Platform.getContentTypeManager(); @@ -66,7 +66,7 @@ public abstract class LanguageMappingWidget { fContentTypeNamesToIDsMap.put(name, contentTypesIDs[i]); } - fAffectedContentTypes = new HashSet(); + fAffectedContentTypes = new HashSet(); } public IAdaptable getElement() { @@ -77,12 +77,12 @@ public abstract class LanguageMappingWidget { fElement = element; } - public void setOverriddenContentTypes(Set contentTypes) { + public void setOverriddenContentTypes(Set contentTypes) { fOverriddenContentTypes = contentTypes; } public IContentType[] getAffectedContentTypes() { - return (IContentType[]) fAffectedContentTypes.toArray(new IContentType[fAffectedContentTypes.size()]); + return fAffectedContentTypes.toArray(new IContentType[fAffectedContentTypes.size()]); } public void setReadOnly(boolean isReadOnly) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageVerifier.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageVerifier.java index 8c4e54a5170..59662f41295 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageVerifier.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageVerifier.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. + * Copyright (c) 2007, 2008 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 @@ -29,17 +29,17 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription; */ public class LanguageVerifier { - public static Map computeAvailableLanguages() { + public static Map computeAvailableLanguages() { ILanguage[] registeredLanguages = LanguageManager.getInstance().getRegisteredLanguages(); - Map languages = new TreeMap(); + Map languages = new TreeMap(); for (int i = 0; i < registeredLanguages.length; i++) { languages.put(registeredLanguages[i].getId(), registeredLanguages[i]); } return languages; } - public static String computeAffectedLanguages(Set missingLanguages) { - Iterator languages = missingLanguages.iterator(); + public static String computeAffectedLanguages(Set missingLanguages) { + Iterator languages = missingLanguages.iterator(); StringBuffer buffer = new StringBuffer(); while (languages.hasNext()) { buffer.append('\n'); @@ -48,20 +48,20 @@ public class LanguageVerifier { return buffer.toString(); } - public static Set removeMissingLanguages(ProjectLanguageConfiguration config, ICProjectDescription description, Map availableLanguages) { - Set missingLanguages = new TreeSet(); + public static Set removeMissingLanguages(ProjectLanguageConfiguration config, ICProjectDescription description, Map availableLanguages) { + Set missingLanguages = new TreeSet(); // Check file mappings - Iterator fileConfigurationMappings = config.getFileMappings().entrySet().iterator(); + Iterator>> fileConfigurationMappings = config.getFileMappings().entrySet().iterator(); while (fileConfigurationMappings.hasNext()) { - Entry entry = (Entry) fileConfigurationMappings.next(); - String path = (String) entry.getKey(); - Map configurationLanguageMappings = (Map) entry.getValue(); - Iterator mappings = configurationLanguageMappings.entrySet().iterator(); + Entry> entry = fileConfigurationMappings.next(); + String path = entry.getKey(); + Map configurationLanguageMappings = entry.getValue(); + Iterator> mappings = configurationLanguageMappings.entrySet().iterator(); while (mappings.hasNext()) { - Entry mapping = (Entry) mappings.next(); - String configurationId = (String) mapping.getKey(); - String languageId = (String) mapping.getValue(); + Entry mapping = mappings.next(); + String configurationId = mapping.getKey(); + String languageId = mapping.getValue(); if (!availableLanguages.containsKey(languageId)) { missingLanguages.add(languageId); ICConfigurationDescription configuration = description.getConfigurationById(configurationId); @@ -71,16 +71,16 @@ public class LanguageVerifier { } // Check content type mappings - Iterator configurationContentTypeMappings = config.getContentTypeMappings().entrySet().iterator(); + Iterator>> configurationContentTypeMappings = config.getContentTypeMappings().entrySet().iterator(); while (configurationContentTypeMappings.hasNext()) { - Entry entry = (Entry) configurationContentTypeMappings.next(); - String configurationId = (String) entry.getKey(); - Map contentTypeLanguageMappings = (Map) entry.getValue(); - Iterator mappings = contentTypeLanguageMappings.entrySet().iterator(); + Entry> entry = configurationContentTypeMappings.next(); + String configurationId = entry.getKey(); + Map contentTypeLanguageMappings = entry.getValue(); + Iterator> mappings = contentTypeLanguageMappings.entrySet().iterator(); while (mappings.hasNext()) { - Entry mapping = (Entry) mappings.next(); - String contentTypeId = (String) mapping.getKey(); - String languageId = (String) mapping.getValue(); + Entry mapping = mappings.next(); + String contentTypeId = mapping.getKey(); + String languageId = mapping.getValue(); if (!availableLanguages.containsKey(languageId)) { missingLanguages.add(languageId); ICConfigurationDescription configuration = description.getConfigurationById(configurationId); @@ -92,15 +92,15 @@ public class LanguageVerifier { return missingLanguages; } - public static Set removeMissingLanguages(WorkspaceLanguageConfiguration config, Map availableLanguages) { - Set missingLanguages = new TreeSet(); + public static Set removeMissingLanguages(WorkspaceLanguageConfiguration config, Map availableLanguages) { + Set missingLanguages = new TreeSet(); // Check content type mappings - Iterator contentTypeMappings = config.getWorkspaceMappings().entrySet().iterator(); + Iterator> contentTypeMappings = config.getWorkspaceMappings().entrySet().iterator(); while (contentTypeMappings.hasNext()) { - Entry entry = (Entry) contentTypeMappings.next(); - String contentTypeId = (String) entry.getKey(); - String languageId = (String) entry.getValue(); + Entry entry = contentTypeMappings.next(); + String contentTypeId = entry.getKey(); + String languageId = entry.getValue(); if (!availableLanguages.containsKey(languageId)) { missingLanguages.add(languageId); config.removeWorkspaceMapping(contentTypeId); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectContentTypeMappingDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectContentTypeMappingDialog.java index 4becba3a8fd..f1031133639 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectContentTypeMappingDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectContentTypeMappingDialog.java @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. + * Copyright (c) 2007, 2008 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 + * IBM Corporation - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.ui.language; @@ -36,7 +36,7 @@ public class ProjectContentTypeMappingDialog extends ContentTypeMappingDialog { private Combo fConfiguration; private ICConfigurationDescription[] fConfigurations; private String[] fContentTypesIDs; - private Set fFilteredContentTypes; + private Set fFilteredContentTypes; public ProjectContentTypeMappingDialog(Shell parentShell, ICConfigurationDescription[] configurations) { super(parentShell); @@ -105,7 +105,7 @@ public class ProjectContentTypeMappingDialog extends ContentTypeMappingDialog { fContentType.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { fSelectedContentTypeName = fContentType.getText(); - fSelectedContentTypeID = (String) fContentTypeNamesToIDsMap.get(fSelectedContentTypeName); + fSelectedContentTypeID = fContentTypeNamesToIDsMap.get(fSelectedContentTypeName); getButton(IDialogConstants.OK_ID).setEnabled(isValidSelection()); } }); @@ -120,7 +120,7 @@ public class ProjectContentTypeMappingDialog extends ContentTypeMappingDialog { fLanguage.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { fSelectedLanguageName = fLanguage.getText(); - fSelectedLanguageID = (String) fLanguageNamesToIDsMap.get(fSelectedLanguageName); + fSelectedLanguageID = fLanguageNamesToIDsMap.get(fSelectedLanguageName); getButton(IDialogConstants.OK_ID).setEnabled(isValidSelection()); } }); @@ -150,7 +150,7 @@ public class ProjectContentTypeMappingDialog extends ContentTypeMappingDialog { return fContentType.getSelectionIndex() != -1 && fLanguage.getSelectionIndex() != -1 && fConfiguration.getSelectionIndex() != -1; } - public void setContentTypeFilter(Set contentTypeFilter) { + public void setContentTypeFilter(Set contentTypeFilter) { fFilteredContentTypes = contentTypeFilter; } 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 1d4a05314d3..63e67c4b2b5 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. + * Copyright (c) 2007, 2008 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 @@ -32,6 +32,7 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.language.ProjectLanguageConfiguration; import org.eclipse.cdt.core.language.WorkspaceLanguageConfiguration; import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.model.ILanguage; import org.eclipse.cdt.core.model.ILanguageMappingChangeEvent; import org.eclipse.cdt.core.model.ILanguageMappingChangeListener; import org.eclipse.cdt.core.model.LanguageManager; @@ -117,8 +118,8 @@ public class ProjectLanguageMappingPropertyPage extends PropertyPage { fMappings = manager.getLanguageConfiguration(project); ICProjectDescription description = CoreModel.getDefault().getProjectDescription(project); - Map availableLanguages = LanguageVerifier.computeAvailableLanguages(); - Set missingLanguages = LanguageVerifier.removeMissingLanguages(fMappings, description, availableLanguages); + Map availableLanguages = LanguageVerifier.computeAvailableLanguages(); + Set missingLanguages = LanguageVerifier.removeMissingLanguages(fMappings, description, availableLanguages); if (missingLanguages.size() > 0) { MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK); messageBox.setText(PreferencesMessages.LanguageMappings_missingLanguageTitle); @@ -138,8 +139,8 @@ public class ProjectLanguageMappingPropertyPage extends PropertyPage { LanguageManager manager = LanguageManager.getInstance(); WorkspaceLanguageConfiguration workspaceMappings = manager.getWorkspaceLanguageConfiguration(); - Map availableLanguages = LanguageVerifier.computeAvailableLanguages(); - Set missingLanguages = LanguageVerifier.removeMissingLanguages(workspaceMappings, availableLanguages); + Map availableLanguages = LanguageVerifier.computeAvailableLanguages(); + Set missingLanguages = LanguageVerifier.removeMissingLanguages(workspaceMappings, availableLanguages); if (missingLanguages.size() > 0) { MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK); messageBox.setText(PreferencesMessages.LanguageMappings_missingLanguageTitle); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingWidget.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingWidget.java index e9de8b3e10d..193278e4087 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingWidget.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingWidget.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. + * Copyright (c) 2007, 2008 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 @@ -57,13 +57,13 @@ public class ProjectLanguageMappingWidget extends LanguageMappingWidget { private static final int LANGUAGE_COLUMN = 2; - private Map fConfigurationContentTypeMappings; + private Map> fConfigurationContentTypeMappings; - public void setMappings(Map contentTypeMappings) { + public void setMappings(Map> contentTypeMappings) { fConfigurationContentTypeMappings = contentTypeMappings; } - public Map getContentTypeMappings() { + public Map> getContentTypeMappings() { return fConfigurationContentTypeMappings; } @@ -129,9 +129,9 @@ public class ProjectLanguageMappingWidget extends LanguageMappingWidget { if (configuration == null) { configuration = ALL_CONFIGURATIONS; } - Map contentTypeMappings = (Map) fConfigurationContentTypeMappings.get(configuration); + Map contentTypeMappings = fConfigurationContentTypeMappings.get(configuration); if (contentTypeMappings == null) { - contentTypeMappings = new TreeMap(); + contentTypeMappings = new TreeMap(); fConfigurationContentTypeMappings.put(configuration, contentTypeMappings); } contentTypeMappings.put(contentType, language); @@ -163,7 +163,7 @@ public class ProjectLanguageMappingWidget extends LanguageMappingWidget { configurationId = data.configuration.getId(); } - Map contentTypeMappings = (Map) fConfigurationContentTypeMappings.get(configurationId); + Map contentTypeMappings = fConfigurationContentTypeMappings.get(configurationId); if (contentTypeMappings != null) { contentTypeMappings.remove(contentType); } @@ -184,16 +184,16 @@ public class ProjectLanguageMappingWidget extends LanguageMappingWidget { return fContents; } - private Set createContentTypeFilter(Map mappings) { - Set filter = new HashSet(); - Iterator configurationContentTypeMappings = mappings.entrySet().iterator(); + private Set createContentTypeFilter(Map> mappings) { + Set filter = new HashSet(); + Iterator>> configurationContentTypeMappings = mappings.entrySet().iterator(); while (configurationContentTypeMappings.hasNext()) { - Entry entry = (Entry) configurationContentTypeMappings.next(); - String configuration = (String) entry.getKey(); - Iterator contentTypeMappings = ((Map) entry.getValue()).entrySet().iterator(); + Entry> entry = configurationContentTypeMappings.next(); + String configuration = entry.getKey(); + Iterator> contentTypeMappings = entry.getValue().entrySet().iterator(); while (contentTypeMappings.hasNext()) { - Entry contentTypeEntry = (Entry) contentTypeMappings.next(); - String contentType = (String) contentTypeEntry.getKey(); + Entry contentTypeEntry = contentTypeMappings.next(); + String contentType = contentTypeEntry.getKey(); filter.add(createFilterKey(configuration, contentType)); } } @@ -207,7 +207,7 @@ public class ProjectLanguageMappingWidget extends LanguageMappingWidget { } fTable.removeAll(); - Iterator mappings = fConfigurationContentTypeMappings.entrySet().iterator(); + Iterator>> mappings = fConfigurationContentTypeMappings.entrySet().iterator(); IContentTypeManager contentTypeManager = Platform.getContentTypeManager(); @@ -215,16 +215,16 @@ public class ProjectLanguageMappingWidget extends LanguageMappingWidget { ICProjectDescription description = CoreModel.getDefault().getProjectDescription(project, false); while (mappings.hasNext()) { - Entry configurationEntry = (Entry) mappings.next(); - String configurationId = (String) configurationEntry.getKey(); - Iterator contentTypeMappings = ((Map) configurationEntry.getValue()).entrySet().iterator(); + Entry> configurationEntry = mappings.next(); + String configurationId = configurationEntry.getKey(); + Iterator> contentTypeMappings = configurationEntry.getValue().entrySet().iterator(); while (contentTypeMappings.hasNext()) { - Entry entry = (Entry) contentTypeMappings.next(); + Entry entry = contentTypeMappings.next(); TableItem item = new TableItem(fTable, SWT.NONE); - String contentType = (String) entry.getKey(); + String contentType = entry.getKey(); String contentTypeName = contentTypeManager.getContentType(contentType).getName(); - String languageId = (String) entry.getValue(); + String languageId = entry.getValue(); String languageName = LanguageManager.getInstance().getLanguage(languageId).getName(); ICConfigurationDescription configuration = description.getConfigurationById(configurationId); @@ -248,16 +248,16 @@ public class ProjectLanguageMappingWidget extends LanguageMappingWidget { } if (fChild != null) { - Set overrides = new HashSet(createWorkspaceContentTypeFilter(fConfigurationContentTypeMappings)); + Set overrides = new HashSet(createWorkspaceContentTypeFilter(fConfigurationContentTypeMappings)); fChild.setOverriddenContentTypes(overrides); fChild.refreshMappings(); } } - private Set createWorkspaceContentTypeFilter(Map configurationContentTypeMappings) { - Map contentTypeMappings = (Map) configurationContentTypeMappings.get(ALL_CONFIGURATIONS); + private Set createWorkspaceContentTypeFilter(Map> configurationContentTypeMappings) { + Map contentTypeMappings = configurationContentTypeMappings.get(ALL_CONFIGURATIONS); if (contentTypeMappings == null) { - return Collections.EMPTY_SET; + return Collections.emptySet(); } return contentTypeMappings.keySet(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceContentTypeMappingDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceContentTypeMappingDialog.java index 14f2d0194fc..bff6cc18b52 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceContentTypeMappingDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceContentTypeMappingDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. + * Copyright (c) 2007, 2008 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 @@ -32,11 +32,11 @@ import org.eclipse.cdt.core.model.LanguageManager; import org.eclipse.cdt.internal.ui.preferences.PreferencesMessages; public class WorkspaceContentTypeMappingDialog extends ContentTypeMappingDialog { - private Set fFilteredContentTypes; + private Set fFilteredContentTypes; public WorkspaceContentTypeMappingDialog(Shell parentShell) { super(parentShell); - fFilteredContentTypes = Collections.EMPTY_SET; + fFilteredContentTypes = Collections.emptySet(); } @Override @@ -53,7 +53,7 @@ public class WorkspaceContentTypeMappingDialog extends ContentTypeMappingDialog fContentType.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { fSelectedContentTypeName = fContentType.getText(); - fSelectedContentTypeID = (String) fContentTypeNamesToIDsMap.get(fSelectedContentTypeName); + fSelectedContentTypeID = fContentTypeNamesToIDsMap.get(fSelectedContentTypeName); getButton(IDialogConstants.OK_ID).setEnabled(isValidSelection()); } }); @@ -67,7 +67,7 @@ public class WorkspaceContentTypeMappingDialog extends ContentTypeMappingDialog fLanguage.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { fSelectedLanguageName = fLanguage.getText(); - fSelectedLanguageID = (String) fLanguageNamesToIDsMap.get(fSelectedLanguageName); + fSelectedLanguageID = fLanguageNamesToIDsMap.get(fSelectedLanguageName); getButton(IDialogConstants.OK_ID).setEnabled(isValidSelection()); } }); @@ -99,7 +99,7 @@ public class WorkspaceContentTypeMappingDialog extends ContentTypeMappingDialog } } - public void setContentTypeFilter(Set contentTypes) { + public void setContentTypeFilter(Set contentTypes) { fFilteredContentTypes = contentTypes; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingPreferencePage.java index d6bf5f86579..6aa4146e0b1 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingPreferencePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. + * Copyright (c) 2007, 2008 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 @@ -25,6 +25,7 @@ import org.eclipse.ui.IWorkbenchPreferencePage; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.language.WorkspaceLanguageConfiguration; +import org.eclipse.cdt.core.model.ILanguage; import org.eclipse.cdt.core.model.LanguageManager; import org.eclipse.cdt.internal.ui.preferences.PreferencesMessages; @@ -52,8 +53,8 @@ public class WorkspaceLanguageMappingPreferencePage extends PreferencePage imple private void fetchMappings() throws CoreException { fMappings = LanguageManager.getInstance().getWorkspaceLanguageConfiguration(); - Map availableLanguages = LanguageVerifier.computeAvailableLanguages(); - Set missingLanguages = LanguageVerifier.removeMissingLanguages(fMappings, availableLanguages); + Map availableLanguages = LanguageVerifier.computeAvailableLanguages(); + Set missingLanguages = LanguageVerifier.removeMissingLanguages(fMappings, availableLanguages); if (missingLanguages.size() > 0) { MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK); messageBox.setText(PreferencesMessages.LanguageMappings_missingLanguageTitle); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingWidget.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingWidget.java index 1257327097f..05b069ae47c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingWidget.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingWidget.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. + * Copyright (c) 2007, 2008 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 @@ -42,11 +42,11 @@ import org.eclipse.cdt.internal.ui.preferences.PreferencesMessages; import org.eclipse.cdt.internal.ui.util.Messages; public class WorkspaceLanguageMappingWidget extends LanguageMappingWidget { - private Map fContentTypeMappings; + private Map fContentTypeMappings; public WorkspaceLanguageMappingWidget() { super(); - fContentTypeMappings = new TreeMap(); + fContentTypeMappings = new TreeMap(); } @Override @@ -119,7 +119,7 @@ public class WorkspaceLanguageMappingWidget extends LanguageMappingWidget { TableItem[] selection = fTable.getSelection(); for (int i = 0; i < selection.length; i++) { - String contentType = (String) fContentTypeNamesToIDsMap.get(selection[i].getText(0)); + String contentType = fContentTypeNamesToIDsMap.get(selection[i].getText(0)); fContentTypeMappings.remove(contentType); @@ -147,18 +147,18 @@ public class WorkspaceLanguageMappingWidget extends LanguageMappingWidget { } fTable.removeAll(); - Iterator mappings = fContentTypeMappings.entrySet().iterator(); + Iterator> mappings = fContentTypeMappings.entrySet().iterator(); IContentTypeManager contentTypeManager = Platform.getContentTypeManager(); while (mappings.hasNext()) { - Entry entry = (Entry) mappings.next(); + Entry entry = mappings.next(); TableItem item = new TableItem(fTable, SWT.NONE); - String contentType = (String) entry.getKey(); + String contentType = entry.getKey(); String contentTypeName = contentTypeManager.getContentType(contentType).getName(); - String languageName = LanguageManager.getInstance().getLanguage((String) entry.getValue()).getName(); + String languageName = LanguageManager.getInstance().getLanguage(entry.getValue()).getName(); if (fOverriddenContentTypes.contains(contentType)) { item.setText(0, Messages.format(PreferencesMessages.ProjectLanguagesPropertyPage_overriddenContentType, contentTypeName)); @@ -170,18 +170,18 @@ public class WorkspaceLanguageMappingWidget extends LanguageMappingWidget { } if (fChild != null) { - Set overrides = new HashSet(fContentTypeMappings.keySet()); + Set overrides = new HashSet(fContentTypeMappings.keySet()); overrides.addAll(fOverriddenContentTypes); fChild.setOverriddenContentTypes(overrides); fChild.refreshMappings(); } } - public void setMappings(Map mappings) { - fContentTypeMappings = new TreeMap(mappings); + public void setMappings(Map mappings) { + fContentTypeMappings = new TreeMap(mappings); } - public Map getContentTypeMappings() { + public Map getContentTypeMappings() { return Collections.unmodifiableMap(fContentTypeMappings); } }