1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 18:26:01 +02:00

Fix for bug 226302 - addressed compiler warnings in language mapping-related classes

This commit is contained in:
Jason Montojo 2008-04-14 17:32:41 +00:00
parent 0540c57e38
commit 28b527741f
15 changed files with 245 additions and 240 deletions

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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)). * Project-wide content type mappings (Configuration ID -> (Content Type ID -> Language ID)).
*/ */
private Map/*<String,Map<String,String>>*/ fConfigurationContentTypeMappings; private Map<String,Map<String,String>> fConfigurationContentTypeMappings;
/** /**
* Per-file mappings (Path -> (Configuration ID -> Language ID)). * Per-file mappings (Path -> (Configuration ID -> Language ID)).
*/ */
private Map/*<String,Map<String,String>>*/ fFileConfigurationMappings; private Map<String,Map<String,String>> fFileConfigurationMappings;
/** /**
* Creates a new <code>ProjectLanguageConfiguration</code> with no * Creates a new <code>ProjectLanguageConfiguration</code> with no
* language mappings defined. * language mappings defined.
*/ */
public ProjectLanguageConfiguration() { public ProjectLanguageConfiguration() {
fConfigurationContentTypeMappings = new TreeMap(); fConfigurationContentTypeMappings = new TreeMap<String, Map<String, String>>();
fFileConfigurationMappings = new TreeMap(); fFileConfigurationMappings = new TreeMap<String, Map<String, String>>();
} }
/** /**
* Returns the language id that is mapped to the given content type when * Returns the language id that is mapped to the given content type when
* the given configurationis active. * the given configuration is active.
* If <code>configuration</code> is <code>null</code>, the configuration-agnostic * If <code>configuration</code> is <code>null</code>, the configuration-agnostic
* mapping is returned. * mapping is returned.
* @return * @return the language id that is mapped to the given content type.
*/ */
public String getLanguageForContentType(ICConfigurationDescription configuration, String contentTypeId) { public String getLanguageForContentType(ICConfigurationDescription configuration, String contentTypeId) {
String configurationId = getId(configuration); String configurationId = getId(configuration);
Map contentTypeMappings = (Map) fConfigurationContentTypeMappings.get(configurationId); Map<String, String> contentTypeMappings = fConfigurationContentTypeMappings.get(configurationId);
if (contentTypeMappings == null) { if (contentTypeMappings == null) {
return null; return null;
} }
return (String) contentTypeMappings.get(contentTypeId); return contentTypeMappings.get(contentTypeId);
} }
/** /**
@ -74,7 +74,7 @@ public class ProjectLanguageConfiguration {
* configuration is active. * configuration is active.
* If <code>configuration</code> is <code>null</code>, the configuration-agnostic * If <code>configuration</code> is <code>null</code>, the configuration-agnostic
* mapping is returned. * mapping is returned.
* @return * @return the language id that is mapped to the given file
*/ */
public String getLanguageForFile(ICConfigurationDescription configuration, IFile file) { public String getLanguageForFile(ICConfigurationDescription configuration, IFile file) {
return getLanguageForFile(configuration, file.getProjectRelativePath().toPortableString()); return getLanguageForFile(configuration, file.getProjectRelativePath().toPortableString());
@ -86,15 +86,15 @@ public class ProjectLanguageConfiguration {
* If <code>configuration</code> is <code>null</code>, the configuration-agnostic * If <code>configuration</code> is <code>null</code>, the configuration-agnostic
* mapping is returned. * mapping is returned.
* @param path * @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) { public String getLanguageForFile(ICConfigurationDescription configuration, String path) {
Map configurationMappings = (Map) fFileConfigurationMappings.get(path); Map<String, String> configurationMappings = fFileConfigurationMappings.get(path);
if (configurationMappings == null) { if (configurationMappings == null) {
return null; return null;
} }
String configurationId = getId(configuration); 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) { public void addContentTypeMapping(ICConfigurationDescription configuration, String contentType, String language) {
String configurationId = getId(configuration); String configurationId = getId(configuration);
Map contentTypeMappings = (Map) fConfigurationContentTypeMappings.get(configurationId); Map<String, String> contentTypeMappings = fConfigurationContentTypeMappings.get(configurationId);
if (contentTypeMappings == null) { if (contentTypeMappings == null) {
contentTypeMappings = new TreeMap(); contentTypeMappings = new TreeMap<String, String>();
fConfigurationContentTypeMappings.put(configurationId, contentTypeMappings); fConfigurationContentTypeMappings.put(configurationId, contentTypeMappings);
} }
contentTypeMappings.put(contentType, language); contentTypeMappings.put(contentType, language);
@ -124,7 +124,7 @@ public class ProjectLanguageConfiguration {
*/ */
public void removeContentTypeMapping(ICConfigurationDescription configuration, String contentType) { public void removeContentTypeMapping(ICConfigurationDescription configuration, String contentType) {
String configurationId = getId(configuration); String configurationId = getId(configuration);
Map contentTypeMappings = (Map) fConfigurationContentTypeMappings.get(configurationId); Map<String, String> contentTypeMappings = fConfigurationContentTypeMappings.get(configurationId);
if (contentTypeMappings == null) { if (contentTypeMappings == null) {
return; return;
} }
@ -155,9 +155,9 @@ public class ProjectLanguageConfiguration {
* @param language * @param language
*/ */
public void addFileMapping(ICConfigurationDescription configuration, String filePath, String language) { public void addFileMapping(ICConfigurationDescription configuration, String filePath, String language) {
Map configurationMappings = (Map) fFileConfigurationMappings.get(filePath); Map<String, String> configurationMappings = fFileConfigurationMappings.get(filePath);
if (configurationMappings == null) { if (configurationMappings == null) {
configurationMappings = new TreeMap(); configurationMappings = new TreeMap<String, String>();
fFileConfigurationMappings.put(filePath, configurationMappings); fFileConfigurationMappings.put(filePath, configurationMappings);
} }
String configurationId = getId(configuration); String configurationId = getId(configuration);
@ -181,7 +181,7 @@ public class ProjectLanguageConfiguration {
* @param filePath * @param filePath
*/ */
public void removeFileMapping(ICConfigurationDescription configuration, String filePath) { public void removeFileMapping(ICConfigurationDescription configuration, String filePath) {
Map fileMappings = (Map) fFileConfigurationMappings.get(filePath); Map<String, String> fileMappings = fFileConfigurationMappings.get(filePath);
if (fileMappings == null) { if (fileMappings == null) {
return; return;
} }
@ -202,54 +202,57 @@ public class ProjectLanguageConfiguration {
/** /**
* Removes all language mappings for the given file. * Removes all language mappings for the given file.
* @param filePath * @param file
*/ */
public void removeAllFileMappings(IFile file) { public void removeAllFileMappings(IFile file) {
removeAllFileMappings(file.getProjectRelativePath().toPortableString()); 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. * 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<String, Map<String, String>> getContentTypeMappings() {
return copyLanguageMappings(fConfigurationContentTypeMappings, false); return copyLanguageMappings(fConfigurationContentTypeMappings, false);
} }
/** /**
* This method is used internally by CDT and should not be used outside of the CDT framework. * 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<String, Map<String, String>> mappings) {
fConfigurationContentTypeMappings = copyLanguageMappings(mappings, false); 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. * 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<String, Map<String, String>> getFileMappings() {
return copyLanguageMappings(fFileConfigurationMappings, false); return copyLanguageMappings(fFileConfigurationMappings, false);
} }
/** /**
* This method is used internally by CDT and should not be used outside of the CDT framework. * This method is used internally by CDT and should not be used outside of the CDT framework.
* @param file * @param file
* @return
*/ */
public void setFileMappings(IFile file, Map mappings) { public void setFileMappings(IFile file, Map<String, String> mappings) {
fFileConfigurationMappings.put(file.getProjectRelativePath().toPortableString(), new TreeMap(mappings)); fFileConfigurationMappings.put(file.getProjectRelativePath().toPortableString(), new TreeMap<String, String>(mappings));
} }
private Map copyLanguageMappings(Map mappings, boolean isReadOnly) { private Map<String, Map<String, String>> copyLanguageMappings(Map<String, Map<String, String>> mappings, boolean isReadOnly) {
Map result = new TreeMap(); Map<String, Map<String, String>> result = new TreeMap<String, Map<String, String>>();
Iterator entries = mappings.entrySet().iterator(); Iterator<Entry<String, Map<String, String>>> entries = mappings.entrySet().iterator();
while (entries.hasNext()) { while (entries.hasNext()) {
Entry entry = (Entry) entries.next(); Entry<String, Map<String, String>> entry = entries.next();
Map map = (Map) entry.getValue(); Map<String, String> map = entry.getValue();
if (isReadOnly) { if (isReadOnly) {
map = Collections.unmodifiableMap(map); map = Collections.unmodifiableMap(map);
} else { } else {
map = new TreeMap(map); map = new TreeMap<String, String>(map);
} }
result.put(entry.getKey(), 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. * This method is used internally by CDT and should not be used outside of the CDT framework.
* @param file * @param mappings
* @return
*/ */
public void setFileMappings(Map mappings) { public void setFileMappings(Map<String, Map<String, String>> mappings) {
fFileConfigurationMappings = copyLanguageMappings(mappings, false); fFileConfigurationMappings = copyLanguageMappings(mappings, false);
} }

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -22,14 +22,14 @@ public class WorkspaceLanguageConfiguration {
/** /**
* Workspace-wide content type mappings. * Workspace-wide content type mappings.
*/ */
private Map fMappings; private Map<String, String> fMappings;
/** /**
* Creates a new <code>WorkspaceLanguageConfiguration</code> with no * Creates a new <code>WorkspaceLanguageConfiguration</code> with no
* language mappings defined. * language mappings defined.
*/ */
public WorkspaceLanguageConfiguration() { public WorkspaceLanguageConfiguration() {
fMappings = new TreeMap(); fMappings = new TreeMap<String, String>();
} }
/** /**
@ -53,26 +53,26 @@ public class WorkspaceLanguageConfiguration {
* Replaces the existing language mappings with the given * Replaces the existing language mappings with the given
* mappings. The given mappings should be between content type ids * mappings. The given mappings should be between content type ids
* (<code>String</code>) and language ids (<code>String</code>) * (<code>String</code>) and language ids (<code>String</code>)
* @param projectMappings * @param mappings
*/ */
public void setWorkspaceMappings(Map/*<String, String>*/ mappings) { public void setWorkspaceMappings(Map<String, String> mappings) {
fMappings = new TreeMap(mappings); fMappings = new TreeMap<String, String>(mappings);
} }
/** /**
* Returns a read-only copy of the workspace-wide language mappings. * Returns a read-only copy of the workspace-wide language mappings.
* @return 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<String, String> getWorkspaceMappings() {
return Collections.unmodifiableMap(fMappings); return Collections.unmodifiableMap(fMappings);
} }
/** /**
* Returns the language id that is mapped to the given content type. * Returns the language id that is mapped to the given content type.
* @param contentTypeId * @param contentTypeId
* @return * @return the language id that is mapped to the given content type.
*/ */
public String getLanguageForContentType(String contentTypeId) { public String getLanguageForContentType(String contentTypeId) {
return (String) fMappings.get(contentTypeId); return fMappings.get(contentTypeId);
} }
} }

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -22,6 +22,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.Map.Entry;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ILinkage; 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 final String ATTRIBUTE_ID = "id"; //$NON-NLS-1$
private static LanguageManager instance; private static LanguageManager instance;
private Map fLanguageCache = new HashMap(); private Map<String, ILanguage> fLanguageCache = new HashMap<String, ILanguage>();
private Map<String, IPDOMLinkageFactory> fPDOMLinkageFactoryCache= new HashMap<String, IPDOMLinkageFactory>(); private Map<String, IPDOMLinkageFactory> fPDOMLinkageFactoryCache= new HashMap<String, IPDOMLinkageFactory>();
private Map fContentTypeToLanguageCache= new HashMap(); private Map<String, ILanguage> fContentTypeToLanguageCache= new HashMap<String, ILanguage>();
private Map fLanguageConfigurationCache = new HashMap(); private Map<IProject, ProjectLanguageConfiguration> fLanguageConfigurationCache = new HashMap<IProject, ProjectLanguageConfiguration>();
private boolean fIsFullyCached; private boolean fIsFullyCached;
private HashMap fIdToLanguageDescriptorCache;//= new HashMap(); private HashMap<String, ILanguageDescriptor> fIdToLanguageDescriptorCache;//= new HashMap();
private HashMap fContentTypeToDescriptorListCache; private HashMap<String, List<ILanguageDescriptor>> fContentTypeToDescriptorListCache;
private ListenerList fLanguageChangeListeners = new ListenerList(ListenerList.IDENTITY); private ListenerList fLanguageChangeListeners = new ListenerList(ListenerList.IDENTITY);
private WorkspaceLanguageConfiguration fWorkspaceMappings; private WorkspaceLanguageConfiguration fWorkspaceMappings;
@ -79,11 +80,11 @@ public class LanguageManager {
} }
public ILanguageDescriptor getLanguageDescriptor(String id) { public ILanguageDescriptor getLanguageDescriptor(String id) {
Map map = getDescriptorCache(); Map<String, ILanguageDescriptor> map = getDescriptorCache();
return (ILanguageDescriptor)map.get(id); return map.get(id);
} }
private HashMap getDescriptorCache(){ private HashMap<String, ILanguageDescriptor> getDescriptorCache(){
if(fIdToLanguageDescriptorCache == null){ if(fIdToLanguageDescriptorCache == null){
fIdToLanguageDescriptorCache = createDescriptorCache(); fIdToLanguageDescriptorCache = createDescriptorCache();
} }
@ -91,12 +92,12 @@ public class LanguageManager {
} }
public ILanguageDescriptor[] getLanguageDescriptors(){ public ILanguageDescriptor[] getLanguageDescriptors(){
HashMap map = getDescriptorCache(); HashMap<String, ILanguageDescriptor> map = getDescriptorCache();
return (ILanguageDescriptor[])map.values().toArray(new ILanguageDescriptor[map.size()]); return map.values().toArray(new ILanguageDescriptor[map.size()]);
} }
private HashMap createDescriptorCache(){ private HashMap<String, ILanguageDescriptor> createDescriptorCache(){
HashMap map = new HashMap(); HashMap<String, ILanguageDescriptor> map = new HashMap<String, ILanguageDescriptor>();
IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID); IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID);
for (int j = 0; j < configs.length; ++j) { for (int j = 0; j < configs.length; ++j) {
final IConfigurationElement languageElem = configs[j]; final IConfigurationElement languageElem = configs[j];
@ -108,23 +109,23 @@ public class LanguageManager {
return map; return map;
} }
private HashMap getContentTypeToDescriptorCache(){ private HashMap<String, List<ILanguageDescriptor>> getContentTypeToDescriptorCache(){
if(fContentTypeToDescriptorListCache == null){ if(fContentTypeToDescriptorListCache == null){
fContentTypeToDescriptorListCache = createContentTypeToDescriptorCache(); fContentTypeToDescriptorListCache = createContentTypeToDescriptorCache();
} }
return fContentTypeToDescriptorListCache; return fContentTypeToDescriptorListCache;
} }
public Map getContentTypeIdToLanguageDescriptionsMap(){ public Map<String, ILanguageDescriptor[]> getContentTypeIdToLanguageDescriptionsMap(){
HashMap map = (HashMap)getContentTypeToDescriptorCache().clone(); HashMap<String, ILanguageDescriptor[]> map = new HashMap<String, ILanguageDescriptor[]>();
for(Iterator iter = map.entrySet().iterator(); iter.hasNext();){ Map<String, List<ILanguageDescriptor>> cache = getContentTypeToDescriptorCache();
Map.Entry entry = (Map.Entry)iter.next();
List list = (List)entry.getValue(); for(Iterator<Entry<String, List<ILanguageDescriptor>>> iter = cache.entrySet().iterator(); iter.hasNext();){
Entry<String, List<ILanguageDescriptor>> entry = iter.next();
List<ILanguageDescriptor> list = entry.getValue();
if(list.size() > 0){ if(list.size() > 0){
ILanguageDescriptor[] dess = (ILanguageDescriptor[])list.toArray(new ILanguageDescriptor[list.size()]); ILanguageDescriptor[] dess = list.toArray(new ILanguageDescriptor[list.size()]);
entry.setValue(dess); map.put(entry.getKey(), dess);
} else {
iter.remove();
} }
} }
@ -132,22 +133,22 @@ public class LanguageManager {
} }
private HashMap createContentTypeToDescriptorCache(){ private HashMap<String, List<ILanguageDescriptor>> createContentTypeToDescriptorCache(){
HashMap map = new HashMap(); HashMap<String, List<ILanguageDescriptor>> map = new HashMap<String, List<ILanguageDescriptor>>();
Map dc = getDescriptorCache(); Map<String, ILanguageDescriptor> dc = getDescriptorCache();
List list; List<ILanguageDescriptor> list;
IContentType type; IContentType type;
String id; String id;
for(Iterator iter = dc.values().iterator(); iter.hasNext();){ for(Iterator<ILanguageDescriptor> iter = dc.values().iterator(); iter.hasNext();){
ILanguageDescriptor des = (ILanguageDescriptor)iter.next(); ILanguageDescriptor des = iter.next();
IContentType types[] = des.getContentTypes(); IContentType types[] = des.getContentTypes();
for(int i = 0; i < types.length; i++){ for(int i = 0; i < types.length; i++){
type = types[i]; type = types[i];
id = type.getId(); id = type.getId();
list = (List)map.get(id); list = map.get(id);
if(list == null){ if(list == null){
list = new ArrayList(); list = new ArrayList<ILanguageDescriptor>();
map.put(id, list); map.put(id, list);
} }
list.add(des); list.add(des);
@ -157,7 +158,7 @@ public class LanguageManager {
} }
public ILanguage getLanguage(String id) { public ILanguage getLanguage(String id) {
ILanguage language = (ILanguage)fLanguageCache.get(id); ILanguage language = fLanguageCache.get(id);
if (language != null) if (language != null)
return language; return language;
@ -199,7 +200,7 @@ public class LanguageManager {
public ILanguage getLanguageForContentTypeID(String contentTypeID) { public ILanguage getLanguageForContentTypeID(String contentTypeID) {
cacheAllLanguages(); cacheAllLanguages();
ILanguage language = (ILanguage)fContentTypeToLanguageCache.get(contentTypeID); ILanguage language = fContentTypeToLanguageCache.get(contentTypeID);
if (language != null || fContentTypeToLanguageCache.containsKey(contentTypeID)) if (language != null || fContentTypeToLanguageCache.containsKey(contentTypeID))
return language; return language;
@ -226,8 +227,8 @@ public class LanguageManager {
* @deprecated use getRegisteredContentTypes() instead. * @deprecated use getRegisteredContentTypes() instead.
*/ */
@Deprecated @Deprecated
public ArrayList/*<String>*/ getAllContentTypes() { public ArrayList/*<String>*/<String> getAllContentTypes() {
ArrayList/*<String>*/ allTypes = new ArrayList(); ArrayList/*<String>*/<String> allTypes = new ArrayList<String>();
allTypes.add(CCorePlugin.CONTENT_TYPE_ASMSOURCE); allTypes.add(CCorePlugin.CONTENT_TYPE_ASMSOURCE);
allTypes.add(CCorePlugin.CONTENT_TYPE_CHEADER); allTypes.add(CCorePlugin.CONTENT_TYPE_CHEADER);
allTypes.add(CCorePlugin.CONTENT_TYPE_CSOURCE); allTypes.add(CCorePlugin.CONTENT_TYPE_CSOURCE);
@ -255,12 +256,12 @@ public class LanguageManager {
* @since 3.1.1 * @since 3.1.1
*/ */
public String[] getRegisteredContentTypeIds() { public String[] getRegisteredContentTypeIds() {
Set contentTypes= collectContentTypeIds(); Set<String> contentTypes= collectContentTypeIds();
return (String[]) contentTypes.toArray(new String[contentTypes.size()]); return contentTypes.toArray(new String[contentTypes.size()]);
} }
private Set collectContentTypeIds() { private Set<String> collectContentTypeIds() {
HashSet/*<String>*/ allTypes = new HashSet(); HashSet/*<String>*/<String> allTypes = new HashSet<String>();
allTypes.add(CCorePlugin.CONTENT_TYPE_ASMSOURCE); allTypes.add(CCorePlugin.CONTENT_TYPE_ASMSOURCE);
allTypes.add(CCorePlugin.CONTENT_TYPE_CHEADER); allTypes.add(CCorePlugin.CONTENT_TYPE_CHEADER);
allTypes.add(CCorePlugin.CONTENT_TYPE_CSOURCE); allTypes.add(CCorePlugin.CONTENT_TYPE_CSOURCE);
@ -335,9 +336,9 @@ public class LanguageManager {
public ILanguage[] getRegisteredLanguages() { public ILanguage[] getRegisteredLanguages() {
cacheAllLanguages(); cacheAllLanguages();
ILanguage[] languages = new ILanguage[fLanguageCache.size()]; ILanguage[] languages = new ILanguage[fLanguageCache.size()];
Iterator values = fLanguageCache.values().iterator(); Iterator<ILanguage> values = fLanguageCache.values().iterator();
for (int i = 0; values.hasNext(); i++) { for (int i = 0; values.hasNext(); i++) {
languages[i] = (ILanguage) values.next(); languages[i] = values.next();
} }
return languages; return languages;
} }
@ -371,7 +372,7 @@ public class LanguageManager {
/** /**
* Returns the language configuration for the workspace. * Returns the language configuration for the workspace.
* @return * @return the language configuration for the workspace
* @throws CoreException * @throws CoreException
* @since 4.0 * @since 4.0
*/ */
@ -414,13 +415,13 @@ public class LanguageManager {
/** /**
* Returns the language configuration for the given project. * Returns the language configuration for the given project.
* @param project * @param project
* @return * @return the language configuration for the given project
* @throws CoreException * @throws CoreException
* @since 4.0 * @since 4.0
*/ */
public ProjectLanguageConfiguration getLanguageConfiguration(IProject project) throws CoreException { public ProjectLanguageConfiguration getLanguageConfiguration(IProject project) throws CoreException {
synchronized (this) { synchronized (this) {
ProjectLanguageConfiguration mappings = (ProjectLanguageConfiguration) fLanguageConfigurationCache.get(project); ProjectLanguageConfiguration mappings = fLanguageConfigurationCache.get(project);
if (mappings != null) { if (mappings != null) {
return mappings; return mappings;
} }
@ -443,7 +444,7 @@ public class LanguageManager {
*/ */
public void storeLanguageMappingConfiguration(IProject project, IContentType[] affectedContentTypes) throws CoreException { public void storeLanguageMappingConfiguration(IProject project, IContentType[] affectedContentTypes) throws CoreException {
synchronized (this) { synchronized (this) {
ProjectLanguageConfiguration mappings = (ProjectLanguageConfiguration) fLanguageConfigurationCache.get(project); ProjectLanguageConfiguration mappings = fLanguageConfigurationCache.get(project);
LanguageMappingStore store = new LanguageMappingStore(); LanguageMappingStore store = new LanguageMappingStore();
store.storeMappings(project, mappings); store.storeMappings(project, mappings);
} }
@ -550,7 +551,7 @@ public class LanguageManager {
* @param file the file for which the language is requested * @param file the file for which the language is requested
* @param configuration the active build configuration, or <code>null</code> if build configurations * @param configuration the active build configuration, or <code>null</code> if build configurations
* are not relevant to determining the language. * are not relevant to determining the language.
* @param contentTypeID id of the content type, may be <code>null</code>. * @param contentTypeId id of the content type, may be <code>null</code>.
* @throws CoreException * @throws CoreException
* @since 4.0 * @since 4.0
*/ */
@ -612,7 +613,7 @@ public class LanguageManager {
public void storeLanguageMappingConfiguration(IFile file) throws CoreException { public void storeLanguageMappingConfiguration(IFile file) throws CoreException {
IProject project = file.getProject(); IProject project = file.getProject();
synchronized (this) { synchronized (this) {
ProjectLanguageConfiguration mappings = (ProjectLanguageConfiguration) fLanguageConfigurationCache.get(project); ProjectLanguageConfiguration mappings = fLanguageConfigurationCache.get(project);
LanguageMappingStore store = new LanguageMappingStore(); LanguageMappingStore store = new LanguageMappingStore();
store.storeMappings(project, mappings); store.storeMappings(project, mappings);
} }

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -51,7 +51,7 @@ public class LanguageMappingResolver {
*/ */
public static LanguageMapping[] computeLanguage(IProject project, String filePath, ICConfigurationDescription configuration, String contentTypeId, boolean fetchAll) throws CoreException { public static LanguageMapping[] computeLanguage(IProject project, String filePath, ICConfigurationDescription configuration, String contentTypeId, boolean fetchAll) throws CoreException {
LanguageManager manager = LanguageManager.getInstance(); LanguageManager manager = LanguageManager.getInstance();
List inheritedLanguages = new LinkedList(); List<LanguageMapping> inheritedLanguages = new LinkedList<LanguageMapping>();
if (project != null) { if (project != null) {
ProjectLanguageConfiguration mappings = manager.getLanguageConfiguration(project); ProjectLanguageConfiguration mappings = manager.getLanguageConfiguration(project);
@ -121,12 +121,12 @@ public class LanguageMappingResolver {
return createLanguageMappingArray(inheritedLanguages); return createLanguageMappingArray(inheritedLanguages);
} }
private static LanguageMapping[] createLanguageMappingArray(List inheritedLanguages) { private static LanguageMapping[] createLanguageMappingArray(List<LanguageMapping> inheritedLanguages) {
LanguageMapping[] results = new LanguageMapping[inheritedLanguages.size()]; LanguageMapping[] results = new LanguageMapping[inheritedLanguages.size()];
Iterator mappings = inheritedLanguages.iterator(); Iterator<LanguageMapping> mappings = inheritedLanguages.iterator();
int i = 0; int i = 0;
while (mappings.hasNext()) { while (mappings.hasNext()) {
LanguageMapping mapping = (LanguageMapping) mappings.next(); LanguageMapping mapping = mappings.next();
results[i] = mapping; results[i] = mapping;
i++; i++;
} }

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -86,16 +86,16 @@ public class LanguageMappingStore {
return config; return config;
} }
private Map decodeProjectContentTypeMappings(Element rootElement) { private Map<String, Map<String, String>> decodeProjectContentTypeMappings(Element rootElement) {
Map decodedMappings = new TreeMap(); Map<String, Map<String, String>> decodedMappings = new TreeMap<String, Map<String, String>>();
NodeList mappingElements = rootElement.getElementsByTagName(CONTENT_TYPE_MAPPING); NodeList mappingElements = rootElement.getElementsByTagName(CONTENT_TYPE_MAPPING);
for (int j = 0; j < mappingElements.getLength(); j++) { for (int j = 0; j < mappingElements.getLength(); j++) {
Element mapping = (Element) mappingElements.item(j); Element mapping = (Element) mappingElements.item(j);
String configuration = mapping.getAttribute(ATTRIBUTE_CONFIGURATION); String configuration = mapping.getAttribute(ATTRIBUTE_CONFIGURATION);
Map contentTypeMappings = (Map) decodedMappings.get(configuration); Map<String, String> contentTypeMappings = decodedMappings.get(configuration);
if (contentTypeMappings == null) { if (contentTypeMappings == null) {
contentTypeMappings = new TreeMap(); contentTypeMappings = new TreeMap<String, String>();
decodedMappings.put(configuration, contentTypeMappings); decodedMappings.put(configuration, contentTypeMappings);
} }
String contentType = mapping.getAttribute(ATTRIBUTE_CONTENT_TYPE); String contentType = mapping.getAttribute(ATTRIBUTE_CONTENT_TYPE);
@ -109,20 +109,20 @@ public class LanguageMappingStore {
return CCorePlugin.getDefault().getCProjectDescription(project, true); return CCorePlugin.getDefault().getCProjectDescription(project, true);
} }
private Map decodeContentTypeMappings(Element rootElement) throws CoreException { private Map<String, String> decodeContentTypeMappings(Element rootElement) throws CoreException {
return decodeMappings(rootElement, CONTENT_TYPE_MAPPING, ATTRIBUTE_CONTENT_TYPE, ATTRIBUTE_LANGUAGE); return decodeMappings(rootElement, CONTENT_TYPE_MAPPING, ATTRIBUTE_CONTENT_TYPE, ATTRIBUTE_LANGUAGE);
} }
private Map decodeFileMappings(Element rootElement) throws CoreException { private Map<String, Map<String, String>> decodeFileMappings(Element rootElement) throws CoreException {
Map decodedMappings = new TreeMap(); Map<String, Map<String, String>> decodedMappings = new TreeMap<String, Map<String, String>>();
NodeList mappingElements = rootElement.getElementsByTagName(FILE_MAPPING); NodeList mappingElements = rootElement.getElementsByTagName(FILE_MAPPING);
for (int j = 0; j < mappingElements.getLength(); j++) { for (int j = 0; j < mappingElements.getLength(); j++) {
Element mapping = (Element) mappingElements.item(j); Element mapping = (Element) mappingElements.item(j);
String path = mapping.getAttribute(ATTRIBUTE_PATH); String path = mapping.getAttribute(ATTRIBUTE_PATH);
Map configurationMappings = (Map) decodedMappings.get(path); Map<String, String> configurationMappings = decodedMappings.get(path);
if (configurationMappings == null) { if (configurationMappings == null) {
configurationMappings = new TreeMap(); configurationMappings = new TreeMap<String, String>();
decodedMappings.put(path, configurationMappings); decodedMappings.put(path, configurationMappings);
} }
String configuration = mapping.getAttribute(ATTRIBUTE_CONFIGURATION); String configuration = mapping.getAttribute(ATTRIBUTE_CONFIGURATION);
@ -132,8 +132,8 @@ public class LanguageMappingStore {
return decodedMappings; return decodedMappings;
} }
private Map decodeMappings(Element rootElement, String category, String keyName, String valueName) { private Map<String, String> decodeMappings(Element rootElement, String category, String keyName, String valueName) {
Map decodedMappings = new TreeMap(); Map<String, String> decodedMappings = new TreeMap<String, String>();
NodeList mappingElements = rootElement.getElementsByTagName(category); NodeList mappingElements = rootElement.getElementsByTagName(category);
for (int j = 0; j < mappingElements.getLength(); j++) { for (int j = 0; j < mappingElements.getLength(); j++) {
Element mapping = (Element) mappingElements.item(j); Element mapping = (Element) mappingElements.item(j);
@ -158,18 +158,18 @@ public class LanguageMappingStore {
descriptor.saveProjectData(); descriptor.saveProjectData();
} }
private void addProjectContentTypeMappings(Map contentTypeMappings, Element rootElement) { private void addProjectContentTypeMappings(Map<String, Map<String, String>> contentTypeMappings, Element rootElement) {
Document document = rootElement.getOwnerDocument(); Document document = rootElement.getOwnerDocument();
Iterator entries = contentTypeMappings.entrySet().iterator(); Iterator<Entry<String, Map<String, String>>> entries = contentTypeMappings.entrySet().iterator();
while (entries.hasNext()) { while (entries.hasNext()) {
Entry entry = (Entry) entries.next(); Entry<String, Map<String, String>> entry = entries.next();
String configuration = (String) entry.getKey(); String configuration = entry.getKey();
Iterator contentTypeEntries = ((Map) entry.getValue()).entrySet().iterator(); Iterator<Entry<String, String>> contentTypeEntries = entry.getValue().entrySet().iterator();
while (contentTypeEntries.hasNext()) { while (contentTypeEntries.hasNext()) {
Entry configurationEntry = (Entry) contentTypeEntries.next(); Entry<String, String> configurationEntry = contentTypeEntries.next();
String contentType = (String) configurationEntry.getKey(); String contentType = configurationEntry.getKey();
String language = (String) configurationEntry.getValue(); String language = configurationEntry.getValue();
Element mapping = document.createElement(CONTENT_TYPE_MAPPING); Element mapping = document.createElement(CONTENT_TYPE_MAPPING);
mapping.setAttribute(ATTRIBUTE_CONTENT_TYPE, contentType); 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<String, String> mappings, Element rootElement, String category, String keyName, String valueName) {
Document document = rootElement.getOwnerDocument(); Document document = rootElement.getOwnerDocument();
Iterator entries = mappings.entrySet().iterator(); Iterator<Entry<String, String>> entries = mappings.entrySet().iterator();
while (entries.hasNext()) { while (entries.hasNext()) {
Entry entry = (Entry) entries.next(); Entry<String, String> entry = entries.next();
Element mapping = document.createElement(category); Element mapping = document.createElement(category);
mapping.setAttribute(keyName, (String) entry.getKey()); mapping.setAttribute(keyName, entry.getKey());
mapping.setAttribute(valueName, (String) entry.getValue()); mapping.setAttribute(valueName, entry.getValue());
rootElement.appendChild(mapping); rootElement.appendChild(mapping);
} }
} }
private void addContentTypeMappings(Map mappings, Element rootElement) { private void addContentTypeMappings(Map<String, String> mappings, Element rootElement) {
addMappings(mappings, rootElement, CONTENT_TYPE_MAPPING, ATTRIBUTE_CONTENT_TYPE, ATTRIBUTE_LANGUAGE); addMappings(mappings, rootElement, CONTENT_TYPE_MAPPING, ATTRIBUTE_CONTENT_TYPE, ATTRIBUTE_LANGUAGE);
} }
private void addFileMappings(Map mappings, Element rootElement) { private void addFileMappings(Map<String, Map<String, String>> mappings, Element rootElement) {
Document document = rootElement.getOwnerDocument(); Document document = rootElement.getOwnerDocument();
Iterator entries = mappings.entrySet().iterator(); Iterator<Entry<String, Map<String, String>>> entries = mappings.entrySet().iterator();
while (entries.hasNext()) { while (entries.hasNext()) {
Entry entry = (Entry) entries.next(); Entry<String, Map<String, String>> entry = entries.next();
Element mapping = document.createElement(FILE_MAPPING); Element mapping = document.createElement(FILE_MAPPING);
String path = (String) entry.getKey(); String path = entry.getKey();
Iterator configurationEntries = ((Map) entry.getValue()).entrySet().iterator(); Iterator<Entry<String, String>> configurationEntries = entry.getValue().entrySet().iterator();
while (configurationEntries.hasNext()) { while (configurationEntries.hasNext()) {
Entry configurationEntry = (Entry) configurationEntries.next(); Entry<String, String> configurationEntry = configurationEntries.next();
String configuration = (String) configurationEntry.getKey(); String configuration = configurationEntry.getKey();
String language = (String) configurationEntry.getValue(); String language = configurationEntry.getValue();
mapping.setAttribute(ATTRIBUTE_PATH, path); mapping.setAttribute(ATTRIBUTE_PATH, path);
mapping.setAttribute(ATTRIBUTE_CONFIGURATION, configuration); mapping.setAttribute(ATTRIBUTE_CONFIGURATION, configuration);

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -34,13 +34,13 @@ public abstract class ContentTypeMappingDialog extends Dialog {
String fSelectedLanguageID; String fSelectedLanguageID;
String fSelectedConfigurationID; String fSelectedConfigurationID;
String fSelectedConfigurationName; String fSelectedConfigurationName;
HashMap fContentTypeNamesToIDsMap; HashMap<String, String> fContentTypeNamesToIDsMap;
HashMap fLanguageNamesToIDsMap; HashMap<String, String> fLanguageNamesToIDsMap;
public ContentTypeMappingDialog(Shell parentShell) { public ContentTypeMappingDialog(Shell parentShell) {
super(parentShell); super(parentShell);
fContentTypeNamesToIDsMap = new HashMap(); fContentTypeNamesToIDsMap = new HashMap<String, String>();
fLanguageNamesToIDsMap = new HashMap(); fLanguageNamesToIDsMap = new HashMap<String, String>();
} }
public String getSelectedContentTypeName() { public String getSelectedContentTypeName() {

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -71,7 +71,7 @@ public class FileLanguageMappingPropertyPage extends PropertyPage {
private Composite fContents; private Composite fContents;
private Table fTable; private Table fTable;
private ILanguage[] fLanguages; private ILanguage[] fLanguages;
private Map fLanguageIds; private Map<String, ILanguage> fLanguageIds;
private boolean fHasChanges; private boolean fHasChanges;
public FileLanguageMappingPropertyPage() { public FileLanguageMappingPropertyPage() {
@ -213,7 +213,7 @@ public class FileLanguageMappingPropertyPage extends PropertyPage {
ProjectLanguageConfiguration config = LanguageManager.getInstance().getLanguageConfiguration(project); ProjectLanguageConfiguration config = LanguageManager.getInstance().getLanguageConfiguration(project);
Set missingLanguages = LanguageVerifier.removeMissingLanguages(config, description, fLanguageIds); Set<String> missingLanguages = LanguageVerifier.removeMissingLanguages(config, description, fLanguageIds);
if (missingLanguages.size() > 0) { if (missingLanguages.size() > 0) {
MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK); MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK);
messageBox.setText(PreferencesMessages.LanguageMappings_missingLanguageTitle); messageBox.setText(PreferencesMessages.LanguageMappings_missingLanguageTitle);
@ -232,7 +232,7 @@ public class FileLanguageMappingPropertyPage extends PropertyPage {
String languageId = config.getLanguageForFile(configurations[i], file); String languageId = config.getLanguageForFile(configurations[i], file);
if (languageId != null) { if (languageId != null) {
ILanguage language = (ILanguage) fLanguageIds.get(languageId); ILanguage language = fLanguageIds.get(languageId);
String languageName = language.getName(); String languageName = language.getName();
item.setText(LANGUAGE_COLUMN, languageName); item.setText(LANGUAGE_COLUMN, languageName);
} }
@ -322,7 +322,7 @@ public class FileLanguageMappingPropertyPage extends PropertyPage {
LanguageManager manager = LanguageManager.getInstance(); LanguageManager manager = LanguageManager.getInstance();
ProjectLanguageConfiguration config = manager.getLanguageConfiguration(project); ProjectLanguageConfiguration config = manager.getLanguageConfiguration(project);
Map mappings = new TreeMap(); Map<String, String> mappings = new TreeMap<String, String>();
TableItem[] items = fTable.getItems(); TableItem[] items = fTable.getItems();
for (int i = 0; i < items.length; i++) { for (int i = 0; i < items.length; i++) {
TableItem item = items[i]; TableItem item = items[i];

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -36,22 +36,22 @@ public abstract class LanguageMappingWidget {
protected boolean fIsReadOnly; protected boolean fIsReadOnly;
protected Table fTable; protected Table fTable;
protected HashMap fContentTypeNamesToIDsMap; protected HashMap<String, String> fContentTypeNamesToIDsMap;
protected Set fAffectedContentTypes; protected Set<IContentType> fAffectedContentTypes;
protected Font fOverriddenFont; protected Font fOverriddenFont;
protected LanguageMappingWidget fChild; protected LanguageMappingWidget fChild;
protected IAdaptable fElement; protected IAdaptable fElement;
protected Set fOverriddenContentTypes; protected Set<String> fOverriddenContentTypes;
private boolean fIsChanged; private boolean fIsChanged;
public LanguageMappingWidget() { public LanguageMappingWidget() {
fOverriddenFont = JFaceResources.getFontRegistry().getItalic(JFaceResources.DIALOG_FONT); 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 // keep a mapping of all registered content types and their names
fContentTypeNamesToIDsMap = new HashMap(); fContentTypeNamesToIDsMap = new HashMap<String, String>();
String[] contentTypesIDs = LanguageManager.getInstance().getRegisteredContentTypeIds(); String[] contentTypesIDs = LanguageManager.getInstance().getRegisteredContentTypeIds();
IContentTypeManager contentTypeManager = Platform.getContentTypeManager(); IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
@ -66,7 +66,7 @@ public abstract class LanguageMappingWidget {
fContentTypeNamesToIDsMap.put(name, contentTypesIDs[i]); fContentTypeNamesToIDsMap.put(name, contentTypesIDs[i]);
} }
fAffectedContentTypes = new HashSet(); fAffectedContentTypes = new HashSet<IContentType>();
} }
public IAdaptable getElement() { public IAdaptable getElement() {
@ -77,12 +77,12 @@ public abstract class LanguageMappingWidget {
fElement = element; fElement = element;
} }
public void setOverriddenContentTypes(Set contentTypes) { public void setOverriddenContentTypes(Set<String> contentTypes) {
fOverriddenContentTypes = contentTypes; fOverriddenContentTypes = contentTypes;
} }
public IContentType[] getAffectedContentTypes() { public IContentType[] getAffectedContentTypes() {
return (IContentType[]) fAffectedContentTypes.toArray(new IContentType[fAffectedContentTypes.size()]); return fAffectedContentTypes.toArray(new IContentType[fAffectedContentTypes.size()]);
} }
public void setReadOnly(boolean isReadOnly) { public void setReadOnly(boolean isReadOnly) {

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -29,17 +29,17 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription;
*/ */
public class LanguageVerifier { public class LanguageVerifier {
public static Map computeAvailableLanguages() { public static Map<String, ILanguage> computeAvailableLanguages() {
ILanguage[] registeredLanguages = LanguageManager.getInstance().getRegisteredLanguages(); ILanguage[] registeredLanguages = LanguageManager.getInstance().getRegisteredLanguages();
Map languages = new TreeMap(); Map<String, ILanguage> languages = new TreeMap<String, ILanguage>();
for (int i = 0; i < registeredLanguages.length; i++) { for (int i = 0; i < registeredLanguages.length; i++) {
languages.put(registeredLanguages[i].getId(), registeredLanguages[i]); languages.put(registeredLanguages[i].getId(), registeredLanguages[i]);
} }
return languages; return languages;
} }
public static String computeAffectedLanguages(Set missingLanguages) { public static String computeAffectedLanguages(Set<String> missingLanguages) {
Iterator languages = missingLanguages.iterator(); Iterator<String> languages = missingLanguages.iterator();
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
while (languages.hasNext()) { while (languages.hasNext()) {
buffer.append('\n'); buffer.append('\n');
@ -48,20 +48,20 @@ public class LanguageVerifier {
return buffer.toString(); return buffer.toString();
} }
public static Set removeMissingLanguages(ProjectLanguageConfiguration config, ICProjectDescription description, Map availableLanguages) { public static Set<String> removeMissingLanguages(ProjectLanguageConfiguration config, ICProjectDescription description, Map<String, ILanguage> availableLanguages) {
Set missingLanguages = new TreeSet(); Set<String> missingLanguages = new TreeSet<String>();
// Check file mappings // Check file mappings
Iterator fileConfigurationMappings = config.getFileMappings().entrySet().iterator(); Iterator<Entry<String, Map<String, String>>> fileConfigurationMappings = config.getFileMappings().entrySet().iterator();
while (fileConfigurationMappings.hasNext()) { while (fileConfigurationMappings.hasNext()) {
Entry entry = (Entry) fileConfigurationMappings.next(); Entry<String, Map<String, String>> entry = fileConfigurationMappings.next();
String path = (String) entry.getKey(); String path = entry.getKey();
Map configurationLanguageMappings = (Map) entry.getValue(); Map<String, String> configurationLanguageMappings = entry.getValue();
Iterator mappings = configurationLanguageMappings.entrySet().iterator(); Iterator<Entry<String, String>> mappings = configurationLanguageMappings.entrySet().iterator();
while (mappings.hasNext()) { while (mappings.hasNext()) {
Entry mapping = (Entry) mappings.next(); Entry<String, String> mapping = mappings.next();
String configurationId = (String) mapping.getKey(); String configurationId = mapping.getKey();
String languageId = (String) mapping.getValue(); String languageId = mapping.getValue();
if (!availableLanguages.containsKey(languageId)) { if (!availableLanguages.containsKey(languageId)) {
missingLanguages.add(languageId); missingLanguages.add(languageId);
ICConfigurationDescription configuration = description.getConfigurationById(configurationId); ICConfigurationDescription configuration = description.getConfigurationById(configurationId);
@ -71,16 +71,16 @@ public class LanguageVerifier {
} }
// Check content type mappings // Check content type mappings
Iterator configurationContentTypeMappings = config.getContentTypeMappings().entrySet().iterator(); Iterator<Entry<String, Map<String, String>>> configurationContentTypeMappings = config.getContentTypeMappings().entrySet().iterator();
while (configurationContentTypeMappings.hasNext()) { while (configurationContentTypeMappings.hasNext()) {
Entry entry = (Entry) configurationContentTypeMappings.next(); Entry<String, Map<String, String>> entry = configurationContentTypeMappings.next();
String configurationId = (String) entry.getKey(); String configurationId = entry.getKey();
Map contentTypeLanguageMappings = (Map) entry.getValue(); Map<String, String> contentTypeLanguageMappings = entry.getValue();
Iterator mappings = contentTypeLanguageMappings.entrySet().iterator(); Iterator<Entry<String, String>> mappings = contentTypeLanguageMappings.entrySet().iterator();
while (mappings.hasNext()) { while (mappings.hasNext()) {
Entry mapping = (Entry) mappings.next(); Entry<String, String> mapping = mappings.next();
String contentTypeId = (String) mapping.getKey(); String contentTypeId = mapping.getKey();
String languageId = (String) mapping.getValue(); String languageId = mapping.getValue();
if (!availableLanguages.containsKey(languageId)) { if (!availableLanguages.containsKey(languageId)) {
missingLanguages.add(languageId); missingLanguages.add(languageId);
ICConfigurationDescription configuration = description.getConfigurationById(configurationId); ICConfigurationDescription configuration = description.getConfigurationById(configurationId);
@ -92,15 +92,15 @@ public class LanguageVerifier {
return missingLanguages; return missingLanguages;
} }
public static Set removeMissingLanguages(WorkspaceLanguageConfiguration config, Map availableLanguages) { public static Set<String> removeMissingLanguages(WorkspaceLanguageConfiguration config, Map<String, ILanguage> availableLanguages) {
Set missingLanguages = new TreeSet(); Set<String> missingLanguages = new TreeSet<String>();
// Check content type mappings // Check content type mappings
Iterator contentTypeMappings = config.getWorkspaceMappings().entrySet().iterator(); Iterator<Entry<String, String>> contentTypeMappings = config.getWorkspaceMappings().entrySet().iterator();
while (contentTypeMappings.hasNext()) { while (contentTypeMappings.hasNext()) {
Entry entry = (Entry) contentTypeMappings.next(); Entry<String, String> entry = contentTypeMappings.next();
String contentTypeId = (String) entry.getKey(); String contentTypeId = entry.getKey();
String languageId = (String) entry.getValue(); String languageId = entry.getValue();
if (!availableLanguages.containsKey(languageId)) { if (!availableLanguages.containsKey(languageId)) {
missingLanguages.add(languageId); missingLanguages.add(languageId);
config.removeWorkspaceMapping(contentTypeId); config.removeWorkspaceMapping(contentTypeId);

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -36,7 +36,7 @@ public class ProjectContentTypeMappingDialog extends ContentTypeMappingDialog {
private Combo fConfiguration; private Combo fConfiguration;
private ICConfigurationDescription[] fConfigurations; private ICConfigurationDescription[] fConfigurations;
private String[] fContentTypesIDs; private String[] fContentTypesIDs;
private Set fFilteredContentTypes; private Set<String> fFilteredContentTypes;
public ProjectContentTypeMappingDialog(Shell parentShell, ICConfigurationDescription[] configurations) { public ProjectContentTypeMappingDialog(Shell parentShell, ICConfigurationDescription[] configurations) {
super(parentShell); super(parentShell);
@ -105,7 +105,7 @@ public class ProjectContentTypeMappingDialog extends ContentTypeMappingDialog {
fContentType.addListener(SWT.Selection, new Listener() { fContentType.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) { public void handleEvent(Event event) {
fSelectedContentTypeName = fContentType.getText(); fSelectedContentTypeName = fContentType.getText();
fSelectedContentTypeID = (String) fContentTypeNamesToIDsMap.get(fSelectedContentTypeName); fSelectedContentTypeID = fContentTypeNamesToIDsMap.get(fSelectedContentTypeName);
getButton(IDialogConstants.OK_ID).setEnabled(isValidSelection()); getButton(IDialogConstants.OK_ID).setEnabled(isValidSelection());
} }
}); });
@ -120,7 +120,7 @@ public class ProjectContentTypeMappingDialog extends ContentTypeMappingDialog {
fLanguage.addListener(SWT.Selection, new Listener() { fLanguage.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) { public void handleEvent(Event event) {
fSelectedLanguageName = fLanguage.getText(); fSelectedLanguageName = fLanguage.getText();
fSelectedLanguageID = (String) fLanguageNamesToIDsMap.get(fSelectedLanguageName); fSelectedLanguageID = fLanguageNamesToIDsMap.get(fSelectedLanguageName);
getButton(IDialogConstants.OK_ID).setEnabled(isValidSelection()); 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; return fContentType.getSelectionIndex() != -1 && fLanguage.getSelectionIndex() != -1 && fConfiguration.getSelectionIndex() != -1;
} }
public void setContentTypeFilter(Set contentTypeFilter) { public void setContentTypeFilter(Set<String> contentTypeFilter) {
fFilteredContentTypes = contentTypeFilter; fFilteredContentTypes = contentTypeFilter;
} }

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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.ProjectLanguageConfiguration;
import org.eclipse.cdt.core.language.WorkspaceLanguageConfiguration; import org.eclipse.cdt.core.language.WorkspaceLanguageConfiguration;
import org.eclipse.cdt.core.model.CoreModel; 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.ILanguageMappingChangeEvent;
import org.eclipse.cdt.core.model.ILanguageMappingChangeListener; import org.eclipse.cdt.core.model.ILanguageMappingChangeListener;
import org.eclipse.cdt.core.model.LanguageManager; import org.eclipse.cdt.core.model.LanguageManager;
@ -117,8 +118,8 @@ public class ProjectLanguageMappingPropertyPage extends PropertyPage {
fMappings = manager.getLanguageConfiguration(project); fMappings = manager.getLanguageConfiguration(project);
ICProjectDescription description = CoreModel.getDefault().getProjectDescription(project); ICProjectDescription description = CoreModel.getDefault().getProjectDescription(project);
Map availableLanguages = LanguageVerifier.computeAvailableLanguages(); Map<String, ILanguage> availableLanguages = LanguageVerifier.computeAvailableLanguages();
Set missingLanguages = LanguageVerifier.removeMissingLanguages(fMappings, description, availableLanguages); Set<String> missingLanguages = LanguageVerifier.removeMissingLanguages(fMappings, description, availableLanguages);
if (missingLanguages.size() > 0) { if (missingLanguages.size() > 0) {
MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK); MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK);
messageBox.setText(PreferencesMessages.LanguageMappings_missingLanguageTitle); messageBox.setText(PreferencesMessages.LanguageMappings_missingLanguageTitle);
@ -138,8 +139,8 @@ public class ProjectLanguageMappingPropertyPage extends PropertyPage {
LanguageManager manager = LanguageManager.getInstance(); LanguageManager manager = LanguageManager.getInstance();
WorkspaceLanguageConfiguration workspaceMappings = manager.getWorkspaceLanguageConfiguration(); WorkspaceLanguageConfiguration workspaceMappings = manager.getWorkspaceLanguageConfiguration();
Map availableLanguages = LanguageVerifier.computeAvailableLanguages(); Map<String, ILanguage> availableLanguages = LanguageVerifier.computeAvailableLanguages();
Set missingLanguages = LanguageVerifier.removeMissingLanguages(workspaceMappings, availableLanguages); Set<String> missingLanguages = LanguageVerifier.removeMissingLanguages(workspaceMappings, availableLanguages);
if (missingLanguages.size() > 0) { if (missingLanguages.size() > 0) {
MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK); MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK);
messageBox.setText(PreferencesMessages.LanguageMappings_missingLanguageTitle); messageBox.setText(PreferencesMessages.LanguageMappings_missingLanguageTitle);

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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 static final int LANGUAGE_COLUMN = 2;
private Map fConfigurationContentTypeMappings; private Map<String, Map<String, String>> fConfigurationContentTypeMappings;
public void setMappings(Map contentTypeMappings) { public void setMappings(Map<String, Map<String, String>> contentTypeMappings) {
fConfigurationContentTypeMappings = contentTypeMappings; fConfigurationContentTypeMappings = contentTypeMappings;
} }
public Map getContentTypeMappings() { public Map<String, Map<String, String>> getContentTypeMappings() {
return fConfigurationContentTypeMappings; return fConfigurationContentTypeMappings;
} }
@ -129,9 +129,9 @@ public class ProjectLanguageMappingWidget extends LanguageMappingWidget {
if (configuration == null) { if (configuration == null) {
configuration = ALL_CONFIGURATIONS; configuration = ALL_CONFIGURATIONS;
} }
Map contentTypeMappings = (Map) fConfigurationContentTypeMappings.get(configuration); Map<String, String> contentTypeMappings = fConfigurationContentTypeMappings.get(configuration);
if (contentTypeMappings == null) { if (contentTypeMappings == null) {
contentTypeMappings = new TreeMap(); contentTypeMappings = new TreeMap<String, String>();
fConfigurationContentTypeMappings.put(configuration, contentTypeMappings); fConfigurationContentTypeMappings.put(configuration, contentTypeMappings);
} }
contentTypeMappings.put(contentType, language); contentTypeMappings.put(contentType, language);
@ -163,7 +163,7 @@ public class ProjectLanguageMappingWidget extends LanguageMappingWidget {
configurationId = data.configuration.getId(); configurationId = data.configuration.getId();
} }
Map contentTypeMappings = (Map) fConfigurationContentTypeMappings.get(configurationId); Map<String, String> contentTypeMappings = fConfigurationContentTypeMappings.get(configurationId);
if (contentTypeMappings != null) { if (contentTypeMappings != null) {
contentTypeMappings.remove(contentType); contentTypeMappings.remove(contentType);
} }
@ -184,16 +184,16 @@ public class ProjectLanguageMappingWidget extends LanguageMappingWidget {
return fContents; return fContents;
} }
private Set createContentTypeFilter(Map mappings) { private Set<String> createContentTypeFilter(Map<String, Map<String, String>> mappings) {
Set filter = new HashSet(); Set<String> filter = new HashSet<String>();
Iterator configurationContentTypeMappings = mappings.entrySet().iterator(); Iterator<Entry<String, Map<String, String>>> configurationContentTypeMappings = mappings.entrySet().iterator();
while (configurationContentTypeMappings.hasNext()) { while (configurationContentTypeMappings.hasNext()) {
Entry entry = (Entry) configurationContentTypeMappings.next(); Entry<String, Map<String, String>> entry = configurationContentTypeMappings.next();
String configuration = (String) entry.getKey(); String configuration = entry.getKey();
Iterator contentTypeMappings = ((Map) entry.getValue()).entrySet().iterator(); Iterator<Entry<String, String>> contentTypeMappings = entry.getValue().entrySet().iterator();
while (contentTypeMappings.hasNext()) { while (contentTypeMappings.hasNext()) {
Entry contentTypeEntry = (Entry) contentTypeMappings.next(); Entry<String, String> contentTypeEntry = contentTypeMappings.next();
String contentType = (String) contentTypeEntry.getKey(); String contentType = contentTypeEntry.getKey();
filter.add(createFilterKey(configuration, contentType)); filter.add(createFilterKey(configuration, contentType));
} }
} }
@ -207,7 +207,7 @@ public class ProjectLanguageMappingWidget extends LanguageMappingWidget {
} }
fTable.removeAll(); fTable.removeAll();
Iterator mappings = fConfigurationContentTypeMappings.entrySet().iterator(); Iterator<Entry<String, Map<String, String>>> mappings = fConfigurationContentTypeMappings.entrySet().iterator();
IContentTypeManager contentTypeManager = Platform.getContentTypeManager(); IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
@ -215,16 +215,16 @@ public class ProjectLanguageMappingWidget extends LanguageMappingWidget {
ICProjectDescription description = CoreModel.getDefault().getProjectDescription(project, false); ICProjectDescription description = CoreModel.getDefault().getProjectDescription(project, false);
while (mappings.hasNext()) { while (mappings.hasNext()) {
Entry configurationEntry = (Entry) mappings.next(); Entry<String, Map<String, String>> configurationEntry = mappings.next();
String configurationId = (String) configurationEntry.getKey(); String configurationId = configurationEntry.getKey();
Iterator contentTypeMappings = ((Map) configurationEntry.getValue()).entrySet().iterator(); Iterator<Entry<String, String>> contentTypeMappings = configurationEntry.getValue().entrySet().iterator();
while (contentTypeMappings.hasNext()) { while (contentTypeMappings.hasNext()) {
Entry entry = (Entry) contentTypeMappings.next(); Entry<String, String> entry = contentTypeMappings.next();
TableItem item = new TableItem(fTable, SWT.NONE); TableItem item = new TableItem(fTable, SWT.NONE);
String contentType = (String) entry.getKey(); String contentType = entry.getKey();
String contentTypeName = contentTypeManager.getContentType(contentType).getName(); String contentTypeName = contentTypeManager.getContentType(contentType).getName();
String languageId = (String) entry.getValue(); String languageId = entry.getValue();
String languageName = LanguageManager.getInstance().getLanguage(languageId).getName(); String languageName = LanguageManager.getInstance().getLanguage(languageId).getName();
ICConfigurationDescription configuration = description.getConfigurationById(configurationId); ICConfigurationDescription configuration = description.getConfigurationById(configurationId);
@ -248,16 +248,16 @@ public class ProjectLanguageMappingWidget extends LanguageMappingWidget {
} }
if (fChild != null) { if (fChild != null) {
Set overrides = new HashSet(createWorkspaceContentTypeFilter(fConfigurationContentTypeMappings)); Set<String> overrides = new HashSet<String>(createWorkspaceContentTypeFilter(fConfigurationContentTypeMappings));
fChild.setOverriddenContentTypes(overrides); fChild.setOverriddenContentTypes(overrides);
fChild.refreshMappings(); fChild.refreshMappings();
} }
} }
private Set createWorkspaceContentTypeFilter(Map configurationContentTypeMappings) { private Set<String> createWorkspaceContentTypeFilter(Map<String, Map<String, String>> configurationContentTypeMappings) {
Map contentTypeMappings = (Map) configurationContentTypeMappings.get(ALL_CONFIGURATIONS); Map<String, String> contentTypeMappings = configurationContentTypeMappings.get(ALL_CONFIGURATIONS);
if (contentTypeMappings == null) { if (contentTypeMappings == null) {
return Collections.EMPTY_SET; return Collections.emptySet();
} }
return contentTypeMappings.keySet(); return contentTypeMappings.keySet();
} }

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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; import org.eclipse.cdt.internal.ui.preferences.PreferencesMessages;
public class WorkspaceContentTypeMappingDialog extends ContentTypeMappingDialog { public class WorkspaceContentTypeMappingDialog extends ContentTypeMappingDialog {
private Set fFilteredContentTypes; private Set<String> fFilteredContentTypes;
public WorkspaceContentTypeMappingDialog(Shell parentShell) { public WorkspaceContentTypeMappingDialog(Shell parentShell) {
super(parentShell); super(parentShell);
fFilteredContentTypes = Collections.EMPTY_SET; fFilteredContentTypes = Collections.emptySet();
} }
@Override @Override
@ -53,7 +53,7 @@ public class WorkspaceContentTypeMappingDialog extends ContentTypeMappingDialog
fContentType.addListener(SWT.Selection, new Listener() { fContentType.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) { public void handleEvent(Event event) {
fSelectedContentTypeName = fContentType.getText(); fSelectedContentTypeName = fContentType.getText();
fSelectedContentTypeID = (String) fContentTypeNamesToIDsMap.get(fSelectedContentTypeName); fSelectedContentTypeID = fContentTypeNamesToIDsMap.get(fSelectedContentTypeName);
getButton(IDialogConstants.OK_ID).setEnabled(isValidSelection()); getButton(IDialogConstants.OK_ID).setEnabled(isValidSelection());
} }
}); });
@ -67,7 +67,7 @@ public class WorkspaceContentTypeMappingDialog extends ContentTypeMappingDialog
fLanguage.addListener(SWT.Selection, new Listener() { fLanguage.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) { public void handleEvent(Event event) {
fSelectedLanguageName = fLanguage.getText(); fSelectedLanguageName = fLanguage.getText();
fSelectedLanguageID = (String) fLanguageNamesToIDsMap.get(fSelectedLanguageName); fSelectedLanguageID = fLanguageNamesToIDsMap.get(fSelectedLanguageName);
getButton(IDialogConstants.OK_ID).setEnabled(isValidSelection()); getButton(IDialogConstants.OK_ID).setEnabled(isValidSelection());
} }
}); });
@ -99,7 +99,7 @@ public class WorkspaceContentTypeMappingDialog extends ContentTypeMappingDialog
} }
} }
public void setContentTypeFilter(Set contentTypes) { public void setContentTypeFilter(Set<String> contentTypes) {
fFilteredContentTypes = contentTypes; fFilteredContentTypes = contentTypes;
} }

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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.CCorePlugin;
import org.eclipse.cdt.core.language.WorkspaceLanguageConfiguration; 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.core.model.LanguageManager;
import org.eclipse.cdt.internal.ui.preferences.PreferencesMessages; import org.eclipse.cdt.internal.ui.preferences.PreferencesMessages;
@ -52,8 +53,8 @@ public class WorkspaceLanguageMappingPreferencePage extends PreferencePage imple
private void fetchMappings() throws CoreException { private void fetchMappings() throws CoreException {
fMappings = LanguageManager.getInstance().getWorkspaceLanguageConfiguration(); fMappings = LanguageManager.getInstance().getWorkspaceLanguageConfiguration();
Map availableLanguages = LanguageVerifier.computeAvailableLanguages(); Map<String, ILanguage> availableLanguages = LanguageVerifier.computeAvailableLanguages();
Set missingLanguages = LanguageVerifier.removeMissingLanguages(fMappings, availableLanguages); Set<String> missingLanguages = LanguageVerifier.removeMissingLanguages(fMappings, availableLanguages);
if (missingLanguages.size() > 0) { if (missingLanguages.size() > 0) {
MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK); MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK);
messageBox.setText(PreferencesMessages.LanguageMappings_missingLanguageTitle); messageBox.setText(PreferencesMessages.LanguageMappings_missingLanguageTitle);

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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; import org.eclipse.cdt.internal.ui.util.Messages;
public class WorkspaceLanguageMappingWidget extends LanguageMappingWidget { public class WorkspaceLanguageMappingWidget extends LanguageMappingWidget {
private Map fContentTypeMappings; private Map<String, String> fContentTypeMappings;
public WorkspaceLanguageMappingWidget() { public WorkspaceLanguageMappingWidget() {
super(); super();
fContentTypeMappings = new TreeMap(); fContentTypeMappings = new TreeMap<String, String>();
} }
@Override @Override
@ -119,7 +119,7 @@ public class WorkspaceLanguageMappingWidget extends LanguageMappingWidget {
TableItem[] selection = fTable.getSelection(); TableItem[] selection = fTable.getSelection();
for (int i = 0; i < selection.length; i++) { 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); fContentTypeMappings.remove(contentType);
@ -147,18 +147,18 @@ public class WorkspaceLanguageMappingWidget extends LanguageMappingWidget {
} }
fTable.removeAll(); fTable.removeAll();
Iterator mappings = fContentTypeMappings.entrySet().iterator(); Iterator<Entry<String, String>> mappings = fContentTypeMappings.entrySet().iterator();
IContentTypeManager contentTypeManager = Platform.getContentTypeManager(); IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
while (mappings.hasNext()) { while (mappings.hasNext()) {
Entry entry = (Entry) mappings.next(); Entry<String, String> entry = mappings.next();
TableItem item = new TableItem(fTable, SWT.NONE); TableItem item = new TableItem(fTable, SWT.NONE);
String contentType = (String) entry.getKey(); String contentType = entry.getKey();
String contentTypeName = contentTypeManager.getContentType(contentType).getName(); 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)) { if (fOverriddenContentTypes.contains(contentType)) {
item.setText(0, Messages.format(PreferencesMessages.ProjectLanguagesPropertyPage_overriddenContentType, contentTypeName)); item.setText(0, Messages.format(PreferencesMessages.ProjectLanguagesPropertyPage_overriddenContentType, contentTypeName));
@ -170,18 +170,18 @@ public class WorkspaceLanguageMappingWidget extends LanguageMappingWidget {
} }
if (fChild != null) { if (fChild != null) {
Set overrides = new HashSet(fContentTypeMappings.keySet()); Set<String> overrides = new HashSet<String>(fContentTypeMappings.keySet());
overrides.addAll(fOverriddenContentTypes); overrides.addAll(fOverriddenContentTypes);
fChild.setOverriddenContentTypes(overrides); fChild.setOverriddenContentTypes(overrides);
fChild.refreshMappings(); fChild.refreshMappings();
} }
} }
public void setMappings(Map mappings) { public void setMappings(Map<String, String> mappings) {
fContentTypeMappings = new TreeMap(mappings); fContentTypeMappings = new TreeMap<String, String>(mappings);
} }
public Map getContentTypeMappings() { public Map<String, String> getContentTypeMappings() {
return Collections.unmodifiableMap(fContentTypeMappings); return Collections.unmodifiableMap(fContentTypeMappings);
} }
} }