1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

compilation warnings

This commit is contained in:
Andrew Gvozdev 2010-04-29 04:18:37 +00:00
parent 27674723aa
commit 4790e5993f

View file

@ -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 * 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
@ -12,11 +12,13 @@ package org.eclipse.cdt.make.internal.core.scannerconfig;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICSettingBase; import org.eclipse.cdt.core.settings.model.ICSettingBase;
@ -75,7 +77,7 @@ public class CDataDiscoveredInfoCalculator {
} }
private static class RcSettingInfo implements IRcSettingInfo{ private static class RcSettingInfo implements IRcSettingInfo{
private ArrayList fLangInfoList; private ArrayList<ILangSettingInfo> fLangInfoList;
private CResourceData fRcData; private CResourceData fRcData;
RcSettingInfo(CResourceData rcData){ RcSettingInfo(CResourceData rcData){
@ -84,7 +86,7 @@ public class CDataDiscoveredInfoCalculator {
public ILangSettingInfo[] getLangInfos() { public ILangSettingInfo[] getLangInfos() {
if(fLangInfoList != null && fLangInfoList.size() != 0) if(fLangInfoList != null && fLangInfoList.size() != 0)
return (ILangSettingInfo[])fLangInfoList.toArray(new ILangSettingInfo[fLangInfoList.size()]); return fLangInfoList.toArray(new ILangSettingInfo[fLangInfoList.size()]);
return new ILangSettingInfo[0]; return new ILangSettingInfo[0];
} }
@ -94,7 +96,7 @@ public class CDataDiscoveredInfoCalculator {
void add(ILangSettingInfo info){ void add(ILangSettingInfo info){
if(fLangInfoList == null) if(fLangInfoList == null)
fLangInfoList = new ArrayList(); fLangInfoList = new ArrayList<ILangSettingInfo>();
fLangInfoList.add(info); fLangInfoList.add(info);
} }
} }
@ -120,19 +122,21 @@ public class CDataDiscoveredInfoCalculator {
private static class ListIndexStore { private static class ListIndexStore {
private int fMaxIndex; private int fMaxIndex;
private List[] fStore; private List<PathFilePathInfo>[] fStore;
public ListIndexStore(int size){ public ListIndexStore(int size){
if(size < 0) if(size < 0)
size = 0; size = 0;
fStore = new List[size]; @SuppressWarnings("unchecked")
List<PathFilePathInfo>[] lists = new List[size];
fStore = lists;
} }
public void add(int index, Object value){ public void add(int index, PathFilePathInfo value){
List list = checkResize(index) ? new ArrayList() : fStore[index]; List<PathFilePathInfo> list = checkResize(index) ? new ArrayList<PathFilePathInfo>() : fStore[index];
if(list == null){ if(list == null){
list = new ArrayList(); list = new ArrayList<PathFilePathInfo>();
fStore[index] = list; fStore[index] = list;
} }
@ -145,7 +149,8 @@ public class CDataDiscoveredInfoCalculator {
private boolean checkResize(int index){ private boolean checkResize(int index){
if(index >= fStore.length){ if(index >= fStore.length){
int newSize = ++index; int newSize = ++index;
List resized[] = new List[newSize]; @SuppressWarnings("unchecked")
List<PathFilePathInfo> resized[] = new List[newSize];
if(fStore != null && fStore.length != 0){ if(fStore != null && fStore.length != 0){
System.arraycopy(fStore, 0, resized, 0, fStore.length); System.arraycopy(fStore, 0, resized, 0, fStore.length);
} }
@ -155,17 +160,19 @@ public class CDataDiscoveredInfoCalculator {
return false; return false;
} }
public List[] getLists(){ public List<PathFilePathInfo>[] getLists(){
int size = fMaxIndex + 1; int size = fMaxIndex + 1;
List list = new ArrayList(size); List<List<PathFilePathInfo>> list = new ArrayList<List<PathFilePathInfo>>(size);
List l; List<PathFilePathInfo> l;
for(int i = 0; i < size; i++){ for(int i = 0; i < size; i++){
l = fStore[i]; l = fStore[i];
if(l != null) if(l != null)
list.add(l); list.add(l);
} }
return (List[])list.toArray(new List[list.size()]); @SuppressWarnings("unchecked")
List<PathFilePathInfo>[] lists = list.toArray(new List[list.size()]);
return lists;
} }
} }
@ -183,11 +190,11 @@ public class CDataDiscoveredInfoCalculator {
// String[] fExts; // String[] fExts;
// HashSet fExtsSet; // HashSet fExtsSet;
private ExtsSet fExtsSet; private ExtsSet fExtsSet;
Map fPathFilePathInfoMap; Map<PathInfo, List<PathFilePathInfo>> fPathFilePathInfoMap;
CLanguageData fBaseLangData; CLanguageData fBaseLangData;
boolean fIsDerived; boolean fIsDerived;
private PathInfo fMaxMatchInfo; private PathInfo fMaxMatchInfo;
private List fMaxMatchInfoList; private List<PathFilePathInfo> fMaxMatchInfoList;
private int fHash; private int fHash;
public ExtsSetSettings(CLanguageData baseLangData, ExtsSet extsSet, boolean isDerived) { public ExtsSetSettings(CLanguageData baseLangData, ExtsSet extsSet, boolean isDerived) {
@ -198,31 +205,23 @@ public class CDataDiscoveredInfoCalculator {
void add(ExtsSetSettings setting){ void add(ExtsSetSettings setting){
if(setting.fPathFilePathInfoMap != null){ if(setting.fPathFilePathInfoMap != null){
List list; Collection<List<PathFilePathInfo>> infoLists = setting.fPathFilePathInfoMap.values();
int size; for (List<PathFilePathInfo> infoList : infoLists) {
for(Iterator iter = setting.fPathFilePathInfoMap.values().iterator(); iter.hasNext();){ for (PathFilePathInfo info : infoList) {
list = (List)iter.next(); add(info);
size = list.size();
for(int i = 0; i < size; i++){
add((PathFilePathInfo)list.get(i));
} }
} }
} }
} }
void updateLangData(CLanguageData lData, boolean isDerived){
fBaseLangData = lData;
fIsDerived = lData != null ? isDerived : false;
}
public void add(PathFilePathInfo pInfo){ public void add(PathFilePathInfo pInfo){
if(fPathFilePathInfoMap == null) if(fPathFilePathInfoMap == null)
fPathFilePathInfoMap = new HashMap(3); fPathFilePathInfoMap = new HashMap<PathInfo, List<PathFilePathInfo>>(3);
PathInfo fileInfo = pInfo.fInfo; PathInfo fileInfo = pInfo.fInfo;
List list = fileInfo == fMaxMatchInfo ? fMaxMatchInfoList : (List)fPathFilePathInfoMap.get(fileInfo); List<PathFilePathInfo> list = fileInfo == fMaxMatchInfo ? fMaxMatchInfoList : fPathFilePathInfoMap.get(fileInfo);
if(list == null){ if(list == null){
list = new ArrayList(); list = new ArrayList<PathFilePathInfo>();
fPathFilePathInfoMap.put(fileInfo, list); fPathFilePathInfoMap.put(fileInfo, list);
if(fMaxMatchInfo == null){ if(fMaxMatchInfo == null){
fMaxMatchInfo = fileInfo; fMaxMatchInfo = fileInfo;
@ -246,10 +245,7 @@ public class CDataDiscoveredInfoCalculator {
return fPathFilePathInfoMap != null && fPathFilePathInfoMap.size() > 1; return fPathFilePathInfoMap != null && fPathFilePathInfoMap.size() > 1;
} }
public PathInfo getMaxMatchPathInfo(){ @Override
return fMaxMatchInfo;
}
public boolean equals(Object obj) { public boolean equals(Object obj) {
if(obj == this) if(obj == this)
return true; return true;
@ -273,6 +269,7 @@ public class CDataDiscoveredInfoCalculator {
return true; return true;
} }
@Override
public int hashCode() { public int hashCode() {
int hash = fHash; int hash = fHash;
if(hash == 0){ if(hash == 0){
@ -294,13 +291,14 @@ public class CDataDiscoveredInfoCalculator {
private static class ExtsSet { private static class ExtsSet {
private String[] fExts; private String[] fExts;
private HashSet fExtsSet; private HashSet<String> fExtsSet;
private int fHash; private int fHash;
public ExtsSet(String[] exts){ public ExtsSet(String[] exts){
fExts = exts == null || exts.length == 0 ? EMPTY_STRING_ARRAY : (String[])exts.clone(); fExts = exts == null || exts.length == 0 ? EMPTY_STRING_ARRAY : (String[])exts.clone();
} }
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if(this == obj) if(this == obj)
return true; return true;
@ -313,7 +311,8 @@ public class CDataDiscoveredInfoCalculator {
return false; return false;
if(fExts.length != 0){ if(fExts.length != 0){
HashSet set = (HashSet)calcExtsSet().clone(); @SuppressWarnings("unchecked")
HashSet<String> set = (HashSet<String>)calcExtsSet().clone();
set.removeAll(other.calcExtsSet()); set.removeAll(other.calcExtsSet());
if(set.size() != 0) if(set.size() != 0)
return false; return false;
@ -321,10 +320,7 @@ public class CDataDiscoveredInfoCalculator {
return true; return true;
} }
public String[] getExtensions(){ @Override
return (String[])fExts.clone();
}
public int hashCode() { public int hashCode() {
int hash = fHash; int hash = fHash;
if(hash == 0){ if(hash == 0){
@ -337,12 +333,13 @@ public class CDataDiscoveredInfoCalculator {
return hash; return hash;
} }
private HashSet calcExtsSet(){ private HashSet<String> calcExtsSet(){
if(fExtsSet == null) if(fExtsSet == null)
fExtsSet = new HashSet(Arrays.asList(fExts)); fExtsSet = new HashSet<String>(Arrays.asList(fExts));
return fExtsSet; return fExtsSet;
} }
@Override
public String toString() { public String toString() {
if(fExts.length == 0) if(fExts.length == 0)
return "<empty>"; //$NON-NLS-1$ return "<empty>"; //$NON-NLS-1$
@ -360,8 +357,8 @@ public class CDataDiscoveredInfoCalculator {
private static class RcSetSettings { private static class RcSetSettings {
private CResourceData fRcData; private CResourceData fRcData;
private HashMap fExtToExtsSetMap; private HashMap<String, ExtsSetSettings> fExtToExtsSetMap;
private HashMap fExtsSetToExtsSetSettingsMap; private HashMap<ExtsSet, ExtsSetSettings> fExtsSetToExtsSetSettingsMap;
private PathSettingsContainer fContainer; private PathSettingsContainer fContainer;
private boolean fIsDerived; private boolean fIsDerived;
@ -386,10 +383,6 @@ public class CDataDiscoveredInfoCalculator {
return null; return null;
} }
public CResourceData getResourceData() {
return fRcData;
}
public RcSetSettings createChild(IPath path, CResourceData data, boolean isDerived){ public RcSetSettings createChild(IPath path, CResourceData data, boolean isDerived){
PathSettingsContainer cr = fContainer.getChildContainer(path, true, true); PathSettingsContainer cr = fContainer.getChildContainer(path, true, true);
RcSetSettings child = (RcSetSettings)cr.getValue(); RcSetSettings child = (RcSetSettings)cr.getValue();
@ -407,11 +400,9 @@ public class CDataDiscoveredInfoCalculator {
} }
private void updateLangDatas(){ private void updateLangDatas(){
ExtsSetSettings extSetting;
if(fRcData.getType() == ICSettingBase.SETTING_FILE){ if(fRcData.getType() == ICSettingBase.SETTING_FILE){
CLanguageData lData = ((CFileData)fRcData).getLanguageData(); CLanguageData lData = ((CFileData)fRcData).getLanguageData();
extSetting = (ExtsSetSettings)fExtToExtsSetMap.get(getFileExt(fRcData.getPath())); ExtsSetSettings extSetting = fExtToExtsSetMap.get(getFileExt(fRcData.getPath()));
if(extSetting != null){ if(extSetting != null){
extSetting.fBaseLangData = lData; extSetting.fBaseLangData = lData;
extSetting.fIsDerived = lData != null ? fIsDerived : false; extSetting.fIsDerived = lData != null ? fIsDerived : false;
@ -420,9 +411,7 @@ public class CDataDiscoveredInfoCalculator {
if(extSetting != null ? if(extSetting != null ?
fExtsSetToExtsSetSettingsMap.size() > 1 fExtsSetToExtsSetSettingsMap.size() > 1
: fExtsSetToExtsSetSettingsMap.size() > 0){ : fExtsSetToExtsSetSettingsMap.size() > 0){
ExtsSetSettings s; for (ExtsSetSettings s : fExtsSetToExtsSetSettingsMap.values()) {
for(Iterator iter = fExtsSetToExtsSetSettingsMap.values().iterator(); iter.hasNext();){
s = (ExtsSetSettings)iter.next();
if(s != extSetting){ if(s != extSetting){
s.fBaseLangData = null; s.fBaseLangData = null;
s.fIsDerived = false; s.fIsDerived = false;
@ -431,12 +420,13 @@ public class CDataDiscoveredInfoCalculator {
} }
} else { } else {
CLanguageData[] lDatas = ((CFolderData)fRcData).getLanguageDatas(); CLanguageData[] lDatas = ((CFolderData)fRcData).getLanguageDatas();
Map map = (HashMap)fExtsSetToExtsSetSettingsMap.clone(); @SuppressWarnings("unchecked")
Map<ExtsSet, ExtsSetSettings> map = (HashMap<ExtsSet, ExtsSetSettings>)fExtsSetToExtsSetSettingsMap.clone();
CLanguageData lData; CLanguageData lData;
for(int i = 0; i < lDatas.length; i++){ for(int i = 0; i < lDatas.length; i++){
lData = lDatas[i]; lData = lDatas[i];
extSetting = (ExtsSetSettings)map.remove(new ExtsSet(lData.getSourceExtensions())); ExtsSetSettings extSetting = map.remove(new ExtsSet(lData.getSourceExtensions()));
if(extSetting != null){ if(extSetting != null){
extSetting.fBaseLangData = lData; extSetting.fBaseLangData = lData;
extSetting.fIsDerived = this.fIsDerived; extSetting.fIsDerived = this.fIsDerived;
@ -444,8 +434,8 @@ public class CDataDiscoveredInfoCalculator {
} }
if(map.size() != 0){ if(map.size() != 0){
for(Iterator iter = map.values().iterator(); iter.hasNext();){ Collection<ExtsSetSettings> extSettings = map.values();
extSetting = (ExtsSetSettings)iter.next(); for (ExtsSetSettings extSetting : extSettings) {
extSetting.fBaseLangData = null; extSetting.fBaseLangData = null;
extSetting.fIsDerived = false; extSetting.fIsDerived = false;
} }
@ -464,17 +454,17 @@ public class CDataDiscoveredInfoCalculator {
return null; return null;
} }
void internalSetSettingsMap(HashMap map){ void internalSetSettingsMap(HashMap<ExtsSet, ExtsSetSettings> map){
fExtsSetToExtsSetSettingsMap = map; fExtsSetToExtsSetSettingsMap = map;
fExtToExtsSetMap = calcExtToExtSetSettingsMap(map); fExtToExtsSetMap = calcExtToExtSetSettingsMap(map);
} }
void internalAdd(ExtsSetSettings setting){ void internalAdd(ExtsSetSettings setting){
if(fExtsSetToExtsSetSettingsMap == null){ if(fExtsSetToExtsSetSettingsMap == null){
fExtsSetToExtsSetSettingsMap = new HashMap(); fExtsSetToExtsSetSettingsMap = new HashMap<ExtsSet, ExtsSetSettings>();
} }
ExtsSetSettings cur = (ExtsSetSettings)fExtsSetToExtsSetSettingsMap.get(setting.fExtsSet); ExtsSetSettings cur = fExtsSetToExtsSetSettingsMap.get(setting.fExtsSet);
if(cur != null){ if(cur != null){
cur.add(setting); cur.add(setting);
} else { } else {
@ -483,12 +473,11 @@ public class CDataDiscoveredInfoCalculator {
} }
} }
void internalAddSettingsMap(HashMap map){ void internalAddSettingsMap(HashMap<ExtsSet, ExtsSetSettings> map){
ExtsSetSettings setting;//, thisSetting; Collection<ExtsSetSettings> settings = map.values();
// ExtsSet extsSet; for (ExtsSetSettings setting : settings) {
for(Iterator iter = map.values().iterator(); iter.hasNext();){
setting = (ExtsSetSettings)iter.next();
internalAdd(setting); internalAdd(setting);
// ExtsSet extsSet;
// extsSet = setting.fExtsSet; // extsSet = setting.fExtsSet;
// thisSetting = (ExtsSetSettings)fExtsSetToExtsSetSettingsMap.get(extsSet); // thisSetting = (ExtsSetSettings)fExtsSetToExtsSetSettingsMap.get(extsSet);
// if(thisSetting != null){ // if(thisSetting != null){
@ -500,12 +489,8 @@ public class CDataDiscoveredInfoCalculator {
} }
} }
public boolean settingsEqual(RcSetSettings other){
return fExtsSetToExtsSetSettingsMap.equals(other.fExtsSetToExtsSetSettingsMap);
}
public RcSetSettings[] getChildren(final boolean includeCurrent){ public RcSetSettings[] getChildren(final boolean includeCurrent){
final List list = new ArrayList(); final List<Object> list = new ArrayList<Object>();
fContainer.accept(new IPathSettingsContainerVisitor(){ fContainer.accept(new IPathSettingsContainerVisitor(){
public boolean visit(PathSettingsContainer container) { public boolean visit(PathSettingsContainer container) {
@ -517,23 +502,20 @@ public class CDataDiscoveredInfoCalculator {
}); });
return (RcSetSettings[])list.toArray(new RcSetSettings[list.size()]); return list.toArray(new RcSetSettings[list.size()]);
} }
public boolean containsEqualMaxMatches(RcSetSettings other, boolean ignoreGenerated){ public boolean containsEqualMaxMatches(RcSetSettings other, boolean ignoreGenerated){
if(!ignoreGenerated && fExtsSetToExtsSetSettingsMap.size() < other.fExtsSetToExtsSetSettingsMap.size()) if(!ignoreGenerated && fExtsSetToExtsSetSettingsMap.size() < other.fExtsSetToExtsSetSettingsMap.size())
return false; return false;
ExtsSetSettings otherSetting, thisSetting; Set<Entry<ExtsSet, ExtsSetSettings>> entrySet = other.fExtsSetToExtsSetSettingsMap.entrySet();
Map.Entry entry; for (Entry<ExtsSet, ExtsSetSettings> entry : entrySet) {
ExtsSetSettings otherSetting = entry.getValue();
for(Iterator iter = other.fExtsSetToExtsSetSettingsMap.entrySet().iterator(); iter.hasNext();){
entry = (Map.Entry)iter.next();
otherSetting = (ExtsSetSettings)entry.getValue();
if(ignoreGenerated && otherSetting.fBaseLangData == null) if(ignoreGenerated && otherSetting.fBaseLangData == null)
continue; continue;
thisSetting = (ExtsSetSettings)fExtsSetToExtsSetSettingsMap.get(entry.getKey()); ExtsSetSettings thisSetting = fExtsSetToExtsSetSettingsMap.get(entry.getKey());
if(thisSetting == null) if(thisSetting == null)
return false; return false;
@ -555,22 +537,21 @@ public class CDataDiscoveredInfoCalculator {
} }
} }
private static HashMap calcExtToExtSetSettingsMap(Map extsSetMap){ private static HashMap<String, ExtsSetSettings> calcExtToExtSetSettingsMap(Map<ExtsSet, ExtsSetSettings> extsSetMap){
HashMap result = null; HashMap<String, ExtsSetSettings> result = null;
ExtsSetSettings setting; Collection<ExtsSetSettings> settings = extsSetMap.values();
for(Iterator iter = extsSetMap.values().iterator(); iter.hasNext();){ for (ExtsSetSettings setting : settings) {
setting = (ExtsSetSettings)iter.next();
result = addExtsInfoToMap(setting, result); result = addExtsInfoToMap(setting, result);
} }
return result; return result;
} }
private static HashMap addExtsInfoToMap(ExtsSetSettings setting, HashMap map){ private static HashMap<String, ExtsSetSettings> addExtsInfoToMap(ExtsSetSettings setting, HashMap<String, ExtsSetSettings> map){
boolean forceAdd = false; boolean forceAdd = false;
String[] exts = setting.fExtsSet.fExts; String[] exts = setting.fExtsSet.fExts;
String ext; String ext;
if(map == null){ if(map == null){
map = new HashMap(); map = new HashMap<String, ExtsSetSettings>();
forceAdd = true; forceAdd = true;
} }
@ -594,7 +575,7 @@ public class CDataDiscoveredInfoCalculator {
CResourceData[] rcDatas = data.getResourceDatas(); CResourceData[] rcDatas = data.getResourceDatas();
CResourceData rcData; CResourceData rcData;
RcSetSettings curRcSet; RcSetSettings curRcSet;
HashMap fileMap; HashMap<ExtsSet, ExtsSetSettings> fileMap;
ExtsSetSettings fileSetting; ExtsSetSettings fileSetting;
IPath path; IPath path;
@ -609,7 +590,7 @@ public class CDataDiscoveredInfoCalculator {
path = rcData.getPath(); path = rcData.getPath();
curRcSet = rcSet.createChild(path, rcData, false); curRcSet = rcSet.createChild(path, rcData, false);
if(rcData.getType() == ICSettingBase.SETTING_FILE){ if(rcData.getType() == ICSettingBase.SETTING_FILE){
fileMap = new HashMap(1); fileMap = new HashMap<ExtsSet, ExtsSetSettings>(1);
fileSetting = createExtsSetSettings(path, (CFileData)rcData); fileSetting = createExtsSetSettings(path, (CFileData)rcData);
fileMap.put(fileSetting.fExtsSet, fileSetting); fileMap.put(fileSetting.fExtsSet, fileSetting);
curRcSet.internalSetSettingsMap(fileMap); curRcSet.internalSetSettingsMap(fileMap);
@ -639,7 +620,7 @@ public class CDataDiscoveredInfoCalculator {
private RcSetSettings createRcSetSettings(CConfigurationData data, IDiscoveredPathManager.IPerFileDiscoveredPathInfo2 discoveredInfo){ private RcSetSettings createRcSetSettings(CConfigurationData data, IDiscoveredPathManager.IPerFileDiscoveredPathInfo2 discoveredInfo){
RcSetSettings rcSet = createRcSetInfo(data); RcSetSettings rcSet = createRcSetInfo(data);
Map map = discoveredInfo.getPathInfoMap(); Map<IResource, PathInfo> map = discoveredInfo.getPathInfoMap();
PathFilePathInfo pInfos[] = createOrderedInfo(map); PathFilePathInfo pInfos[] = createOrderedInfo(map);
mapDiscoveredInfo(rcSet, pInfos); mapDiscoveredInfo(rcSet, pInfos);
checkRemoveDups(rcSet); checkRemoveDups(rcSet);
@ -676,9 +657,9 @@ public class CDataDiscoveredInfoCalculator {
} }
private static void addLanguageInfos(RcSettingInfo rcInfo, CLanguageData[] lDatas, PathInfo info){ private static void addLanguageInfos(RcSettingInfo rcInfo, CLanguageData[] lDatas, PathInfo info){
ArrayList list = rcInfo.fLangInfoList; ArrayList<ILangSettingInfo> list = rcInfo.fLangInfoList;
if(list == null){ if(list == null){
list = new ArrayList(lDatas.length); list = new ArrayList<ILangSettingInfo>(lDatas.length);
rcInfo.fLangInfoList = list; rcInfo.fLangInfoList = list;
} else { } else {
list.ensureCapacity(lDatas.length); list.ensureCapacity(lDatas.length);
@ -695,11 +676,11 @@ public class CDataDiscoveredInfoCalculator {
IPath projRelPath; IPath projRelPath;
CResourceData rcData; CResourceData rcData;
// RcSetSettings dataSetting; // RcSetSettings dataSetting;
List list = new ArrayList(pfpis.length); List<RcSettingInfo> list = new ArrayList<RcSettingInfo>(pfpis.length);
RcSettingInfo rcInfo; RcSettingInfo rcInfo;
LangSettingInfo lInfo; ILangSettingInfo lInfo;
CLanguageData lData; CLanguageData lData;
ArrayList tmpList; ArrayList<ILangSettingInfo> tmpList;
PathFilePathInfo pfpi; PathFilePathInfo pfpi;
for(int i = 0; i < pfpis.length; i++){ for(int i = 0; i < pfpis.length; i++){
@ -716,7 +697,7 @@ public class CDataDiscoveredInfoCalculator {
IPath[] quotedIncPaths = pInfo.getQuoteIncludePaths(); IPath[] quotedIncPaths = pInfo.getQuoteIncludePaths();
IPath[] incFiles = pInfo.getIncludeFiles(); IPath[] incFiles = pInfo.getIncludeFiles();
IPath[] macroFiles = pInfo.getMacroFiles(); IPath[] macroFiles = pInfo.getMacroFiles();
Map symbolMap = pInfo.getSymbols(); Map<String, String> symbolMap = pInfo.getSymbols();
int kinds = 0; int kinds = 0;
if(incPaths.length != 0 || quotedIncPaths.length != 0) if(incPaths.length != 0 || quotedIncPaths.length != 0)
@ -736,7 +717,7 @@ public class CDataDiscoveredInfoCalculator {
if(rcInfo == null){ if(rcInfo == null){
rcInfo = new RcSettingInfo(rootData); rcInfo = new RcSettingInfo(rootData);
tmpList = new ArrayList(lDatas.length - k); tmpList = new ArrayList<ILangSettingInfo>(lDatas.length - k);
rcInfo.fLangInfoList = tmpList; rcInfo.fLangInfoList = tmpList;
} }
@ -790,7 +771,7 @@ public class CDataDiscoveredInfoCalculator {
if(lData != null){ if(lData != null){
rcInfo = new RcSettingInfo(rcData); rcInfo = new RcSettingInfo(rcData);
lInfo = new LangSettingInfo(lData, pInfo); lInfo = new LangSettingInfo(lData, pInfo);
tmpList = new ArrayList(1); tmpList = new ArrayList<ILangSettingInfo>(1);
tmpList.add(lInfo); tmpList.add(lInfo);
rcInfo.fLangInfoList = tmpList; rcInfo.fLangInfoList = tmpList;
list.add(rcInfo); list.add(rcInfo);
@ -801,7 +782,7 @@ public class CDataDiscoveredInfoCalculator {
// break; // break;
// } // }
} }
return (RcSettingInfo[])list.toArray(new RcSettingInfo[list.size()]); return list.toArray(new RcSettingInfo[list.size()]);
} }
public IRcSettingInfo[] getSettingInfos(IProject project, CConfigurationData data, IDiscoveredPathManager.IPerFileDiscoveredPathInfo2 discoveredInfo, boolean fileDataMode){ public IRcSettingInfo[] getSettingInfos(IProject project, CConfigurationData data, IDiscoveredPathManager.IPerFileDiscoveredPathInfo2 discoveredInfo, boolean fileDataMode){
@ -818,8 +799,7 @@ public class CDataDiscoveredInfoCalculator {
RcSetSettings settings[] = rootSetting.getChildren(true); RcSetSettings settings[] = rootSetting.getChildren(true);
RcSetSettings setting; RcSetSettings setting;
CResourceData rcData; CResourceData rcData;
ExtsSetSettings extSetting; List<IRcSettingInfo> resultList = new ArrayList<IRcSettingInfo>();
List resultList = new ArrayList();
LangSettingInfo langInfo; LangSettingInfo langInfo;
RcSettingInfo rcInfo; RcSettingInfo rcInfo;
PathInfo pathInfo; PathInfo pathInfo;
@ -845,13 +825,13 @@ public class CDataDiscoveredInfoCalculator {
} }
if(rcData.getType() == ICSettingBase.SETTING_FILE){ if(rcData.getType() == ICSettingBase.SETTING_FILE){
extSetting = (ExtsSetSettings)setting.fExtToExtsSetMap.get(getFileExt(rcData.getPath())); ExtsSetSettings extSetting = setting.fExtToExtsSetMap.get(getFileExt(rcData.getPath()));
if(extSetting != null){ if(extSetting != null){
pathInfo = extSetting.fMaxMatchInfo; pathInfo = extSetting.fMaxMatchInfo;
if(pathInfo != null){ if(pathInfo != null){
langInfo = new LangSettingInfo(extSetting.fBaseLangData, pathInfo); langInfo = new LangSettingInfo(extSetting.fBaseLangData, pathInfo);
rcInfo = new RcSettingInfo(rcData); rcInfo = new RcSettingInfo(rcData);
rcInfo.fLangInfoList = new ArrayList(1); rcInfo.fLangInfoList = new ArrayList<ILangSettingInfo> (1);
rcInfo.fLangInfoList.add(langInfo); rcInfo.fLangInfoList.add(langInfo);
resultList.add(rcInfo); resultList.add(rcInfo);
} }
@ -859,11 +839,11 @@ public class CDataDiscoveredInfoCalculator {
} else { } else {
if(setting.fExtsSetToExtsSetSettingsMap.size() != 0 ){ if(setting.fExtsSetToExtsSetSettingsMap.size() != 0 ){
rcInfo = new RcSettingInfo(rcData); rcInfo = new RcSettingInfo(rcData);
rcInfo.fLangInfoList = new ArrayList(setting.fExtsSetToExtsSetSettingsMap.size()); rcInfo.fLangInfoList = new ArrayList<ILangSettingInfo>(setting.fExtsSetToExtsSetSettingsMap.size());
resultList.add(rcInfo); resultList.add(rcInfo);
for(Iterator iter = setting.fExtsSetToExtsSetSettingsMap.values().iterator(); iter.hasNext();){ Collection<ExtsSetSettings> extSettings = setting.fExtsSetToExtsSetSettingsMap.values();
extSetting = (ExtsSetSettings)iter.next(); for (ExtsSetSettings extSetting : extSettings) {
if(extSetting.fMaxMatchInfo == null) if(extSetting.fMaxMatchInfo == null)
continue; continue;
@ -878,28 +858,17 @@ public class CDataDiscoveredInfoCalculator {
rcInfo.add(new LangSettingInfo(extSetting.fBaseLangData, extSetting.fMaxMatchInfo)); rcInfo.add(new LangSettingInfo(extSetting.fBaseLangData, extSetting.fMaxMatchInfo));
if(extSetting.isMultiple()){ if(extSetting.isMultiple()){
Map.Entry entry; Set<Entry<PathInfo, List<PathFilePathInfo>>> entries = extSetting.fPathFilePathInfoMap.entrySet();
List piList; for (Entry<PathInfo, List<PathFilePathInfo>> entry : entries) {
int sz;
PathFilePathInfo pi;
CFileData fiData;
RcSettingInfo fiInfo;
CLanguageData fiLangData;
for(Iterator pathInfoIter = extSetting.fPathFilePathInfoMap.entrySet().iterator(); pathInfoIter.hasNext();){
entry = (Map.Entry)pathInfoIter.next();
if(entry.getKey().equals(extSetting.fMaxMatchInfo)) if(entry.getKey().equals(extSetting.fMaxMatchInfo))
continue; continue;
piList = (List)entry.getValue(); List<PathFilePathInfo> piList = entry.getValue();
sz = piList.size(); for (PathFilePathInfo pi : piList) {
for(int k = 0; k < sz; k++){
pi = (PathFilePathInfo)piList.get(k);
try { try {
fiData = createFileData(data, pi.fPath, (CFolderData)rcData, extSetting.fBaseLangData); CFileData fiData = createFileData(data, pi.fPath, (CFolderData)rcData, extSetting.fBaseLangData);
fiLangData = fiData.getLanguageData(); CLanguageData fiLangData = fiData.getLanguageData();
if(fiLangData != null){ if(fiLangData != null){
fiInfo = new RcSettingInfo(fiData); RcSettingInfo fiInfo = new RcSettingInfo(fiData);
fiInfo.add(new LangSettingInfo(fiLangData, pi.fInfo)); fiInfo.add(new LangSettingInfo(fiLangData, pi.fInfo));
resultList.add(fiInfo); resultList.add(fiInfo);
} }
@ -915,7 +884,7 @@ public class CDataDiscoveredInfoCalculator {
} }
// } // }
return (RcSettingInfo[])resultList.toArray(new RcSettingInfo[resultList.size()]); return resultList.toArray(new RcSettingInfo[resultList.size()]);
} }
private CFolderData createFolderData(CConfigurationData cfg, CResourceData base, RcSetSettings setting) throws CoreException{ private CFolderData createFolderData(CConfigurationData cfg, CResourceData base, RcSetSettings setting) throws CoreException{
@ -977,7 +946,7 @@ public class CDataDiscoveredInfoCalculator {
processProjectPaths(child, pInfo); processProjectPaths(child, pInfo);
} else { } else {
ext = getFileExt(pInfo.fPath); ext = getFileExt(pInfo.fPath);
extsSet = (ExtsSetSettings)child.fExtToExtsSetMap.get(ext); extsSet = child.fExtToExtsSetMap.get(ext);
if(extsSet == null){ if(extsSet == null){
extsSet = new ExtsSetSettings(null, new ExtsSet(new String[]{ext}), false); extsSet = new ExtsSetSettings(null, new ExtsSet(new String[]{ext}), false);
child.internalAdd(extsSet); child.internalAdd(extsSet);
@ -989,9 +958,8 @@ public class CDataDiscoveredInfoCalculator {
} }
private static void processProjectPaths(RcSetSettings rcSet, PathFilePathInfo pfpi){ private static void processProjectPaths(RcSetSettings rcSet, PathFilePathInfo pfpi){
ExtsSetSettings setting; Collection<ExtsSetSettings> settings = rcSet.fExtsSetToExtsSetSettingsMap.values();
for(Iterator iter = rcSet.fExtsSetToExtsSetSettingsMap.values().iterator(); iter.hasNext();){ for (ExtsSetSettings setting : settings) {
setting = (ExtsSetSettings)iter.next();
setting.add(pfpi); setting.add(pfpi);
} }
} }
@ -1003,12 +971,12 @@ public class CDataDiscoveredInfoCalculator {
return ""; //$NON-NLS-1$ return ""; //$NON-NLS-1$
} }
private static HashMap createEmptyExtSetMapCopy(HashMap base){ private static HashMap<ExtsSet, ExtsSetSettings> createEmptyExtSetMapCopy(HashMap<ExtsSet, ExtsSetSettings> base){
HashMap map = (HashMap)base.clone(); @SuppressWarnings("unchecked")
ExtsSetSettings extsSet; HashMap<ExtsSet, ExtsSetSettings> map = (HashMap<ExtsSet, ExtsSetSettings>)base.clone();
for(Iterator iter = map.entrySet().iterator(); iter.hasNext();){ Set<Entry<ExtsSet, ExtsSetSettings>> entries = map.entrySet();
Map.Entry entry = (Map.Entry)iter.next(); for (Entry<ExtsSet, ExtsSetSettings> entry : entries) {
extsSet = (ExtsSetSettings)entry.getValue(); ExtsSetSettings extsSet = entry.getValue();
extsSet = new ExtsSetSettings(extsSet.fBaseLangData, extsSet.fExtsSet, true); extsSet = new ExtsSetSettings(extsSet.fBaseLangData, extsSet.fExtsSet, true);
entry.setValue(extsSet); entry.setValue(extsSet);
} }
@ -1028,9 +996,9 @@ public class CDataDiscoveredInfoCalculator {
return new ExtsSetSettings(lData, new ExtsSet(exts), false); return new ExtsSetSettings(lData, new ExtsSet(exts), false);
} }
private static HashMap createExtsSetSettingsMap(CFolderData data){ private static HashMap<ExtsSet, ExtsSetSettings> createExtsSetSettingsMap(CFolderData data){
CLanguageData[] lDatas = data.getLanguageDatas(); CLanguageData[] lDatas = data.getLanguageDatas();
HashMap map = new HashMap(lDatas.length); HashMap<ExtsSet, ExtsSetSettings> map = new HashMap<ExtsSet, ExtsSetSettings>(lDatas.length);
ExtsSetSettings settings; ExtsSetSettings settings;
if(lDatas.length != 0) { if(lDatas.length != 0) {
@ -1045,19 +1013,15 @@ public class CDataDiscoveredInfoCalculator {
return map; return map;
} }
private static PathFilePathInfo[] createOrderedInfo(Map map){ private static PathFilePathInfo[] createOrderedInfo(Map<IResource, PathInfo> map){
Map.Entry entry;
IResource rc;
IPath path;
PathInfo info, storedInfo;
ListIndexStore store = new ListIndexStore(10); ListIndexStore store = new ListIndexStore(10);
HashMap infoMap = new HashMap(); HashMap<PathInfo, PathInfo> infoMap = new HashMap<PathInfo, PathInfo>();
// LinkedHashMap result; // LinkedHashMap result;
for(Iterator iter = map.entrySet().iterator(); iter.hasNext();){ Set<Entry<IResource, PathInfo>> entries = map.entrySet();
entry = (Map.Entry)iter.next(); for (Entry<IResource, PathInfo> entry : entries) {
rc = (IResource)entry.getKey(); IResource rc = entry.getKey();
path = rc.getProjectRelativePath(); IPath path = rc.getProjectRelativePath();
int segCount = path.segmentCount(); int segCount = path.segmentCount();
// if(segCount < 1) // if(segCount < 1)
// continue; // continue;
@ -1065,8 +1029,8 @@ public class CDataDiscoveredInfoCalculator {
// path = path.removeFirstSegments(1); // path = path.removeFirstSegments(1);
// segCount--; // segCount--;
info = (PathInfo)entry.getValue(); PathInfo info = entry.getValue();
storedInfo = (PathInfo)infoMap.get(info); PathInfo storedInfo = infoMap.get(info);
if(storedInfo == null){ if(storedInfo == null){
storedInfo = info; storedInfo = info;
infoMap.put(storedInfo, storedInfo); infoMap.put(storedInfo, storedInfo);
@ -1075,7 +1039,7 @@ public class CDataDiscoveredInfoCalculator {
store.add(segCount, new PathFilePathInfo(path, storedInfo)); store.add(segCount, new PathFilePathInfo(path, storedInfo));
} }
List lists[] = store.getLists(); List<PathFilePathInfo> lists[] = store.getLists();
// result = new LinkedHashMap(map.size()); // result = new LinkedHashMap(map.size());
// List l; // List l;
// int lSize; // int lSize;
@ -1099,12 +1063,12 @@ public class CDataDiscoveredInfoCalculator {
infos = new PathFilePathInfo[size]; infos = new PathFilePathInfo[size];
int num = 0; int num = 0;
int listSize; int listSize;
List list; List<PathFilePathInfo> list;
for(int i = 0; i < lists.length; i++){ for(int i = 0; i < lists.length; i++){
list = lists[i]; list = lists[i];
listSize = list.size(); listSize = list.size();
for(int k = 0; k < listSize; k++){ for(int k = 0; k < listSize; k++){
infos[num++] = (PathFilePathInfo)list.get(k); infos[num++] = list.get(k);
} }
} }
@ -1128,7 +1092,7 @@ public class CDataDiscoveredInfoCalculator {
return dsInfo; return dsInfo;
} }
IPath[] includes = info.getIncludePaths(); IPath[] includes = info.getIncludePaths();
Map symbols = info.getSymbols(); Map<String, String> symbols = info.getSymbols();
PathInfo pathInfo = new PathInfo(includes, null, symbols, null, null); PathInfo pathInfo = new PathInfo(includes, null, symbols, null, null);
CFolderData rootData = cfgData.getRootFolderData(); CFolderData rootData = cfgData.getRootFolderData();