mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 09:16:02 +02:00
cosmetics: generics
This commit is contained in:
parent
f766cfa76c
commit
a62de2fbe6
10 changed files with 53 additions and 46 deletions
|
@ -17,6 +17,8 @@ import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
|||
* A storage where stored data is organized by "kind".
|
||||
* In most cases kind is one of {@link ICLanguageSettingEntry}, i.e. include path, macro etc.
|
||||
*
|
||||
* @param <T> - stored type
|
||||
*
|
||||
* @see ICSettingEntry#INCLUDE_PATH
|
||||
* @see ICSettingEntry#INCLUDE_FILE
|
||||
* @see ICSettingEntry#MACRO
|
||||
|
@ -27,7 +29,7 @@ import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
|||
* @see ICSettingEntry#SOURCE_PATH
|
||||
*
|
||||
*/
|
||||
public class KindBasedStore<TypeStored> implements Cloneable {
|
||||
public class KindBasedStore<T> implements Cloneable {
|
||||
private static final int INDEX_INCLUDE_PATH = 0;
|
||||
private static final int INDEX_INCLUDE_FILE = 1;
|
||||
private static final int INDEX_MACRO = 2;
|
||||
|
@ -149,19 +151,19 @@ public class KindBasedStore<TypeStored> implements Cloneable {
|
|||
throw new IllegalArgumentException(UtilMessages.getString("KindBasedStore.1")); //$NON-NLS-1$
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public TypeStored get(int kind){
|
||||
return (TypeStored) fEntryStorage[kindToIndex(kind)];
|
||||
public T get(int kind){
|
||||
return (T) fEntryStorage[kindToIndex(kind)];
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public TypeStored put(int kind, TypeStored object){
|
||||
public T put(int kind, T object){
|
||||
int index = kindToIndex(kind);
|
||||
TypeStored old = (TypeStored) fEntryStorage[index];
|
||||
@SuppressWarnings("unchecked")
|
||||
T old = (T) fEntryStorage[index];
|
||||
fEntryStorage[index] = object;
|
||||
return old;
|
||||
}
|
||||
|
||||
private class KindBasedInfo implements IKindBasedInfo {
|
||||
private class KindBasedInfo implements IKindBasedInfo<T> {
|
||||
int fIdex;
|
||||
int fKind;
|
||||
|
||||
|
@ -175,31 +177,35 @@ public class KindBasedStore<TypeStored> implements Cloneable {
|
|||
}
|
||||
}
|
||||
|
||||
public Object getInfo() {
|
||||
return fEntryStorage[fIdex];
|
||||
public T getInfo() {
|
||||
@SuppressWarnings("unchecked")
|
||||
T info = (T)fEntryStorage[fIdex];
|
||||
return info;
|
||||
}
|
||||
|
||||
public int getKind() {
|
||||
return fKind;
|
||||
}
|
||||
|
||||
public Object setInfo(Object newInfo) {
|
||||
Object old = fEntryStorage[fIdex];
|
||||
public T setInfo(T newInfo) {
|
||||
@SuppressWarnings("unchecked")
|
||||
T old = (T)fEntryStorage[fIdex];
|
||||
fEntryStorage[fIdex] = newInfo;
|
||||
return old;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public IKindBasedInfo[] getContents(){
|
||||
IKindBasedInfo infos[] = new IKindBasedInfo[fEntryStorage.length];
|
||||
public IKindBasedInfo<T>[] getContents(){
|
||||
@SuppressWarnings("unchecked")
|
||||
IKindBasedInfo<T> infos[] = new IKindBasedInfo[fEntryStorage.length];
|
||||
for(int i = 0; i < fEntryStorage.length; i++){
|
||||
infos[i] = new KindBasedInfo(i, false);
|
||||
}
|
||||
return infos;
|
||||
}
|
||||
|
||||
public IKindBasedInfo getInfo(int kind){
|
||||
public IKindBasedInfo<T> getInfo(int kind){
|
||||
return new KindBasedInfo(kind, true);
|
||||
}
|
||||
|
||||
|
@ -213,7 +219,7 @@ public class KindBasedStore<TypeStored> implements Cloneable {
|
|||
public Object clone() {
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
KindBasedStore<TypeStored> clone = (KindBasedStore<TypeStored>)super.clone();
|
||||
KindBasedStore<T> clone = (KindBasedStore<T>)super.clone();
|
||||
clone.fEntryStorage = fEntryStorage.clone();
|
||||
return clone;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
|
|
|
@ -15,15 +15,15 @@ import java.util.List;
|
|||
public class PathEntryResolveInfo {
|
||||
private PathEntryResolveInfoElement[] fElements;
|
||||
|
||||
public PathEntryResolveInfo(List list){
|
||||
public PathEntryResolveInfo(List<PathEntryResolveInfoElement> list){
|
||||
if(list != null){
|
||||
fElements = (PathEntryResolveInfoElement[])list.toArray(new PathEntryResolveInfoElement[list.size()]);
|
||||
fElements = list.toArray(new PathEntryResolveInfoElement[list.size()]);
|
||||
} else {
|
||||
fElements = new PathEntryResolveInfoElement[0];
|
||||
}
|
||||
}
|
||||
|
||||
public PathEntryResolveInfoElement[] getElements(){
|
||||
return (PathEntryResolveInfoElement[])fElements.clone();
|
||||
return fElements.clone();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Intel Corporation and others.
|
||||
* Copyright (c) 2007, 2010 Intel 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
|
||||
|
@ -26,7 +26,7 @@ public class PathEntryResolveInfoElement {
|
|||
fResolvedEntries = new IPathEntry[0];
|
||||
}
|
||||
|
||||
public PathEntryResolveInfoElement(IPathEntry rawEntry, List resolvedList){
|
||||
public PathEntryResolveInfoElement(IPathEntry rawEntry, List<IPathEntry> resolvedList){
|
||||
fRawEntry = rawEntry;
|
||||
if(resolvedList != null){
|
||||
fResolvedEntries = new IPathEntry[resolvedList.size()];
|
||||
|
@ -41,6 +41,6 @@ public class PathEntryResolveInfoElement {
|
|||
public IPathEntry[] getResolvedEntries(){
|
||||
if(fResolvedEntries == null)
|
||||
return new IPathEntry[0];
|
||||
return (IPathEntry[])fResolvedEntries.clone();
|
||||
return fResolvedEntries.clone();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Intel Corporation and others.
|
||||
* Copyright (c) 2007, 2010 Intel 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
|
||||
|
@ -44,8 +44,8 @@ public class CExternalSettingSerializer {
|
|||
if(tmp != null)
|
||||
exts = CDataUtil.stringToArray(tmp, SEPARATOR);
|
||||
|
||||
List entriesList = LanguageSettingEntriesSerializer.loadEntriesList(element, KindBasedStore.ORED_LANG_ENTRY_KINDS);
|
||||
ICSettingEntry[] entries = (ICSettingEntry[])entriesList.toArray(new ICSettingEntry[entriesList.size()]);
|
||||
List<ICSettingEntry> entriesList = LanguageSettingEntriesSerializer.loadEntriesList(element, KindBasedStore.ORED_LANG_ENTRY_KINDS);
|
||||
ICSettingEntry[] entries = entriesList.toArray(new ICSettingEntry[entriesList.size()]);
|
||||
return new CExternalSetting(langIds, cTypeIds, exts, entries);
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ public class CProjectConverterDesciptor {
|
|||
if(supportedIds != null){
|
||||
IProjectDescription eDes = project.getDescription();
|
||||
String natures[] = eDes.getNatureIds();
|
||||
Set natureSet = new HashSet(Arrays.asList(natures));
|
||||
Set<String> natureSet = new HashSet<String>(Arrays.asList(natures));
|
||||
natureSet.removeAll(Arrays.asList(supportedIds));
|
||||
if(natureSet.size() == natures.length)
|
||||
return false;
|
||||
|
|
|
@ -40,7 +40,7 @@ public class CfgProxyCache implements IProxyCache {
|
|||
if(proxy != null)
|
||||
fProxyMap.put(proxy.getId(),proxy);
|
||||
else if(oldValue != null){
|
||||
fProxyMap.remove((CDataProxy)oldValue);
|
||||
fProxyMap.remove(oldValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,6 +82,7 @@ public class CfgProxyCache implements IProxyCache {
|
|||
removeCachedProxy(proxy);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, CDataProxy> getCachedProxiesMap() {
|
||||
return (Map<String, CDataProxy>)fProxyMap.clone();
|
||||
}
|
||||
|
|
|
@ -21,12 +21,12 @@ public class ConfigBasedPathEntryContainer implements IPathEntryContainer {
|
|||
public static final IPath CONTAINER_PATH = new Path("org.eclipse.cdt.core.CFG_BASED_CONTAINER"); //$NON-NLS-1$
|
||||
private IPathEntry[] fEntries;
|
||||
|
||||
public ConfigBasedPathEntryContainer(List list){
|
||||
this.fEntries = (IPathEntry[])list.toArray(new IPathEntry[list.size()]);
|
||||
public ConfigBasedPathEntryContainer(List<IPathEntry> list){
|
||||
this.fEntries = list.toArray(new IPathEntry[list.size()]);
|
||||
}
|
||||
|
||||
public ConfigBasedPathEntryContainer(IPathEntry entries[]){
|
||||
this.fEntries = (IPathEntry[])entries.clone();
|
||||
this.fEntries = entries.clone();
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
|
@ -38,7 +38,7 @@ public class ConfigBasedPathEntryContainer implements IPathEntryContainer {
|
|||
}
|
||||
|
||||
public IPathEntry[] getPathEntries() {
|
||||
return (IPathEntry[])fEntries.clone();
|
||||
return fEntries.clone();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.eclipse.cdt.core.settings.model.util.KindBasedStore;
|
|||
|
||||
class EntriesNamesContainer {
|
||||
// private String fLanguageSettingsId;
|
||||
private KindBasedStore fRemovedEntryNamesStore = new KindBasedStore();
|
||||
private KindBasedStore<Set<String>> fRemovedEntryNamesStore = new KindBasedStore<Set<String>>();
|
||||
|
||||
// EntriesNamesContainer(ICLanguageSetting setting) {
|
||||
// fLanguageSettingsId = setting.getId();
|
||||
|
@ -30,11 +30,11 @@ class EntriesNamesContainer {
|
|||
|
||||
public EntriesNamesContainer(EntriesNamesContainer base) {
|
||||
// fLanguageSettingsId = base.fLanguageSettingsId;
|
||||
IKindBasedInfo infos[] = base.fRemovedEntryNamesStore.getContents();
|
||||
IKindBasedInfo<Set<String>> infos[] = base.fRemovedEntryNamesStore.getContents();
|
||||
for(int i = 0; i < infos.length; i++){
|
||||
Set set = (Set)infos[i].getInfo();
|
||||
Set<String> set = infos[i].getInfo();
|
||||
if(set != null)
|
||||
fRemovedEntryNamesStore.put(infos[i].getKind(), new HashSet(set));
|
||||
fRemovedEntryNamesStore.put(infos[i].getKind(), new HashSet<String>(set));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,10 +42,10 @@ class EntriesNamesContainer {
|
|||
// return fLanguageSettingsId;
|
||||
//o }
|
||||
|
||||
private Set getRemovedNamesSet(int kind, boolean create){
|
||||
Set set = (Set)fRemovedEntryNamesStore.get(kind);
|
||||
private Set<String> getRemovedNamesSet(int kind, boolean create){
|
||||
Set<String> set = fRemovedEntryNamesStore.get(kind);
|
||||
if(set == null && create){
|
||||
set = new HashSet();
|
||||
set = new HashSet<String>();
|
||||
fRemovedEntryNamesStore.put(kind, set);
|
||||
}
|
||||
return set;
|
||||
|
@ -60,7 +60,7 @@ class EntriesNamesContainer {
|
|||
}
|
||||
|
||||
public boolean contains(int kind, String name){
|
||||
Set set = getRemovedNamesSet(kind, false);
|
||||
Set<String> set = getRemovedNamesSet(kind, false);
|
||||
if(set != null)
|
||||
return set.contains(name);
|
||||
return false;
|
||||
|
@ -71,7 +71,7 @@ class EntriesNamesContainer {
|
|||
}
|
||||
|
||||
public boolean remove(int kind, String name){
|
||||
Set set = getRemovedNamesSet(kind, false);
|
||||
Set<String> set = getRemovedNamesSet(kind, false);
|
||||
if(set != null)
|
||||
return set.remove(name);
|
||||
return false;
|
||||
|
@ -81,13 +81,13 @@ class EntriesNamesContainer {
|
|||
if(names == null || names.length == 0) {
|
||||
clear(kind);
|
||||
} else {
|
||||
Set set = getRemovedNamesSet(kind, true);
|
||||
Set<String> set = getRemovedNamesSet(kind, true);
|
||||
set.clear();
|
||||
add(set, names);
|
||||
}
|
||||
}
|
||||
|
||||
private static void add(Set set, String names[]){
|
||||
private static void add(Set<String> set, String names[]){
|
||||
for(int i = 0; i < names.length; i++){
|
||||
set.add(names[i]);
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ class EntriesNamesContainer {
|
|||
if(names == null || names.length == 0) {
|
||||
return;
|
||||
} else {
|
||||
Set set = getRemovedNamesSet(kind, true);
|
||||
Set<String> set = getRemovedNamesSet(kind, true);
|
||||
add(set, names);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Intel Corporation and others.
|
||||
* Copyright (c) 2007, 2010 Intel 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
|
||||
|
@ -17,7 +17,7 @@ import org.eclipse.cdt.core.settings.model.extension.CDataObject;
|
|||
public interface IProxyCache {
|
||||
CDataProxy[] getCachedProxies();
|
||||
|
||||
Map getCachedProxiesMap();
|
||||
Map<String, CDataProxy> getCachedProxiesMap();
|
||||
|
||||
CDataProxy getCachedProxy(String id);
|
||||
|
||||
|
|
|
@ -255,7 +255,7 @@ public class PathEntryConfigurationDataProvider extends
|
|||
ICProject cproject = manager.create(project);
|
||||
IPathEntry[] curRawEntries = PathEntryManager.getDefault().getRawPathEntries(cproject);
|
||||
|
||||
List list = new ArrayList();
|
||||
List<IPathEntry> list = new ArrayList<IPathEntry>();
|
||||
list.addAll(Arrays.asList(entries));
|
||||
for(int i = 0; i < curRawEntries.length; i++){
|
||||
if(curRawEntries[i].getEntryKind() == IPathEntry.CDT_CONTAINER){
|
||||
|
@ -263,7 +263,7 @@ public class PathEntryConfigurationDataProvider extends
|
|||
}
|
||||
}
|
||||
|
||||
IPathEntry[] newEntries = (IPathEntry[])list.toArray(new IPathEntry[list.size()]);
|
||||
IPathEntry[] newEntries = list.toArray(new IPathEntry[list.size()]);
|
||||
PathEntryManager.getDefault().setRawPathEntries(cproject, newEntries, new NullProgressMonitor());
|
||||
return createData(des, base, false, false);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue