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

bug 319512: Missing type arguments on managedbuilder.core

This commit is contained in:
Andrew Gvozdev 2010-09-25 05:21:01 +00:00
parent 8cdd50422c
commit 89d44a93c7

View file

@ -12,11 +12,13 @@ package org.eclipse.cdt.build.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;
@ -61,7 +63,7 @@ public class PerFileSettingsCalculator {
} }
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){
@ -70,7 +72,7 @@ public class PerFileSettingsCalculator {
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];
} }
@ -80,7 +82,7 @@ public class PerFileSettingsCalculator {
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);
} }
} }
@ -106,7 +108,7 @@ public class PerFileSettingsCalculator {
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)
@ -115,10 +117,10 @@ public class PerFileSettingsCalculator {
fStore = new List[size]; fStore = new List[size];
} }
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;
} }
@ -131,7 +133,7 @@ public class PerFileSettingsCalculator {
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]; 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);
} }
@ -141,17 +143,17 @@ public class PerFileSettingsCalculator {
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()]); return list.toArray(new List[list.size()]);
} }
} }
@ -169,11 +171,11 @@ public class PerFileSettingsCalculator {
// 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) {
@ -184,35 +186,32 @@ public class PerFileSettingsCalculator {
void add(ExtsSetSettings setting){ void add(ExtsSetSettings setting){
if(setting.fPathFilePathInfoMap != null){ if(setting.fPathFilePathInfoMap != null){
List list; Collection<List<PathFilePathInfo>> values = setting.fPathFilePathInfoMap.values();
int size; for (List<PathFilePathInfo> list : values) {
for(Iterator iter = setting.fPathFilePathInfoMap.values().iterator(); iter.hasNext();){ for (PathFilePathInfo pInfo : list) {
list = (List)iter.next(); add(pInfo);
size = list.size();
for(int i = 0; i < size; i++){
add((PathFilePathInfo)list.get(i));
} }
} }
} }
} }
void updateLangData(CLanguageData lData, boolean isDerived){ // void updateLangData(CLanguageData lData, boolean isDerived){
fBaseLangData = lData; // fBaseLangData = lData;
fIsDerived = lData != null ? isDerived : false; // 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 list = fileInfo == fMaxMatchInfo ? fMaxMatchInfoList : (List)fPathFilePathInfoMap.get(fileInfo);
if(list == null){ if(list == null){
list = new ArrayList(); List<PathFilePathInfo> emptyList = new ArrayList<PathFilePathInfo>();
fPathFilePathInfoMap.put(fileInfo, list); fPathFilePathInfoMap.put(fileInfo, emptyList);
if(fMaxMatchInfo == null){ if(fMaxMatchInfo == null){
fMaxMatchInfo = fileInfo; fMaxMatchInfo = fileInfo;
fMaxMatchInfoList = list; fMaxMatchInfoList = emptyList;
} }
// else { // else {
// fIsMultiple = true; // fIsMultiple = true;
@ -232,9 +231,9 @@ public class PerFileSettingsCalculator {
return fPathFilePathInfoMap != null && fPathFilePathInfoMap.size() > 1; return fPathFilePathInfoMap != null && fPathFilePathInfoMap.size() > 1;
} }
public PathInfo getMaxMatchPathInfo(){ // public PathInfo getMaxMatchPathInfo(){
return fMaxMatchInfo; // return fMaxMatchInfo;
} // }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@ -282,7 +281,7 @@ public class PerFileSettingsCalculator {
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){
@ -302,7 +301,8 @@ public class PerFileSettingsCalculator {
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;
@ -310,9 +310,9 @@ public class PerFileSettingsCalculator {
return true; return true;
} }
public String[] getExtensions(){ // public String[] getExtensions(){
return fExts.clone(); // return fExts.clone();
} // }
@Override @Override
public int hashCode() { public int hashCode() {
@ -327,9 +327,9 @@ public class PerFileSettingsCalculator {
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;
} }
@ -351,8 +351,8 @@ public class PerFileSettingsCalculator {
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;
@ -377,9 +377,9 @@ public class PerFileSettingsCalculator {
return null; return null;
} }
public CResourceData getResourceData() { // public CResourceData getResourceData() {
return fRcData; // 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);
@ -398,11 +398,9 @@ public class PerFileSettingsCalculator {
} }
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;
@ -411,9 +409,8 @@ public class PerFileSettingsCalculator {
if(extSetting != null ? if(extSetting != null ?
fExtsSetToExtsSetSettingsMap.size() > 1 fExtsSetToExtsSetSettingsMap.size() > 1
: fExtsSetToExtsSetSettingsMap.size() > 0){ : fExtsSetToExtsSetSettingsMap.size() > 0){
ExtsSetSettings s; Collection<ExtsSetSettings> values = fExtsSetToExtsSetSettingsMap.values();
for(Iterator iter = fExtsSetToExtsSetSettingsMap.values().iterator(); iter.hasNext();){ for (ExtsSetSettings s : values) {
s = (ExtsSetSettings)iter.next();
if(s != extSetting){ if(s != extSetting){
s.fBaseLangData = null; s.fBaseLangData = null;
s.fIsDerived = false; s.fIsDerived = false;
@ -422,12 +419,13 @@ public class PerFileSettingsCalculator {
} }
} 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;
@ -435,8 +433,8 @@ public class PerFileSettingsCalculator {
} }
if(map.size() != 0){ if(map.size() != 0){
for(Iterator iter = map.values().iterator(); iter.hasNext();){ Collection<ExtsSetSettings> values = map.values();
extSetting = (ExtsSetSettings)iter.next(); for (ExtsSetSettings extSetting : values) {
extSetting.fBaseLangData = null; extSetting.fBaseLangData = null;
extSetting.fIsDerived = false; extSetting.fIsDerived = false;
} }
@ -455,17 +453,17 @@ public class PerFileSettingsCalculator {
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 {
@ -474,11 +472,11 @@ public class PerFileSettingsCalculator {
} }
} }
void internalAddSettingsMap(HashMap map){ void internalAddSettingsMap(HashMap<ExtsSet, ExtsSetSettings> map){
ExtsSetSettings setting;//, thisSetting; // ExtsSetSettings thisSetting;
// ExtsSet extsSet; // ExtsSet extsSet;
for(Iterator iter = map.values().iterator(); iter.hasNext();){ Collection<ExtsSetSettings> values = map.values();
setting = (ExtsSetSettings)iter.next(); for (ExtsSetSettings setting : values) {
internalAdd(setting); internalAdd(setting);
// extsSet = setting.fExtsSet; // extsSet = setting.fExtsSet;
// thisSetting = (ExtsSetSettings)fExtsSetToExtsSetSettingsMap.get(extsSet); // thisSetting = (ExtsSetSettings)fExtsSetToExtsSetSettingsMap.get(extsSet);
@ -491,40 +489,38 @@ public class PerFileSettingsCalculator {
} }
} }
public boolean settingsEqual(RcSetSettings other){ // public boolean settingsEqual(RcSetSettings other){
return fExtsSetToExtsSetSettingsMap.equals(other.fExtsSetToExtsSetSettingsMap); // return fExtsSetToExtsSetSettingsMap.equals(other.fExtsSetToExtsSetSettingsMap);
} // }
public RcSetSettings[] getChildren(final boolean includeCurrent){ public RcSetSettings[] getChildren(final boolean includeCurrent){
final List list = new ArrayList(); final List<RcSetSettings> list = new ArrayList<RcSetSettings>();
fContainer.accept(new IPathSettingsContainerVisitor(){ fContainer.accept(new IPathSettingsContainerVisitor(){
public boolean visit(PathSettingsContainer container) { public boolean visit(PathSettingsContainer container) {
if(includeCurrent || container != fContainer){ if(includeCurrent || container != fContainer){
list.add(container.getValue()); RcSetSettings value = (RcSetSettings)container.getValue();
list.add(value);
} }
return true; return true;
} }
}); });
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;
@ -546,22 +542,21 @@ public class PerFileSettingsCalculator {
} }
} }
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> values = extsSetMap.values();
for(Iterator iter = extsSetMap.values().iterator(); iter.hasNext();){ for (ExtsSetSettings setting : values) {
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;
} }
@ -585,7 +580,7 @@ public class PerFileSettingsCalculator {
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;
@ -600,7 +595,7 @@ public class PerFileSettingsCalculator {
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);
@ -630,7 +625,7 @@ public class PerFileSettingsCalculator {
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);
@ -648,9 +643,9 @@ public class PerFileSettingsCalculator {
} }
private static void addEmptyLanguageInfos(RcSettingInfo rcInfo, CLanguageData[] lDatas){ private static void addEmptyLanguageInfos(RcSettingInfo rcInfo, CLanguageData[] lDatas){
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);
@ -667,11 +662,11 @@ public class PerFileSettingsCalculator {
IPath projRelPath; IPath projRelPath;
CResourceData rcData; CResourceData rcData;
// RcSetSettings dataSetting; // RcSetSettings dataSetting;
List list = new ArrayList(pfpis.length); List<IRcSettingInfo> list = new ArrayList<IRcSettingInfo>(pfpis.length);
RcSettingInfo rcInfo; RcSettingInfo rcInfo;
LangSettingInfo lInfo; LangSettingInfo 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++){
@ -688,7 +683,7 @@ public class PerFileSettingsCalculator {
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)
@ -708,7 +703,7 @@ public class PerFileSettingsCalculator {
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;
} }
@ -762,7 +757,7 @@ public class PerFileSettingsCalculator {
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);
@ -773,7 +768,7 @@ public class PerFileSettingsCalculator {
// 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){
@ -790,8 +785,7 @@ public class PerFileSettingsCalculator {
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;
@ -817,13 +811,13 @@ public class PerFileSettingsCalculator {
} }
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);
} }
@ -831,11 +825,11 @@ public class PerFileSettingsCalculator {
} 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> values = setting.fExtsSetToExtsSetSettingsMap.values();
extSetting = (ExtsSetSettings)iter.next(); for (ExtsSetSettings extSetting : values) {
if(extSetting.fMaxMatchInfo == null) if(extSetting.fMaxMatchInfo == null)
continue; continue;
@ -850,28 +844,17 @@ public class PerFileSettingsCalculator {
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>>> entrySet = extSetting.fPathFilePathInfoMap.entrySet();
List piList; for (Entry<PathInfo, List<PathFilePathInfo>> entry : entrySet) {
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);
} }
@ -887,7 +870,7 @@ public class PerFileSettingsCalculator {
} }
// } // }
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{
@ -949,7 +932,7 @@ public class PerFileSettingsCalculator {
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);
@ -961,9 +944,8 @@ public class PerFileSettingsCalculator {
} }
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);
} }
} }
@ -975,12 +957,13 @@ public class PerFileSettingsCalculator {
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")
HashMap<ExtsSet, ExtsSetSettings> map = (HashMap<ExtsSet, ExtsSetSettings>)base.clone();
ExtsSetSettings extsSet; ExtsSetSettings extsSet;
for(Iterator iter = map.entrySet().iterator(); iter.hasNext();){ Set<Entry<ExtsSet, ExtsSetSettings>> entrySet = map.entrySet();
Map.Entry entry = (Map.Entry)iter.next(); for (Entry<ExtsSet, ExtsSetSettings> entry : entrySet) {
extsSet = (ExtsSetSettings)entry.getValue(); 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);
} }
@ -1000,9 +983,9 @@ public class PerFileSettingsCalculator {
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) {
@ -1017,18 +1000,17 @@ public class PerFileSettingsCalculator {
return map; return map;
} }
private static PathFilePathInfo[] createOrderedInfo(Map map){ private static PathFilePathInfo[] createOrderedInfo(Map<IResource, PathInfo> map){
Map.Entry entry;
IResource rc; IResource rc;
IPath path; IPath path;
PathInfo info, storedInfo; 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>> entrySet = map.entrySet();
entry = (Map.Entry)iter.next(); for (Entry<IResource, PathInfo> entry : entrySet) {
rc = (IResource)entry.getKey(); rc = entry.getKey();
path = rc.getProjectRelativePath(); path = rc.getProjectRelativePath();
int segCount = path.segmentCount(); int segCount = path.segmentCount();
// if(segCount < 1) // if(segCount < 1)
@ -1037,8 +1019,8 @@ public class PerFileSettingsCalculator {
// path = path.removeFirstSegments(1); // path = path.removeFirstSegments(1);
// segCount--; // segCount--;
info = (PathInfo)entry.getValue(); info = entry.getValue();
storedInfo = (PathInfo)infoMap.get(info); storedInfo = infoMap.get(info);
if(storedInfo == null){ if(storedInfo == null){
storedInfo = info; storedInfo = info;
infoMap.put(storedInfo, storedInfo); infoMap.put(storedInfo, storedInfo);
@ -1047,7 +1029,7 @@ public class PerFileSettingsCalculator {
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;
@ -1071,12 +1053,12 @@ public class PerFileSettingsCalculator {
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);
} }
} }