diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ConflictSet.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ConflictSet.java index 05a682db4b1..c9f2ae38c92 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ConflictSet.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ConflictSet.java @@ -12,11 +12,10 @@ package org.eclipse.cdt.managedbuilder.internal.tcmodification; import java.util.ArrayList; import java.util.Collection; -import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; -import java.util.SortedSet; import java.util.TreeSet; import org.eclipse.cdt.managedbuilder.core.IBuildObject; @@ -30,11 +29,11 @@ public class ConflictSet { public static final IBuildObject[] EMPTY_BO_ARRAY = new IBuildObject[0]; private PerTypeMapStorage fConflictStorage; - private List fConflictMatchList; - private Set fExtConflictSet; + private List fConflictMatchList; + private Set fExtConflictSet; private IRealBuildObjectAssociation fRealObj; - public ConflictSet(IRealBuildObjectAssociation realObj, List conflictMatchList, Set extConflictSet){ + public ConflictSet(IRealBuildObjectAssociation realObj, List conflictMatchList, Set extConflictSet){ fConflictMatchList = conflictMatchList; fExtConflictSet = extConflictSet; fRealObj = realObj; @@ -47,43 +46,42 @@ public class ConflictSet { int size = fConflictMatchList.size(); PerTypeMapStorage result = new PerTypeMapStorage(); for(int i = 0; i < size; i++){ - ConflictMatch match = (ConflictMatch)fConflictMatchList.get(i); + ConflictMatch match = fConflictMatchList.get(i); int objType = match.fMatchType; - Map cm = match.fRObjToPathMap; - Map cur = result.getMap(objType, true); + Map> cm = match.fRObjToPathMap; + Map> cur = result.getMap(objType, true); - for(Iterator iter = cm.entrySet().iterator(); iter.hasNext(); ){ - Map.Entry entry = (Map.Entry)iter.next(); - Object obj = entry.getKey(); + Set>> entrySet = cm.entrySet(); + for (Entry> entry : entrySet) { + IRealBuildObjectAssociation bo = entry.getKey(); if(DbgTcmUtil.DEBUG){ - if(((IRealBuildObjectAssociation)obj).getType() != objType) + if((bo).getType() != objType) DbgTcmUtil.fail(); } - TreeSet set = (TreeSet)cur.get(obj); + Set set = cur.get(bo); if(set == null){ - set = new TreeSet(PathComparator.INSTANCE); - cur.put(obj, set); + set = new TreeSet(PathComparator.INSTANCE); + cur.put(bo, set); } - set.addAll((Set)entry.getValue()); + set.addAll(entry.getValue()); } } int types[] = ObjectTypeBasedStorage.getSupportedObjectTypes(); for(int i = 0; i < types.length; i++){ int type = types[i]; - Map map = result.getMap(type, false); + Map> map = result.getMap(type, false); if(map == null) continue; - for(Iterator iter = map.entrySet().iterator(); iter.hasNext(); ){ - Map.Entry entry = (Map.Entry)iter.next(); + Set>> entrySet = map.entrySet(); + for (Entry> entry : entrySet) { + IRealBuildObjectAssociation obj = entry.getKey(); + Set set = entry.getValue(); - IRealBuildObjectAssociation obj = (IRealBuildObjectAssociation)entry.getKey(); - TreeSet set = (TreeSet)entry.getValue(); - - Map cMap = fConflictStorage.getMap(type, true); + Map cMap = fConflictStorage.getMap(type, true); cMap.put(obj, new Conflict(IConflict.INCOMPATIBLE, obj, set)); } } @@ -94,10 +92,10 @@ public class ConflictSet { private static class Conflict implements IConflict { private IRealBuildObjectAssociation fObj; - private SortedSet fPathSet; + private Set fPathSet; private int fType; - Conflict(int type, IRealBuildObjectAssociation obj, SortedSet paths){ + Conflict(int type, IRealBuildObjectAssociation obj, Set paths){ fType = type; fObj = obj; fPathSet = paths; @@ -116,16 +114,16 @@ public class ConflictSet { } public IPath[] getPaths() { - return (IPath[])fPathSet.toArray(new IPath[fPathSet.size()]); + return fPathSet.toArray(new IPath[fPathSet.size()]); } } public IConflict[] getConflicts(){ init(); int types[] = ObjectTypeBasedStorage.getSupportedObjectTypes(); - List list = new ArrayList(); + List list = new ArrayList(); for(int i = 0; i < types.length; i++){ - Map map = fConflictStorage.getMap(types[i], false); + Map map = fConflictStorage.getMap(types[i], false); if(map == null) continue; @@ -135,28 +133,29 @@ public class ConflictSet { return conflictArray(list); } - private static List getConflicts(Map map, List list){ + private static List getConflicts(Map map, List list){ if(list == null) - list = new ArrayList(); + list = new ArrayList(); - for(Iterator iter = map.values().iterator(); iter.hasNext(); ){ - list.add(iter.next()); + Collection conflicts = map.values(); + for (Conflict conflict : conflicts) { + list.add(conflict); } return list; } - private static Conflict[] conflictArray(Collection list){ - return (Conflict[])list.toArray(new Conflict[list.size()]); + private static Conflict[] conflictArray(Collection list){ + return list.toArray(new Conflict[list.size()]); } - private static IRealBuildObjectAssociation[] objArray(Collection list){ - return (IRealBuildObjectAssociation[])list.toArray(new IRealBuildObjectAssociation[list.size()]); + private static IRealBuildObjectAssociation[] objArray(Collection list){ + return list.toArray(new IRealBuildObjectAssociation[list.size()]); } public IConflict[] getConflictsWith(int objectType){ init(); - Map map = fConflictStorage.getMap(objectType, false); + Map map = fConflictStorage.getMap(objectType, false); if(map == null) return EMPTY_CONFLICT_ARRAY; @@ -166,7 +165,7 @@ public class ConflictSet { public IBuildObject[] getConflictingObjects(int objectType){ init(); - Map map = fConflictStorage.getMap(objectType, false); + Map map = fConflictStorage.getMap(objectType, false); if(map == null) return EMPTY_BO_ARRAY; @@ -179,10 +178,10 @@ public class ConflictSet { return null; IRealBuildObjectAssociation obj = (IRealBuildObjectAssociation)bo; - Map map = fConflictStorage.getMap(obj.getType(), false); + Map map = fConflictStorage.getMap(obj.getType(), false); if(map == null) return null; - return (IConflict)map.get(obj); + return map.get(obj); } } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ToolChainModificationManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ToolChainModificationManager.java index f85569ac569..0c9caed13e4 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ToolChainModificationManager.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ToolChainModificationManager.java @@ -15,7 +15,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -120,17 +119,16 @@ public class ToolChainModificationManager implements return flags &= (~value); } - private boolean getMatchingObjects(int type, IObjectSet[] oSets, Set skipSet, IRealBuildObjectAssociation additionalSkip, Set result){ - Set tmp = null; + private boolean getMatchingObjects(int type, IObjectSet[] oSets, Set skipSet, IRealBuildObjectAssociation additionalSkip, Set result){ + Set tmp = null; boolean added = false; - for(int i = 0; i < oSets.length; i++){ - IObjectSet os = oSets[i]; + for (IObjectSet os : oSets) { int setType = os.getObjectType(); if(setType != type) continue; if(tmp == null) - tmp = new HashSet(); + tmp = new HashSet(); else tmp.clear(); @@ -160,14 +158,13 @@ public class ToolChainModificationManager implements public static class ConflictMatch { final int fMatchType; - final Map fRObjToPathMap; + final Map> fRObjToPathMap; final int fConflictType; - final Set fConflicts; + final Set fConflicts; - ConflictMatch(int matchType, Map robjToPathMap, - int conflictType, Set conflicts){ + ConflictMatch(int matchType, Map> rtToPathMap, int conflictType, Set conflicts){ fMatchType = matchType; - fRObjToPathMap = Collections.unmodifiableMap(robjToPathMap); + fRObjToPathMap = Collections.unmodifiableMap(rtToPathMap); fConflictType = conflictType; fConflicts = Collections.unmodifiableSet(conflicts); } @@ -192,8 +189,8 @@ public class ToolChainModificationManager implements //2. get variants for applicable ones //1.first filter applicable to not-this - List conflictList = new ArrayList(); - Map objToConflictMatchMap = new HashMap(); + List conflictList = new ArrayList(); + Map> objToConflictMatchMap = new HashMap>(); ObjectSetListBasedDefinition[] defs = RulesManager.getInstance().getRules(ObjectSetListBasedDefinition.CONFLICT); for(int i = 0; i < defs.length; i++){ @@ -203,13 +200,14 @@ public class ToolChainModificationManager implements for(int k = 0; k < oss.length; k++){ IObjectSet os = oss[k]; int objType = os.getObjectType(); - Map rtToPathMap = rtToPath.getMap(objType, false); + Map> rtToPathMap = rtToPath.getMap(objType, false); if(rtToPathMap == null) continue; - rtToPathMap = (Map)((HashMap)rtToPathMap).clone(); - Set skipSet = skip != null ? skip.getSet(objType, false) : null; - Set objSet = rtToPathMap.keySet(); + Map> clone = (Map>)((HashMap>)rtToPathMap).clone(); + rtToPathMap = clone; + Set skipSet = skip != null ? (Set)skip.getSet(objType, false) : null; + Set objSet = rtToPathMap.keySet(); if(skipSet != null) objSet.removeAll(skipSet); @@ -217,25 +215,20 @@ public class ToolChainModificationManager implements os.retainMatches(objSet); if(objSet.size() != 0){ - List remainingList = new ArrayList(Arrays.asList(oss)); + List remainingList = new ArrayList(Arrays.asList(oss)); remainingList.remove(os); - IObjectSet[] remaining = (IObjectSet[])remainingList.toArray(new IObjectSet[remainingList.size()]); + IObjectSet[] remaining = remainingList.toArray(new IObjectSet[remainingList.size()]); //get objects matching remaining - skipSet = skip != null ? skip.getSet(type, false) : null; - Set matchingObjects = new HashSet(); - getMatchingObjects(type, remaining, skipSet, - null, - matchingObjects); + Set skipSet2 = skip != null ? (Set)skip.getSet(type, false) : null; + Set matchingObjects = new HashSet(); + getMatchingObjects(type, remaining, skipSet2, null, matchingObjects); if(matchingObjects.size() != 0){ - ConflictMatch conflict = new ConflictMatch( - objType, - rtToPathMap, - type, - matchingObjects); + ConflictMatch conflict = new ConflictMatch(objType, rtToPathMap, type, matchingObjects); - for(Iterator iter = matchingObjects.iterator(); iter.hasNext(); ){ - TcModificationUtil.getArrayList(objToConflictMatchMap, iter.next()).add(conflict); + for (IRealBuildObjectAssociation bo : matchingObjects) { + ArrayList list = TcModificationUtil.getArrayList(objToConflictMatchMap, bo); + list.add(conflict); } conflictList.add(conflict); @@ -245,8 +238,6 @@ public class ToolChainModificationManager implements } } - return new ConflictMatchSet( - (ConflictMatch[])conflictList.toArray(new ConflictMatch[conflictList.size()]), - objToConflictMatchMap); + return new ConflictMatchSet(conflictList.toArray(new ConflictMatch[conflictList.size()]), objToConflictMatchMap); } }