1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 10:16:03 +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
* 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/*<String,Map<String,String>>*/ fConfigurationContentTypeMappings;
private Map<String,Map<String,String>> fConfigurationContentTypeMappings;
/**
* 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
* language mappings defined.
*/
public ProjectLanguageConfiguration() {
fConfigurationContentTypeMappings = new TreeMap();
fFileConfigurationMappings = new TreeMap();
fConfigurationContentTypeMappings = new TreeMap<String, Map<String, String>>();
fFileConfigurationMappings = new TreeMap<String, Map<String, String>>();
}
/**
* 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
* 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<String, String> 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 <code>configuration</code> is <code>null</code>, 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 <code>configuration</code> is <code>null</code>, 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<String, String> 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<String, String> contentTypeMappings = fConfigurationContentTypeMappings.get(configurationId);
if (contentTypeMappings == null) {
contentTypeMappings = new TreeMap();
contentTypeMappings = new TreeMap<String, String>();
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<String, String> 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<String, String> configurationMappings = fFileConfigurationMappings.get(filePath);
if (configurationMappings == null) {
configurationMappings = new TreeMap();
configurationMappings = new TreeMap<String, String>();
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<String, String> 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<String, Map<String, String>> 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<String, Map<String, String>> 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<String, Map<String, String>> 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<String, String> mappings) {
fFileConfigurationMappings.put(file.getProjectRelativePath().toPortableString(), new TreeMap<String, String>(mappings));
}
private Map copyLanguageMappings(Map mappings, boolean isReadOnly) {
Map result = new TreeMap();
Iterator entries = mappings.entrySet().iterator();
private Map<String, Map<String, String>> copyLanguageMappings(Map<String, Map<String, String>> mappings, boolean isReadOnly) {
Map<String, Map<String, String>> result = new TreeMap<String, Map<String, String>>();
Iterator<Entry<String, Map<String, String>>> entries = mappings.entrySet().iterator();
while (entries.hasNext()) {
Entry entry = (Entry) entries.next();
Map map = (Map) entry.getValue();
Entry<String, Map<String, String>> entry = entries.next();
Map<String, String> map = entry.getValue();
if (isReadOnly) {
map = Collections.unmodifiableMap(map);
} else {
map = new TreeMap(map);
map = new TreeMap<String, String>(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<String, Map<String, String>> mappings) {
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
* 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<String, String> fMappings;
/**
* Creates a new <code>WorkspaceLanguageConfiguration</code> with no
* language mappings defined.
*/
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
* mappings. The given mappings should be between content type ids
* (<code>String</code>) and language ids (<code>String</code>)
* @param projectMappings
* @param mappings
*/
public void setWorkspaceMappings(Map/*<String, String>*/ mappings) {
fMappings = new TreeMap(mappings);
public void setWorkspaceMappings(Map<String, String> mappings) {
fMappings = new TreeMap<String, String>(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<String, String> 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);
}
}

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
* 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<String, ILanguage> fLanguageCache = new HashMap<String, ILanguage>();
private Map<String, IPDOMLinkageFactory> fPDOMLinkageFactoryCache= new HashMap<String, IPDOMLinkageFactory>();
private Map fContentTypeToLanguageCache= new HashMap();
private Map fLanguageConfigurationCache = new HashMap();
private Map<String, ILanguage> fContentTypeToLanguageCache= new HashMap<String, ILanguage>();
private Map<IProject, ProjectLanguageConfiguration> fLanguageConfigurationCache = new HashMap<IProject, ProjectLanguageConfiguration>();
private boolean fIsFullyCached;
private HashMap fIdToLanguageDescriptorCache;//= new HashMap();
private HashMap fContentTypeToDescriptorListCache;
private HashMap<String, ILanguageDescriptor> fIdToLanguageDescriptorCache;//= new HashMap();
private HashMap<String, List<ILanguageDescriptor>> 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<String, ILanguageDescriptor> map = getDescriptorCache();
return map.get(id);
}
private HashMap getDescriptorCache(){
private HashMap<String, ILanguageDescriptor> 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<String, ILanguageDescriptor> map = getDescriptorCache();
return map.values().toArray(new ILanguageDescriptor[map.size()]);
}
private HashMap createDescriptorCache(){
HashMap map = new HashMap();
private HashMap<String, ILanguageDescriptor> createDescriptorCache(){
HashMap<String, ILanguageDescriptor> map = new HashMap<String, ILanguageDescriptor>();
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<String, List<ILanguageDescriptor>> 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<String, ILanguageDescriptor[]> getContentTypeIdToLanguageDescriptionsMap(){
HashMap<String, ILanguageDescriptor[]> map = new HashMap<String, ILanguageDescriptor[]>();
Map<String, List<ILanguageDescriptor>> cache = getContentTypeToDescriptorCache();
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){
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<String, List<ILanguageDescriptor>> createContentTypeToDescriptorCache(){
HashMap<String, List<ILanguageDescriptor>> map = new HashMap<String, List<ILanguageDescriptor>>();
Map<String, ILanguageDescriptor> dc = getDescriptorCache();
List list;
List<ILanguageDescriptor> list;
IContentType type;
String id;
for(Iterator iter = dc.values().iterator(); iter.hasNext();){
ILanguageDescriptor des = (ILanguageDescriptor)iter.next();
for(Iterator<ILanguageDescriptor> 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<ILanguageDescriptor>();
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/*<String>*/ getAllContentTypes() {
ArrayList/*<String>*/ allTypes = new ArrayList();
public ArrayList/*<String>*/<String> getAllContentTypes() {
ArrayList/*<String>*/<String> allTypes = new ArrayList<String>();
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<String> contentTypes= collectContentTypeIds();
return contentTypes.toArray(new String[contentTypes.size()]);
}
private Set collectContentTypeIds() {
HashSet/*<String>*/ allTypes = new HashSet();
private Set<String> collectContentTypeIds() {
HashSet/*<String>*/<String> allTypes = new HashSet<String>();
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<ILanguage> 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 <code>null</code> if build configurations
* 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
* @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);
}

View file

@ -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<LanguageMapping> inheritedLanguages = new LinkedList<LanguageMapping>();
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<LanguageMapping> inheritedLanguages) {
LanguageMapping[] results = new LanguageMapping[inheritedLanguages.size()];
Iterator mappings = inheritedLanguages.iterator();
Iterator<LanguageMapping> mappings = inheritedLanguages.iterator();
int i = 0;
while (mappings.hasNext()) {
LanguageMapping mapping = (LanguageMapping) mappings.next();
LanguageMapping mapping = mappings.next();
results[i] = mapping;
i++;
}

View file

@ -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<String, Map<String, String>> decodeProjectContentTypeMappings(Element rootElement) {
Map<String, Map<String, String>> decodedMappings = new TreeMap<String, Map<String, String>>();
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<String, String> contentTypeMappings = decodedMappings.get(configuration);
if (contentTypeMappings == null) {
contentTypeMappings = new TreeMap();
contentTypeMappings = new TreeMap<String, String>();
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<String, String> 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<String, Map<String, String>> decodeFileMappings(Element rootElement) throws CoreException {
Map<String, Map<String, String>> decodedMappings = new TreeMap<String, Map<String, String>>();
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<String, String> configurationMappings = decodedMappings.get(path);
if (configurationMappings == null) {
configurationMappings = new TreeMap();
configurationMappings = new TreeMap<String, String>();
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<String, String> decodeMappings(Element rootElement, String category, String keyName, String valueName) {
Map<String, String> decodedMappings = new TreeMap<String, String>();
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<String, Map<String, String>> contentTypeMappings, Element rootElement) {
Document document = rootElement.getOwnerDocument();
Iterator entries = contentTypeMappings.entrySet().iterator();
Iterator<Entry<String, Map<String, String>>> entries = contentTypeMappings.entrySet().iterator();
while (entries.hasNext()) {
Entry entry = (Entry) entries.next();
Entry<String, Map<String, String>> entry = entries.next();
String configuration = (String) entry.getKey();
Iterator contentTypeEntries = ((Map) entry.getValue()).entrySet().iterator();
String configuration = entry.getKey();
Iterator<Entry<String, String>> contentTypeEntries = entry.getValue().entrySet().iterator();
while (contentTypeEntries.hasNext()) {
Entry configurationEntry = (Entry) contentTypeEntries.next();
String contentType = (String) configurationEntry.getKey();
String language = (String) configurationEntry.getValue();
Entry<String, String> 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<String, String> mappings, Element rootElement, String category, String keyName, String valueName) {
Document document = rootElement.getOwnerDocument();
Iterator entries = mappings.entrySet().iterator();
Iterator<Entry<String, String>> entries = mappings.entrySet().iterator();
while (entries.hasNext()) {
Entry entry = (Entry) entries.next();
Entry<String, String> 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<String, String> 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<String, Map<String, String>> mappings, Element rootElement) {
Document document = rootElement.getOwnerDocument();
Iterator entries = mappings.entrySet().iterator();
Iterator<Entry<String, Map<String, String>>> entries = mappings.entrySet().iterator();
while (entries.hasNext()) {
Entry entry = (Entry) entries.next();
Entry<String, Map<String, String>> 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<Entry<String, String>> configurationEntries = entry.getValue().entrySet().iterator();
while (configurationEntries.hasNext()) {
Entry configurationEntry = (Entry) configurationEntries.next();
String configuration = (String) configurationEntry.getKey();
String language = (String) configurationEntry.getValue();
Entry<String, String> configurationEntry = configurationEntries.next();
String configuration = configurationEntry.getKey();
String language = configurationEntry.getValue();
mapping.setAttribute(ATTRIBUTE_PATH, path);
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
* 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<String, String> fContentTypeNamesToIDsMap;
HashMap<String, String> fLanguageNamesToIDsMap;
public ContentTypeMappingDialog(Shell parentShell) {
super(parentShell);
fContentTypeNamesToIDsMap = new HashMap();
fLanguageNamesToIDsMap = new HashMap();
fContentTypeNamesToIDsMap = new HashMap<String, String>();
fLanguageNamesToIDsMap = new HashMap<String, String>();
}
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
* 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<String, ILanguage> 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<String> 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<String, String> mappings = new TreeMap<String, String>();
TableItem[] items = fTable.getItems();
for (int i = 0; i < items.length; 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
* 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<String, String> fContentTypeNamesToIDsMap;
protected Set<IContentType> fAffectedContentTypes;
protected Font fOverriddenFont;
protected LanguageMappingWidget fChild;
protected IAdaptable fElement;
protected Set fOverriddenContentTypes;
protected Set<String> 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, String>();
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<IContentType>();
}
public IAdaptable getElement() {
@ -77,12 +77,12 @@ public abstract class LanguageMappingWidget {
fElement = element;
}
public void setOverriddenContentTypes(Set contentTypes) {
public void setOverriddenContentTypes(Set<String> 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) {

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
* 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<String, ILanguage> computeAvailableLanguages() {
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++) {
languages.put(registeredLanguages[i].getId(), registeredLanguages[i]);
}
return languages;
}
public static String computeAffectedLanguages(Set missingLanguages) {
Iterator languages = missingLanguages.iterator();
public static String computeAffectedLanguages(Set<String> missingLanguages) {
Iterator<String> 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<String> removeMissingLanguages(ProjectLanguageConfiguration config, ICProjectDescription description, Map<String, ILanguage> availableLanguages) {
Set<String> missingLanguages = new TreeSet<String>();
// Check file mappings
Iterator fileConfigurationMappings = config.getFileMappings().entrySet().iterator();
Iterator<Entry<String, Map<String, String>>> 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<String, Map<String, String>> entry = fileConfigurationMappings.next();
String path = entry.getKey();
Map<String, String> configurationLanguageMappings = entry.getValue();
Iterator<Entry<String, String>> mappings = configurationLanguageMappings.entrySet().iterator();
while (mappings.hasNext()) {
Entry mapping = (Entry) mappings.next();
String configurationId = (String) mapping.getKey();
String languageId = (String) mapping.getValue();
Entry<String, String> 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<Entry<String, Map<String, String>>> 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<String, Map<String, String>> entry = configurationContentTypeMappings.next();
String configurationId = entry.getKey();
Map<String, String> contentTypeLanguageMappings = entry.getValue();
Iterator<Entry<String, String>> mappings = contentTypeLanguageMappings.entrySet().iterator();
while (mappings.hasNext()) {
Entry mapping = (Entry) mappings.next();
String contentTypeId = (String) mapping.getKey();
String languageId = (String) mapping.getValue();
Entry<String, String> 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<String> removeMissingLanguages(WorkspaceLanguageConfiguration config, Map<String, ILanguage> availableLanguages) {
Set<String> missingLanguages = new TreeSet<String>();
// Check content type mappings
Iterator contentTypeMappings = config.getWorkspaceMappings().entrySet().iterator();
Iterator<Entry<String, String>> contentTypeMappings = config.getWorkspaceMappings().entrySet().iterator();
while (contentTypeMappings.hasNext()) {
Entry entry = (Entry) contentTypeMappings.next();
String contentTypeId = (String) entry.getKey();
String languageId = (String) entry.getValue();
Entry<String, String> entry = contentTypeMappings.next();
String contentTypeId = entry.getKey();
String languageId = entry.getValue();
if (!availableLanguages.containsKey(languageId)) {
missingLanguages.add(languageId);
config.removeWorkspaceMapping(contentTypeId);

View file

@ -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<String> 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<String> 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
* 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<String, ILanguage> availableLanguages = LanguageVerifier.computeAvailableLanguages();
Set<String> 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<String, ILanguage> availableLanguages = LanguageVerifier.computeAvailableLanguages();
Set<String> missingLanguages = LanguageVerifier.removeMissingLanguages(workspaceMappings, availableLanguages);
if (missingLanguages.size() > 0) {
MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK);
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
* 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<String, Map<String, String>> fConfigurationContentTypeMappings;
public void setMappings(Map contentTypeMappings) {
public void setMappings(Map<String, Map<String, String>> contentTypeMappings) {
fConfigurationContentTypeMappings = contentTypeMappings;
}
public Map getContentTypeMappings() {
public Map<String, Map<String, String>> 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<String, String> contentTypeMappings = fConfigurationContentTypeMappings.get(configuration);
if (contentTypeMappings == null) {
contentTypeMappings = new TreeMap();
contentTypeMappings = new TreeMap<String, String>();
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<String, String> 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<String> createContentTypeFilter(Map<String, Map<String, String>> mappings) {
Set<String> filter = new HashSet<String>();
Iterator<Entry<String, Map<String, String>>> 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<String, Map<String, String>> entry = configurationContentTypeMappings.next();
String configuration = entry.getKey();
Iterator<Entry<String, String>> contentTypeMappings = entry.getValue().entrySet().iterator();
while (contentTypeMappings.hasNext()) {
Entry contentTypeEntry = (Entry) contentTypeMappings.next();
String contentType = (String) contentTypeEntry.getKey();
Entry<String, String> 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<Entry<String, Map<String, String>>> 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<String, Map<String, String>> configurationEntry = mappings.next();
String configurationId = configurationEntry.getKey();
Iterator<Entry<String, String>> contentTypeMappings = configurationEntry.getValue().entrySet().iterator();
while (contentTypeMappings.hasNext()) {
Entry entry = (Entry) contentTypeMappings.next();
Entry<String, String> 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<String> overrides = new HashSet<String>(createWorkspaceContentTypeFilter(fConfigurationContentTypeMappings));
fChild.setOverriddenContentTypes(overrides);
fChild.refreshMappings();
}
}
private Set createWorkspaceContentTypeFilter(Map configurationContentTypeMappings) {
Map contentTypeMappings = (Map) configurationContentTypeMappings.get(ALL_CONFIGURATIONS);
private Set<String> createWorkspaceContentTypeFilter(Map<String, Map<String, String>> configurationContentTypeMappings) {
Map<String, String> contentTypeMappings = configurationContentTypeMappings.get(ALL_CONFIGURATIONS);
if (contentTypeMappings == null) {
return Collections.EMPTY_SET;
return Collections.emptySet();
}
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
* 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<String> 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<String> 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
* 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<String, ILanguage> availableLanguages = LanguageVerifier.computeAvailableLanguages();
Set<String> missingLanguages = LanguageVerifier.removeMissingLanguages(fMappings, availableLanguages);
if (missingLanguages.size() > 0) {
MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK);
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
* 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<String, String> fContentTypeMappings;
public WorkspaceLanguageMappingWidget() {
super();
fContentTypeMappings = new TreeMap();
fContentTypeMappings = new TreeMap<String, String>();
}
@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<Entry<String, String>> mappings = fContentTypeMappings.entrySet().iterator();
IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
while (mappings.hasNext()) {
Entry entry = (Entry) mappings.next();
Entry<String, String> 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<String> overrides = new HashSet<String>(fContentTypeMappings.keySet());
overrides.addAll(fOverriddenContentTypes);
fChild.setOverriddenContentTypes(overrides);
fChild.refreshMappings();
}
}
public void setMappings(Map mappings) {
fContentTypeMappings = new TreeMap(mappings);
public void setMappings(Map<String, String> mappings) {
fContentTypeMappings = new TreeMap<String, String>(mappings);
}
public Map getContentTypeMappings() {
public Map<String, String> getContentTypeMappings() {
return Collections.unmodifiableMap(fContentTypeMappings);
}
}