diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ConfigurationModification.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ConfigurationModification.java index 6aec9e33358..689c973218a 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ConfigurationModification.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ConfigurationModification.java @@ -28,6 +28,7 @@ import org.eclipse.cdt.managedbuilder.internal.tcmodification.ToolChainModificat import org.eclipse.cdt.managedbuilder.internal.tcmodification.ToolChainModificationManager.ConflictMatchSet; import org.eclipse.cdt.managedbuilder.tcmodification.CompatibilityStatus; import org.eclipse.cdt.managedbuilder.tcmodification.IConfigurationModification; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; public class ConfigurationModification extends FolderInfoModification implements @@ -104,8 +105,8 @@ public class ConfigurationModification extends FolderInfoModification implements private ConflictMatchSet getParentConflictMatchSet(){ if(fConflicts == null){ - PerTypeMapStorage storage = getCompleteObjectStore(); - Object restore = TcModificationUtil.removeBuilderInfo(storage, fRealBuilder); + PerTypeMapStorage> storage = getCompleteObjectStore(); + Set restore = TcModificationUtil.removeBuilderInfo(storage, fRealBuilder); try { fConflicts = ToolChainModificationManager.getInstance().getConflictInfo(IRealBuildObjectAssociation.OBJECT_BUILDER, storage); } finally { @@ -187,7 +188,7 @@ public class ConfigurationModification extends FolderInfoModification implements fRealBuilder = realBuilder; fCompletePathMapStorage = null; - PerTypeMapStorage storage = getCompleteObjectStore(); + PerTypeMapStorage> storage = getCompleteObjectStore(); TcModificationUtil.applyBuilder(storage, getResourceInfo().getPath(), fSelectedBuilder); clearBuilderCompatibilityInfo(); 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 5ff5256c860..b9433433317 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 @@ -30,13 +30,13 @@ public class ConflictSet { private PerTypeMapStorage fConflictStorage; private List fConflictMatchList; - private Set fExtConflictSet; - private IRealBuildObjectAssociation fRealObj; +// private Set fExtConflictSet; +// private IRealBuildObjectAssociation fRealObj; public ConflictSet(IRealBuildObjectAssociation realObj, List conflictMatchList, Set extConflictSet){ fConflictMatchList = conflictMatchList; - fExtConflictSet = extConflictSet; - fRealObj = realObj; +// fExtConflictSet = (Set) extConflictSet; +// fRealObj = realObj; } private void init(){ diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/DbgTcmUtil.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/DbgTcmUtil.java index bc85c05bfa6..dcb4e40b035 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/DbgTcmUtil.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/DbgTcmUtil.java @@ -11,12 +11,13 @@ package org.eclipse.cdt.managedbuilder.internal.tcmodification; import java.io.PrintStream; -import java.util.Iterator; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import org.eclipse.cdt.managedbuilder.internal.core.IRealBuildObjectAssociation; import org.eclipse.cdt.managedbuilder.internal.tcmodification.extension.MatchObjectElement; +import org.eclipse.core.runtime.IPath; public class DbgTcmUtil { private static final PrintStream OUT = System.out; @@ -67,7 +68,7 @@ public class DbgTcmUtil { throw e; } - public static void dumpStorage(PerTypeMapStorage storage){ + public static void dumpStorage(PerTypeMapStorage> storage){ println("starting storage dump.."); //$NON-NLS-1$ int[] types = ObjectTypeBasedStorage.getSupportedObjectTypes(); for(int i = 0; i < types.length; i++){ @@ -78,16 +79,17 @@ public class DbgTcmUtil { println(" dumping for type " + assoc.getString()); //$NON-NLS-1$ - Map map = storage.getMap(type, false); + @SuppressWarnings("unchecked") + Map> map = (Map>) storage.getMap(type, false); if(map != null){ - for(Iterator iter = map.entrySet().iterator(); iter.hasNext(); ){ - Map.Entry entry = (Map.Entry)iter.next(); - IRealBuildObjectAssociation obj = (IRealBuildObjectAssociation)entry.getKey(); + Set>> entrySet = map.entrySet(); + for (Entry> entry : entrySet) { + IRealBuildObjectAssociation obj = entry.getKey(); println(" dumping " + assoc.getString() + " " + obj.getUniqueRealName()); //$NON-NLS-1$ //$NON-NLS-2$ - Set set = (Set)entry.getValue(); + Set set = entry.getValue(); if(set != null){ - for(Iterator setIter = set.iterator(); setIter.hasNext(); ){ - println(" path \"" + setIter.next() + "\""); //$NON-NLS-1$ //$NON-NLS-2$ + for (IPath path : set) { + println(" path \"" + path + "\""); //$NON-NLS-1$ //$NON-NLS-2$ } } println(" end dumping " + obj.getUniqueRealName()); //$NON-NLS-1$ diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/FolderInfoModification.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/FolderInfoModification.java index 106ed26c034..56defdd44fb 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/FolderInfoModification.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/FolderInfoModification.java @@ -307,9 +307,9 @@ public class FolderInfoModification extends ToolListModification implements IFol ToolChainApplicabilityPaths tcApplicabilityPaths = new ToolChainApplicabilityPaths(); IPath path = getResourceInfo().getPath(); - TreeMap pathMap = getCompletePathMapStorage(); + TreeMap> pathMap = getCompletePathMapStorage(); - PerTypeSetStorage oSet = pathMap.get(path); + PerTypeSetStorage oSet = pathMap.get(path); @SuppressWarnings("unchecked") Set toolSet = (Set) oSet.getSet(IRealBuildObjectAssociation.OBJECT_TOOL, false); @SuppressWarnings("unchecked") @@ -356,11 +356,11 @@ public class FolderInfoModification extends ToolListModification implements IFol } } - private static void calculateChildPaths(TreeMap pathMap, IPath path, ToolChain tc, Set tcPaths, Map> toolPathsMap, Set fileInfoPaths){ - SortedMap directCMap = PathComparator.getDirectChildPathMap(pathMap, path); - Set> entrySet = directCMap.entrySet(); - for (Entry entry : entrySet) { - PerTypeSetStorage cst = entry.getValue(); + private static void calculateChildPaths(TreeMap> pathMap, IPath path, ToolChain tc, Set tcPaths, Map> toolPathsMap, Set fileInfoPaths){ + SortedMap> directCMap = PathComparator.getDirectChildPathMap(pathMap, path); + Set>> entrySet = directCMap.entrySet(); + for (Entry> entry : entrySet) { + PerTypeSetStorage cst = entry.getValue(); @SuppressWarnings("unchecked") Set ctc = (Set) cst.getSet(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, false); @@ -389,7 +389,9 @@ public class FolderInfoModification extends ToolListModification implements IFol ToolChainApplicabilityPaths tcApplicability = getToolChainApplicabilityPaths(); PerTypeMapStorage> storage = getCompleteObjectStore(); + @SuppressWarnings("unchecked") Map> tcMap = (Map>) storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, false); + @SuppressWarnings("unchecked") Map> toolMap = (Map>) storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, false); diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/PathComparator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/PathComparator.java index f340b890bef..8b79c3f0d4e 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/PathComparator.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/PathComparator.java @@ -18,6 +18,7 @@ import java.util.SortedSet; import java.util.TreeMap; import java.util.TreeSet; +import org.eclipse.cdt.managedbuilder.internal.core.IRealBuildObjectAssociation; import org.eclipse.core.runtime.IPath; public class PathComparator implements Comparator { @@ -69,12 +70,12 @@ public class PathComparator implements Comparator { return path.append("\0"); //$NON-NLS-1$ } - public static SortedMap getChildPathMap(SortedMap map, IPath path, boolean includeThis, boolean copy){ + public static SortedMap> getChildPathMap(SortedMap> map, IPath path, boolean includeThis, boolean copy){ IPath start = includeThis ? path : getFirstChild(path); IPath next = getNext(path); - SortedMap result = next != null ? map.subMap(start, next) : map.tailMap(start); + SortedMap> result = next != null ? map.subMap(start, next) : map.tailMap(start); if(copy) - result = new TreeMap(result); + result = new TreeMap>(result); return result; } @@ -99,12 +100,12 @@ public class PathComparator implements Comparator { return result; } - public static SortedMap getDirectChildPathMap(SortedMap map, IPath path){ + public static SortedMap> getDirectChildPathMap(SortedMap> map, IPath path){ //all children - SortedMap children = getChildPathMap(map, path, false, false); - SortedMap result = new TreeMap(INSTANCE); - for(Iterator> iter = children.entrySet().iterator(); iter.hasNext(); iter = children.entrySet().iterator()){ - Map.Entry entry = iter.next(); + SortedMap> children = getChildPathMap(map, path, false, false); + SortedMap> result = new TreeMap>(INSTANCE); + for(Iterator>> iter = children.entrySet().iterator(); iter.hasNext(); iter = children.entrySet().iterator()){ + Map.Entry> entry = iter.next(); IPath childPath = entry.getKey(); result.put(childPath, entry.getValue()); diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/PerTypeMapStorage.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/PerTypeMapStorage.java index 6c1b8712521..57b668c0a3b 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/PerTypeMapStorage.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/PerTypeMapStorage.java @@ -15,6 +15,13 @@ import java.util.Map; import org.eclipse.cdt.managedbuilder.internal.core.IRealBuildObjectAssociation; +/** + * The class implements the storage of maps (Map) organized by types extending + * {@link IRealBuildObjectAssociation}. + * + * @param - the type of keys of the map + * @param - the type of values in the map + */ public class PerTypeMapStorage implements Cloneable { private ObjectTypeBasedStorage> fStorage = new ObjectTypeBasedStorage>(); diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/TcModificationUtil.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/TcModificationUtil.java index cdef57d4c5b..3fbb6b93d0a 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/TcModificationUtil.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/TcModificationUtil.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.cdt.managedbuilder.internal.tcmodification; -import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -43,7 +42,7 @@ import org.eclipse.core.runtime.IPath; public class TcModificationUtil { - private static void processFolderInfoChildren(FolderInfo foInfo, PerTypeMapStorage storage, IToolChain rtc, Map tcMap, Map toolMap, boolean addSkipInfo){ + private static void processFolderInfoChildren(FolderInfo foInfo, PerTypeMapStorage> storage, IToolChain rtc, Map> tcMap, Map> toolMap, boolean addSkipInfo){ IResourceInfo rcInfos[] = foInfo.getDirectChildResourceInfos(); for(int i = 0; i < rcInfos.length; i++){ IResourceInfo rc = rcInfos[i]; @@ -69,8 +68,8 @@ public class TcModificationUtil { } } - public static PerTypeMapStorage createChildObjectsRealToolToPathSet(FolderInfo foInfo, Map toolChainMap, Map toolsMap, boolean addSkipPaths){ - PerTypeMapStorage storage = new PerTypeMapStorage(); + public static PerTypeMapStorage> createChildObjectsRealToolToPathSet(FolderInfo foInfo, Map> toolChainMap, Map> toolsMap, boolean addSkipPaths){ + PerTypeMapStorage> storage = new PerTypeMapStorage>(); IToolChain tc = foInfo.getToolChain(); IToolChain rTc = ManagedBuildManager.getRealToolChain(tc); @@ -80,7 +79,7 @@ public class TcModificationUtil { toolChainMap.clear(); for(int i = 0; i < tools.length; i++){ - toolsMap.put(ManagedBuildManager.getRealTool(tools[i]), null); + toolsMap.put((Tool)ManagedBuildManager.getRealTool(tools[i]), null); } @@ -89,29 +88,28 @@ public class TcModificationUtil { return storage; } - public static PerTypeMapStorage createParentObjectsRealToolToPathSet(final FolderInfo foInfo){ - PerTypeMapStorage storage = new PerTypeMapStorage(); + public static PerTypeMapStorage> createParentObjectsRealToolToPathSet(final FolderInfo foInfo){ + PerTypeMapStorage> storage = new PerTypeMapStorage>(); IConfiguration cfg = foInfo.getParent(); FolderInfo rf = (FolderInfo)cfg.getRootFolderInfo(); IPath p = rf.getPath(); IBuilder realBuilder = ManagedBuildManager.getRealBuilder(cfg.getBuilder()); - Map map = storage.getMap(IRealBuildObjectAssociation.OBJECT_BUILDER, true); + Map> map = storage.getMap(IRealBuildObjectAssociation.OBJECT_BUILDER, true); Set pathSet = new TreeSet(PathComparator.INSTANCE); pathSet.add(p); - map.put(realBuilder, pathSet); + map.put((Builder)realBuilder, pathSet); IRealBuildObjectAssociation realCfg = ((Configuration)cfg).getRealBuildObject(); map = storage.getMap(IRealBuildObjectAssociation.OBJECT_CONFIGURATION, true); - pathSet = new TreeSet(PathComparator.INSTANCE); + pathSet = new TreeSet(PathComparator.INSTANCE); pathSet.add(p); map.put(realCfg, pathSet); if(!foInfo.isRoot()){ - Set allRcInfos = new HashSet(Arrays.asList(cfg.getResourceInfos())); + Set allRcInfos = new HashSet(Arrays.asList(cfg.getResourceInfos())); allRcInfos.removeAll(foInfo.getChildResourceInfoList(true)); - for(Iterator iter = allRcInfos.iterator(); iter.hasNext(); ){ - Object rc = iter.next(); + for (IResourceInfo rc : allRcInfos) { if(rc instanceof ResourceConfiguration){ processFileInfo(storage, (ResourceConfiguration)rc, null, false); } else { @@ -123,15 +121,19 @@ public class TcModificationUtil { return storage; } - public static PerTypeMapStorage cloneRealToolToPathSet(PerTypeMapStorage storage){ - storage = (PerTypeMapStorage)storage.clone(); + public static PerTypeMapStorage> cloneRealToolToPathSet(PerTypeMapStorage> storage){ + @SuppressWarnings("unchecked") + PerTypeMapStorage> cloneStorage = (PerTypeMapStorage>)storage.clone(); + storage = cloneStorage; int types[] = ObjectTypeBasedStorage.getSupportedObjectTypes(); for(int i = 0; i < types.length; i++){ - Map map = storage.getMap(types[i], false); + Map> map = storage.getMap(types[i], false); if(map != null){ - for(Iterator iter = map.entrySet().iterator(); iter.hasNext(); ){ - Map.Entry entry = (Map.Entry)iter.next(); - entry.setValue(((TreeSet)entry.getValue()).clone()); + Set>> entrySet = map.entrySet(); + for (Entry> entry : entrySet) { + @SuppressWarnings("unchecked") + Set clone = (Set) ((TreeSet)entry.getValue()).clone(); + entry.setValue(clone); } } } @@ -139,12 +141,12 @@ public class TcModificationUtil { return storage; } - public static PerTypeMapStorage createRealToolToPathSet(IConfiguration cfg, PerTypeMapStorage skipMapStorage, boolean addSkipPaths){ - PerTypeMapStorage storage = new PerTypeMapStorage(); + public static PerTypeMapStorage> createRealToolToPathSet(IConfiguration cfg, PerTypeMapStorage> skipMapStorage, boolean addSkipPaths){ + PerTypeMapStorage> storage = new PerTypeMapStorage>(); FolderInfo rf = (FolderInfo)cfg.getRootFolderInfo(); IPath p = rf.getPath(); - Map skipMap = skipMapStorage != null ? skipMapStorage.getMap(IRealBuildObjectAssociation.OBJECT_BUILDER, false) : null; + Map> skipMap = skipMapStorage != null ? skipMapStorage.getMap(IRealBuildObjectAssociation.OBJECT_BUILDER, false) : null; IBuilder realBuilder = ManagedBuildManager.getRealBuilder(cfg.getBuilder()); if(skipMap != null && skipMap.containsKey(realBuilder)){ if(addSkipPaths){ @@ -152,10 +154,10 @@ public class TcModificationUtil { set.add(p); } } else { - Map map = storage.getMap(IRealBuildObjectAssociation.OBJECT_BUILDER, true); + Map> map = storage.getMap(IRealBuildObjectAssociation.OBJECT_BUILDER, true); Set pathSet = new TreeSet(PathComparator.INSTANCE); pathSet.add(p); - map.put(realBuilder, pathSet); + map.put((Builder)realBuilder, pathSet); } skipMap = skipMapStorage != null ? skipMapStorage.getMap(IRealBuildObjectAssociation.OBJECT_CONFIGURATION, false) : null; @@ -166,7 +168,7 @@ public class TcModificationUtil { set.add(p); } } else { - Map map = storage.getMap(IRealBuildObjectAssociation.OBJECT_CONFIGURATION, true); + Map> map = storage.getMap(IRealBuildObjectAssociation.OBJECT_CONFIGURATION, true); Set pathSet = new TreeSet(PathComparator.INSTANCE); pathSet.add(p); map.put(realCfg, pathSet); @@ -186,43 +188,45 @@ public class TcModificationUtil { return storage; } - public static TreeMap createResultingChangesMap(TreeMap resultingMap, TreeMap initialMap){ + public static TreeMap> createResultingChangesMap(TreeMap> resultingMap, TreeMap> initialMap){ int[] types = new int []{ IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, IRealBuildObjectAssociation.OBJECT_BUILDER, IRealBuildObjectAssociation.OBJECT_TOOL, }; - TreeMap result = new TreeMap(PathComparator.INSTANCE); + TreeMap> result = new TreeMap>(PathComparator.INSTANCE); @SuppressWarnings("unchecked") - TreeMap clone = (TreeMap)initialMap.clone(); + TreeMap> clone = (TreeMap>)initialMap.clone(); initialMap = clone; - for (Entry entry : resultingMap.entrySet()) { + for (Entry> entry : resultingMap.entrySet()) { IPath oPath = entry.getKey(); - PerTypeSetStorage resStorage = entry.getValue(); - PerTypeSetStorage initStorage = initialMap.remove(oPath); - PerTypeSetStorage storage; + PerTypeSetStorage resStorage = entry.getValue(); + PerTypeSetStorage initStorage = initialMap.remove(oPath); + PerTypeSetStorage storage; if(initStorage == null || initStorage.isEmpty(true)){ if(resStorage != null && !resStorage.isEmpty(true)){ - storage = (PerTypeSetStorage)resStorage.clone(); + @SuppressWarnings("unchecked") + PerTypeSetStorage clone2 = (PerTypeSetStorage)resStorage.clone(); + storage = clone2; } else { - storage = new PerTypeSetStorage(); + storage = new PerTypeSetStorage(); } } else if(resStorage == null || resStorage.isEmpty(true)){ - storage = new PerTypeSetStorage(); + storage = new PerTypeSetStorage(); for(int i = 0; i < types.length; i++){ - Set set = initStorage.getSet(types[i], false); + Set set = initStorage.getSet(types[i], false); if(set != null && set.size() != 0){ storage.getSet(types[i], true); } } } else { - Set tcInitSet, resSet, setToStore; - Set bInitSet = null, tInitSet = null; - storage = new PerTypeSetStorage(); + Set tcInitSet, resSet, setToStore; + Set bInitSet = null, tInitSet = null; + storage = new PerTypeSetStorage(); tcInitSet = initStorage.getSet(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, false); resSet = resStorage.getSet(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, false); @@ -239,19 +243,19 @@ public class TcModificationUtil { IPath path = oPath; if(tc != null){ - tInitSet = new LinkedHashSet(); + tInitSet = new LinkedHashSet(); TcModificationUtil.getRealObjectsSet((Tool[])tc.getTools(), tInitSet); if(path.segmentCount() == 0){ - bInitSet = new LinkedHashSet(); + bInitSet = new LinkedHashSet(); IBuilder builder = tc.getBuilder(); if(builder != null){ - bInitSet.add(ManagedBuildManager.getRealBuilder(builder)); + bInitSet.add((Builder)ManagedBuildManager.getRealBuilder(builder)); } } } else { - tcInitSet = Collections.EMPTY_SET; + tcInitSet = Collections.emptySet(); if(path.segmentCount() == 0){ - bInitSet = Collections.EMPTY_SET; + bInitSet = Collections.emptySet(); } } } @@ -281,17 +285,17 @@ public class TcModificationUtil { } if(initialMap.size() != 0){ - for(Iterator iter = initialMap.entrySet().iterator(); iter.hasNext(); ){ - Map.Entry entry = (Map.Entry)iter.next(); - IPath oPath = (IPath) entry.getKey(); + Set>> entrySet = initialMap.entrySet(); + for (Entry> entry : entrySet) { + IPath oPath = entry.getKey(); - PerTypeSetStorage initStorage = (PerTypeSetStorage)entry.getValue(); + PerTypeSetStorage initStorage = entry.getValue(); if(!initStorage.isEmpty(true)){ - PerTypeSetStorage storage = new PerTypeSetStorage(); + PerTypeSetStorage storage = new PerTypeSetStorage(); for(int i = 0; i < types.length; i++){ - Set set = initStorage.getSet(types[i], false); + Set set = initStorage.getSet(types[i], false); if(set != null && set.size() != 0){ storage.getSet(types[i], true).addAll(set); } @@ -310,14 +314,14 @@ public class TcModificationUtil { return result; } - private static Set compareSets(Set resSet, Set initSet){ - Set result = null; + private static Set compareSets(Set resSet, Set initSet){ + Set result = null; if(initSet == null || initSet.isEmpty()){ if(resSet != null && !resSet.isEmpty()){ result = resSet; } } else if (resSet == null || resSet.isEmpty()){ - result = Collections.EMPTY_SET; + result = Collections.emptySet(); } else { if(!initSet.equals(resSet)){ result = resSet; @@ -327,17 +331,17 @@ public class TcModificationUtil { return result; } - private static void processFolderInfo(PerTypeMapStorage storage, FolderInfo info, PerTypeMapStorage skipMapStorage, boolean addSkipPaths){ + private static void processFolderInfo(PerTypeMapStorage> storage, FolderInfo info, PerTypeMapStorage> skipMapStorage, boolean addSkipPaths){ IPath p = info.getPath(); IToolChain rtc = ManagedBuildManager.getRealToolChain(info.getToolChain()); - Map skipMap = skipMapStorage != null ? skipMapStorage.getMap(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, false) : null; + Map> skipMap = skipMapStorage != null ? skipMapStorage.getMap(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, false) : null; if(skipMap != null && skipMap.containsKey(rtc)){ if(addSkipPaths){ Set set = getPathTreeSet(skipMap, (ToolChain)rtc); set.add(p); } } else { - Map map = storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, true); + Map> map = storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, true); Set set = getPathTreeSet(map, (ToolChain)rtc); set.add(p); } @@ -346,18 +350,18 @@ public class TcModificationUtil { processTools(storage, p, tools, skipMapStorage, addSkipPaths); } - public static IRealBuildObjectAssociation[] getRealObjects(IRealBuildObjectAssociation[] objs, Class clazz){ - LinkedHashSet set = new LinkedHashSet(); - for(int i = 0; i < objs.length; i++){ - set.add(objs[i].getRealBuildObject()); - } - Object[] array = (Object[])Array.newInstance(clazz, set.size()); - return (IRealBuildObjectAssociation[])set.toArray(array); - } +// public static IRealBuildObjectAssociation[] getRealObjects(IRealBuildObjectAssociation[] objs, Class clazz){ +// LinkedHashSet set = new LinkedHashSet(); +// for(int i = 0; i < objs.length; i++){ +// set.add(objs[i].getRealBuildObject()); +// } +// Object[] array = (Object[])Array.newInstance(clazz, set.size()); +// return (IRealBuildObjectAssociation[])set.toArray(array); +// } - public static Set getRealObjectsSet(IRealBuildObjectAssociation[] objs, Set set){ + public static Set getRealObjectsSet(IRealBuildObjectAssociation[] objs, Set set){ if(set == null) - set = new LinkedHashSet(); + set = new LinkedHashSet(); for(int i = 0; i < objs.length; i++){ set.add(objs[i].getRealBuildObject()); } @@ -373,20 +377,20 @@ public class TcModificationUtil { return map; } - private static void processFileInfo(PerTypeMapStorage storage, ResourceConfiguration info, PerTypeMapStorage skipMapStorage, boolean addSkipPaths){ + private static void processFileInfo(PerTypeMapStorage> storage, ResourceConfiguration info, PerTypeMapStorage> skipMapStorage, boolean addSkipPaths){ IPath p = info.getPath(); ITool[] tools = info.getTools(); processTools(storage, p, tools, skipMapStorage, addSkipPaths); } - private static void processTools(PerTypeMapStorage storage, IPath path, ITool[] tools, PerTypeMapStorage skipMapStorage, boolean addSkipPaths){ - Map map = storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, true); - Map skipMap = skipMapStorage != null ? skipMapStorage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, false) : null; + private static void processTools(PerTypeMapStorage> storage, IPath path, ITool[] tools, PerTypeMapStorage> skipMapStorage, boolean addSkipPaths){ + Map> map = storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, true); + Map> skipMap = skipMapStorage != null ? skipMapStorage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, false) : null; processTools(map, path, tools, skipMap, addSkipPaths); } - private static void processTools(Map storageMap, IPath path, ITool[] tools, Map skipMap, boolean addSkipPaths){ + private static void processTools(Map> storageMap, IPath path, ITool[] tools, Map> skipMap, boolean addSkipPaths){ for(int i = 0; i < tools.length; i++){ ITool rt = ManagedBuildManager.getRealTool(tools[i]); if(skipMap != null && skipMap.containsKey(rt)){ @@ -420,12 +424,12 @@ public class TcModificationUtil { return list; } - public static Object removeBuilderInfo(PerTypeMapStorage storage, IBuilder builder){ + public static Set removeBuilderInfo(PerTypeMapStorage> storage, IBuilder builder){ return storage.getMap(IRealBuildObjectAssociation.OBJECT_BUILDER, true).remove(builder); } - public static void restoreBuilderInfo(PerTypeMapStorage storage, IBuilder builder, Object obj){ - storage.getMap(IRealBuildObjectAssociation.OBJECT_BUILDER, true).put(builder, obj); + public static void restoreBuilderInfo(PerTypeMapStorage> storage, IBuilder builder, Set obj){ + storage.getMap(IRealBuildObjectAssociation.OBJECT_BUILDER, true).put((Builder)builder, obj); } // public static boolean removeToolInfo(PerTypeMapStorage storage, IPath path, ITool tool){ @@ -502,31 +506,31 @@ public class TcModificationUtil { objPaths.add(path); } - public static void applyBuilder(PerTypeMapStorage storage, IPath path, IBuilder builder){ - Map bMap = storage.getMap(IRealBuildObjectAssociation.OBJECT_BUILDER, true); + public static void applyBuilder(PerTypeMapStorage> storage, IPath path, IBuilder builder){ + Map> bMap = storage.getMap(IRealBuildObjectAssociation.OBJECT_BUILDER, true); bMap.clear(); IBuilder realBuilder = ManagedBuildManager.getRealBuilder(builder); Set set = getPathTreeSet(bMap, (Builder)realBuilder); set.add(path); } - public static void applyBuilder(TreeMap pathMap, IPath path, IBuilder builder){ - IBuilder realBuilder = ManagedBuildManager.getRealBuilder(builder); - PerTypeSetStorage storage = (PerTypeSetStorage)pathMap.get(path); - Set set = storage.getSet(IRealBuildObjectAssociation.OBJECT_BUILDER, true); - set.clear(); - set.add(realBuilder); - } +// public static void applyBuilder(TreeMap pathMap, IPath path, IBuilder builder){ +// IBuilder realBuilder = ManagedBuildManager.getRealBuilder(builder); +// PerTypeSetStorage storage = (PerTypeSetStorage)pathMap.get(path); +// Set set = storage.getSet(IRealBuildObjectAssociation.OBJECT_BUILDER, true); +// set.clear(); +// set.add(realBuilder); +// } - public static TreeMap createPathMap(IConfiguration cfg){ + public static TreeMap> createPathMap(IConfiguration cfg){ //TODO: optimize to calculate the map directly - PerTypeMapStorage storage = createRealToolToPathSet(cfg, null, false); + PerTypeMapStorage> storage = createRealToolToPathSet(cfg, null, false); return createPathMap(storage); } - public static TreeMap createPathMap(PerTypeMapStorage storage){ + public static TreeMap> createPathMap(PerTypeMapStorage> storage){ int[] types = ObjectTypeBasedStorage.getSupportedObjectTypes(); - TreeMap result = new TreeMap(PathComparator.INSTANCE); + TreeMap> result = new TreeMap>(PathComparator.INSTANCE); for(int i = 0; i < types.length; i++){ int type = types[i]; Map> map = storage.getMap(type, false); @@ -538,13 +542,12 @@ public class TcModificationUtil { IRealBuildObjectAssociation pathKey = entry.getKey(); Set pathSet = entry.getValue(); for (IPath path : pathSet) { - PerTypeSetStorage oset = result.get(path); + PerTypeSetStorage oset = result.get(path); if(oset == null){ - oset = new PerTypeSetStorage(); + oset = new PerTypeSetStorage(); result.put(path, oset); } - @SuppressWarnings("unchecked") Set set = oset.getSet(type, true); set.add(pathKey); } @@ -554,58 +557,58 @@ public class TcModificationUtil { return result; } - public static TreeMap clonePathMap(TreeMap map){ - map = (TreeMap)map.clone(); - - for(Iterator iter = map.entrySet().iterator(); iter.hasNext(); ){ - Map.Entry entry = (Map.Entry)iter.next(); - entry.setValue(((PerTypeSetStorage)entry.getValue()).clone()); - } - - return map; - } +// public static TreeMap clonePathMap(TreeMap map){ +// map = (TreeMap)map.clone(); +// +// for(Iterator iter = map.entrySet().iterator(); iter.hasNext(); ){ +// Map.Entry entry = (Map.Entry)iter.next(); +// entry.setValue(((PerTypeSetStorage)entry.getValue()).clone()); +// } +// +// return map; +// } - private static boolean pathContainsObjects(PerTypeMapStorage storage, IPath path, int type){ - Map map = storage.getMap(type, false); - if(map == null) - return false; - - for(Iterator iter = map.values().iterator(); iter.hasNext(); ){ - SortedSet set = (SortedSet)iter.next(); - if(set.contains(path)) - return true; - } - - return false; - } +// private static boolean pathContainsObjects(PerTypeMapStorage storage, IPath path, int type){ +// Map map = storage.getMap(type, false); +// if(map == null) +// return false; +// +// for(Iterator iter = map.values().iterator(); iter.hasNext(); ){ +// SortedSet set = (SortedSet)iter.next(); +// if(set.contains(path)) +// return true; +// } +// +// return false; +// } - public static SortedSet getDirectChildUsagePaths(PerTypeMapStorage storage, IPath path, IRealBuildObjectAssociation obj, SortedSet inclusionPaths){ - Map objMap = storage.getMap(obj.getType(), false); + public static SortedSet getDirectChildUsagePaths(PerTypeMapStorage> storage, IPath path, IRealBuildObjectAssociation obj, SortedSet inclusionPaths){ + Map> objMap = storage.getMap(obj.getType(), false); - SortedSet objPaths = (SortedSet)objMap.get(obj); + SortedSet objPaths = (SortedSet)objMap.get(obj); if(DbgTcmUtil.DEBUG){ if(!objPaths.contains(path)){ DbgTcmUtil.fail(); } } - SortedSet objChildPaths = PathComparator.getChildPathSet(objPaths, path, false, true); + SortedSet objChildPaths = PathComparator.getChildPathSet(objPaths, path, false, true); if(inclusionPaths != null) { objChildPaths.retainAll(inclusionPaths); } - for(Iterator iter = objMap.entrySet().iterator(); iter.hasNext(); ){ - Map.Entry entry = (Map.Entry)iter.next(); - Object cur = entry.getKey(); + for(Iterator>> iter = objMap.entrySet().iterator(); iter.hasNext(); ){ + Map.Entry> entry = iter.next(); + IRealBuildObjectAssociation cur = entry.getKey(); if(obj == cur) continue; - SortedSet curPaths = (SortedSet)entry.getValue(); + SortedSet curPaths = (SortedSet)entry.getValue(); curPaths = PathComparator.getChildPathSet(curPaths, path, false, false); - for(Iterator pathIter = objChildPaths.iterator(); pathIter.hasNext(); ){ - SortedSet sub = curPaths.tailSet(pathIter.next()); + for (IPath childPath : objChildPaths) { + SortedSet sub = curPaths.tailSet(childPath); if(sub.size() != 0) iter.remove(); } @@ -617,7 +620,7 @@ public class TcModificationUtil { } - public static boolean containCommonEntries(Set set, Object[] objs){ + public static boolean containCommonEntries(Set set, String[] objs){ for(int i = 0; i < objs.length; i++){ if(set.contains(objs[i])) return true; diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ToolListModification.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ToolListModification.java index d7c1c11f665..6675529fe2a 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ToolListModification.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ToolListModification.java @@ -59,8 +59,8 @@ public abstract class ToolListModification implements IToolListModification { private HashSet fFilteredOutSysTools; // private LinkedHashMap fRealToToolMap = new LinkedHashMap(); // private boolean fSysInfoMapInited; - private PerTypeMapStorage fCompleteObjectStorage; - protected TreeMap fCompletePathMapStorage; + private PerTypeMapStorage> fCompleteObjectStorage; + protected TreeMap> fCompletePathMapStorage; private HashSet fAddCapableTools; private Map fFilteredOutTools; @@ -164,10 +164,11 @@ public abstract class ToolListModification implements IToolListModification { if(DbgTcmUtil.DEBUG) DbgTcmUtil.println("calculating compatibility for tool " + fRealTool.getUniqueRealName()); //$NON-NLS-1$ - PerTypeMapStorage storage = getCompleteObjectStore(); + PerTypeMapStorage> storage = getCompleteObjectStore(); Tool tool = fRealTool; Set rmSet = getToolApplicabilityPathSet(tool, true); - Map> toolMap = storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, false); + @SuppressWarnings("unchecked") + Map> toolMap = (Map>) storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, false); try { if(rmSet != null && rmSet.size() != 0) TcModificationUtil.removePaths(toolMap, tool, rmSet); @@ -175,11 +176,13 @@ public abstract class ToolListModification implements IToolListModification { if(DbgTcmUtil.DEBUG) DbgTcmUtil.dumpStorage(storage); - ConflictMatchSet conflicts = ToolChainModificationManager.getInstance().getConflictInfo(IRealBuildObjectAssociation.OBJECT_TOOL, storage); + @SuppressWarnings("unchecked") + ConflictMatchSet conflicts = ToolChainModificationManager.getInstance().getConflictInfo(IRealBuildObjectAssociation.OBJECT_TOOL, (PerTypeMapStorage>) storage); fCompatibleTools = new HashMap(); fInCompatibleTools = new HashMap(); Tool sysTools[] = getTools(false, true); + @SuppressWarnings("unchecked") Map> conflictMap = (Map>) conflicts.fObjToConflictListMap; for(int i = 0; i < sysTools.length; i++){ Tool t = sysTools[i]; @@ -368,7 +371,7 @@ public abstract class ToolListModification implements IToolListModification { private Set getAddCompatibleSysTools(){ if(fAddCapableTools == null){ fAddCapableTools = new HashSet(Arrays.asList(getAllSysTools())); - PerTypeMapStorage storage = getCompleteObjectStore(); + PerTypeMapStorage> storage = getCompleteObjectStore(); ConflictMatchSet conflicts = ToolChainModificationManager.getInstance().getConflictInfo(IRealBuildObjectAssociation.OBJECT_TOOL, storage); fAddCapableTools.removeAll(conflicts.fObjToConflictListMap.keySet()); } @@ -383,8 +386,10 @@ public abstract class ToolListModification implements IToolListModification { public ToolListModification(ResourceInfo rcInfo, ToolListModification base){ fRcInfo = rcInfo; Tool[] initialTools = (Tool[])rcInfo.getTools(); + @SuppressWarnings("unchecked") Map initRealToToolMap = (Map) TcModificationUtil.getRealToObjectsMap(initialTools, null); Tool[] updatedTools = base.getTools(true, false); + @SuppressWarnings("unchecked") Map updatedRealToToolMap = (Map) TcModificationUtil.getRealToObjectsMap(updatedTools, null); Set> entrySet = updatedRealToToolMap.entrySet(); for (Entry entry : entrySet) { @@ -502,13 +507,13 @@ public abstract class ToolListModification implements IToolListModification { } public final void apply() throws CoreException { - TreeMap initialMap = TcModificationUtil.createPathMap(fRcInfo.getParent()); - TreeMap cur = getCompletePathMapStorage(); - TreeMap result = TcModificationUtil.createResultingChangesMap(cur, initialMap); + TreeMap> initialMap = TcModificationUtil.createPathMap(fRcInfo.getParent()); + TreeMap> cur = getCompletePathMapStorage(); + TreeMap> result = TcModificationUtil.createResultingChangesMap(cur, initialMap); apply(result); } - private void apply(TreeMap resultingChangeMap) throws CoreException { + private void apply(TreeMap> resultingChangeMap) throws CoreException { //the order matters here: we first should process tool-chain than a builder and then tools int types[] = new int[]{ IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, @@ -518,17 +523,17 @@ public abstract class ToolListModification implements IToolListModification { int type; IConfiguration cfg = fRcInfo.getParent(); - Set> entrySet = resultingChangeMap.entrySet(); - for (Entry entry : entrySet) { + Set>> entrySet = resultingChangeMap.entrySet(); + for (Entry> entry : entrySet) { IPath path = entry.getKey(); ResourceInfo rcInfo = (ResourceInfo)cfg.getResourceInfo(path, true); if(rcInfo == null){ rcInfo = (FolderInfo)cfg.createFolderInfo(path); } - PerTypeSetStorage storage = entry.getValue(); + PerTypeSetStorage storage = entry.getValue(); for(int i = 0; i < types.length; i++){ type = types[i]; - Set set = storage.getSet(type, false); + Set set = storage.getSet(type, false); if(set != null){ apply(rcInfo, type, set); } @@ -654,8 +659,9 @@ public abstract class ToolListModification implements IToolListModification { list.addAll(map.values()); clearToolInfo(map.values().toArray(new Tool[map.size()])); - PerTypeMapStorage storage = getCompleteObjectStore(); - Map> toolMap = storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, true); + PerTypeMapStorage> storage = getCompleteObjectStore(); + @SuppressWarnings("unchecked") + Map> toolMap = (Map>) storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, true); if(rmSet != null) TcModificationUtil.removePaths(toolMap, realRemoved, rmSet); if(addSet != null) @@ -700,7 +706,9 @@ public abstract class ToolListModification implements IToolListModification { } filteredTools = filterTools(allTools); + @SuppressWarnings("unchecked") Map filteredMap = (Map) TcModificationUtil.getRealToObjectsMap(filteredTools, null); + @SuppressWarnings("unchecked") Map allMap = (Map) TcModificationUtil.getRealToObjectsMap(allTools, null); allMap.keySet().removeAll(filteredMap.keySet()); fFilteredOutTools = allMap; @@ -728,7 +736,7 @@ public abstract class ToolListModification implements IToolListModification { fCompletePathMapStorage = null; } - protected PerTypeMapStorage getCompleteObjectStore(){ + protected PerTypeMapStorage> getCompleteObjectStore(){ if(fCompleteObjectStorage == null){ fCompleteObjectStorage = TcModificationUtil.createRealToolToPathSet(fRcInfo.getParent(), null, false); if(DbgTcmUtil.DEBUG){ @@ -739,7 +747,7 @@ public abstract class ToolListModification implements IToolListModification { return fCompleteObjectStorage; } - protected TreeMap getCompletePathMapStorage(){ + protected TreeMap> getCompletePathMapStorage(){ if(fCompletePathMapStorage == null){ fCompletePathMapStorage = TcModificationUtil.createPathMap(getCompleteObjectStore()); }