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

bug 319512: Missing type arguments on managedbuilder.core

This commit is contained in:
Andrew Gvozdev 2010-10-20 16:07:39 +00:00
parent a24bb7ea72
commit de6703334b
8 changed files with 197 additions and 173 deletions

View file

@ -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.internal.tcmodification.ToolChainModificationManager.ConflictMatchSet;
import org.eclipse.cdt.managedbuilder.tcmodification.CompatibilityStatus; import org.eclipse.cdt.managedbuilder.tcmodification.CompatibilityStatus;
import org.eclipse.cdt.managedbuilder.tcmodification.IConfigurationModification; import org.eclipse.cdt.managedbuilder.tcmodification.IConfigurationModification;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
public class ConfigurationModification extends FolderInfoModification implements public class ConfigurationModification extends FolderInfoModification implements
@ -104,8 +105,8 @@ public class ConfigurationModification extends FolderInfoModification implements
private ConflictMatchSet getParentConflictMatchSet(){ private ConflictMatchSet getParentConflictMatchSet(){
if(fConflicts == null){ if(fConflicts == null){
PerTypeMapStorage storage = getCompleteObjectStore(); PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>> storage = getCompleteObjectStore();
Object restore = TcModificationUtil.removeBuilderInfo(storage, fRealBuilder); Set<IPath> restore = TcModificationUtil.removeBuilderInfo(storage, fRealBuilder);
try { try {
fConflicts = ToolChainModificationManager.getInstance().getConflictInfo(IRealBuildObjectAssociation.OBJECT_BUILDER, storage); fConflicts = ToolChainModificationManager.getInstance().getConflictInfo(IRealBuildObjectAssociation.OBJECT_BUILDER, storage);
} finally { } finally {
@ -187,7 +188,7 @@ public class ConfigurationModification extends FolderInfoModification implements
fRealBuilder = realBuilder; fRealBuilder = realBuilder;
fCompletePathMapStorage = null; fCompletePathMapStorage = null;
PerTypeMapStorage storage = getCompleteObjectStore(); PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>> storage = getCompleteObjectStore();
TcModificationUtil.applyBuilder(storage, getResourceInfo().getPath(), fSelectedBuilder); TcModificationUtil.applyBuilder(storage, getResourceInfo().getPath(), fSelectedBuilder);
clearBuilderCompatibilityInfo(); clearBuilderCompatibilityInfo();

View file

@ -30,13 +30,13 @@ public class ConflictSet {
private PerTypeMapStorage<IRealBuildObjectAssociation, Conflict> fConflictStorage; private PerTypeMapStorage<IRealBuildObjectAssociation, Conflict> fConflictStorage;
private List<ConflictMatch> fConflictMatchList; private List<ConflictMatch> fConflictMatchList;
private Set<? extends IRealBuildObjectAssociation> fExtConflictSet; // private Set<IRealBuildObjectAssociation> fExtConflictSet;
private IRealBuildObjectAssociation fRealObj; // private IRealBuildObjectAssociation fRealObj;
public ConflictSet(IRealBuildObjectAssociation realObj, List<ConflictMatch> conflictMatchList, Set<? extends IRealBuildObjectAssociation> extConflictSet){ public ConflictSet(IRealBuildObjectAssociation realObj, List<ConflictMatch> conflictMatchList, Set<? extends IRealBuildObjectAssociation> extConflictSet){
fConflictMatchList = conflictMatchList; fConflictMatchList = conflictMatchList;
fExtConflictSet = extConflictSet; // fExtConflictSet = (Set<IRealBuildObjectAssociation>) extConflictSet;
fRealObj = realObj; // fRealObj = realObj;
} }
private void init(){ private void init(){

View file

@ -11,12 +11,13 @@
package org.eclipse.cdt.managedbuilder.internal.tcmodification; package org.eclipse.cdt.managedbuilder.internal.tcmodification;
import java.io.PrintStream; import java.io.PrintStream;
import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import org.eclipse.cdt.managedbuilder.internal.core.IRealBuildObjectAssociation; import org.eclipse.cdt.managedbuilder.internal.core.IRealBuildObjectAssociation;
import org.eclipse.cdt.managedbuilder.internal.tcmodification.extension.MatchObjectElement; import org.eclipse.cdt.managedbuilder.internal.tcmodification.extension.MatchObjectElement;
import org.eclipse.core.runtime.IPath;
public class DbgTcmUtil { public class DbgTcmUtil {
private static final PrintStream OUT = System.out; private static final PrintStream OUT = System.out;
@ -67,7 +68,7 @@ public class DbgTcmUtil {
throw e; throw e;
} }
public static void dumpStorage(PerTypeMapStorage storage){ public static void dumpStorage(PerTypeMapStorage<? extends IRealBuildObjectAssociation, Set<IPath>> storage){
println("starting storage dump.."); //$NON-NLS-1$ println("starting storage dump.."); //$NON-NLS-1$
int[] types = ObjectTypeBasedStorage.getSupportedObjectTypes(); int[] types = ObjectTypeBasedStorage.getSupportedObjectTypes();
for(int i = 0; i < types.length; i++){ for(int i = 0; i < types.length; i++){
@ -78,16 +79,17 @@ public class DbgTcmUtil {
println(" dumping for type " + assoc.getString()); //$NON-NLS-1$ println(" dumping for type " + assoc.getString()); //$NON-NLS-1$
Map map = storage.getMap(type, false); @SuppressWarnings("unchecked")
Map<IRealBuildObjectAssociation, Set<IPath>> map = (Map<IRealBuildObjectAssociation, Set<IPath>>) storage.getMap(type, false);
if(map != null){ if(map != null){
for(Iterator iter = map.entrySet().iterator(); iter.hasNext(); ){ Set<Entry<IRealBuildObjectAssociation, Set<IPath>>> entrySet = map.entrySet();
Map.Entry entry = (Map.Entry)iter.next(); for (Entry<IRealBuildObjectAssociation, Set<IPath>> entry : entrySet) {
IRealBuildObjectAssociation obj = (IRealBuildObjectAssociation)entry.getKey(); IRealBuildObjectAssociation obj = entry.getKey();
println(" dumping " + assoc.getString() + " " + obj.getUniqueRealName()); //$NON-NLS-1$ //$NON-NLS-2$ println(" dumping " + assoc.getString() + " " + obj.getUniqueRealName()); //$NON-NLS-1$ //$NON-NLS-2$
Set set = (Set)entry.getValue(); Set<IPath> set = entry.getValue();
if(set != null){ if(set != null){
for(Iterator setIter = set.iterator(); setIter.hasNext(); ){ for (IPath path : set) {
println(" path \"" + setIter.next() + "\""); //$NON-NLS-1$ //$NON-NLS-2$ println(" path \"" + path + "\""); //$NON-NLS-1$ //$NON-NLS-2$
} }
} }
println(" end dumping " + obj.getUniqueRealName()); //$NON-NLS-1$ println(" end dumping " + obj.getUniqueRealName()); //$NON-NLS-1$

View file

@ -307,9 +307,9 @@ public class FolderInfoModification extends ToolListModification implements IFol
ToolChainApplicabilityPaths tcApplicabilityPaths = new ToolChainApplicabilityPaths(); ToolChainApplicabilityPaths tcApplicabilityPaths = new ToolChainApplicabilityPaths();
IPath path = getResourceInfo().getPath(); IPath path = getResourceInfo().getPath();
TreeMap<IPath, PerTypeSetStorage> pathMap = getCompletePathMapStorage(); TreeMap<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>> pathMap = getCompletePathMapStorage();
PerTypeSetStorage oSet = pathMap.get(path); PerTypeSetStorage<? extends IRealBuildObjectAssociation> oSet = pathMap.get(path);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Set<Tool> toolSet = (Set<Tool>) oSet.getSet(IRealBuildObjectAssociation.OBJECT_TOOL, false); Set<Tool> toolSet = (Set<Tool>) oSet.getSet(IRealBuildObjectAssociation.OBJECT_TOOL, false);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -356,11 +356,11 @@ public class FolderInfoModification extends ToolListModification implements IFol
} }
} }
private static void calculateChildPaths(TreeMap<IPath, PerTypeSetStorage> pathMap, IPath path, ToolChain tc, Set<IPath> tcPaths, Map<Tool,Set<IPath>> toolPathsMap, Set<IPath> fileInfoPaths){ private static void calculateChildPaths(TreeMap<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>> pathMap, IPath path, ToolChain tc, Set<IPath> tcPaths, Map<Tool,Set<IPath>> toolPathsMap, Set<IPath> fileInfoPaths){
SortedMap<IPath, PerTypeSetStorage> directCMap = PathComparator.getDirectChildPathMap(pathMap, path); SortedMap<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>> directCMap = PathComparator.getDirectChildPathMap(pathMap, path);
Set<Entry<IPath, PerTypeSetStorage>> entrySet = directCMap.entrySet(); Set<Entry<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>>> entrySet = directCMap.entrySet();
for (Entry<IPath, PerTypeSetStorage> entry : entrySet) { for (Entry<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>> entry : entrySet) {
PerTypeSetStorage cst = entry.getValue(); PerTypeSetStorage<? extends IRealBuildObjectAssociation> cst = entry.getValue();
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Set<ToolChain> ctc = (Set<ToolChain>) cst.getSet(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, false); Set<ToolChain> ctc = (Set<ToolChain>) cst.getSet(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, false);
@ -389,7 +389,9 @@ public class FolderInfoModification extends ToolListModification implements IFol
ToolChainApplicabilityPaths tcApplicability = getToolChainApplicabilityPaths(); ToolChainApplicabilityPaths tcApplicability = getToolChainApplicabilityPaths();
PerTypeMapStorage<? extends IRealBuildObjectAssociation, Set<IPath>> storage = getCompleteObjectStore(); PerTypeMapStorage<? extends IRealBuildObjectAssociation, Set<IPath>> storage = getCompleteObjectStore();
@SuppressWarnings("unchecked")
Map<ToolChain, Set<IPath>> tcMap = (Map<ToolChain, Set<IPath>>) storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, false); Map<ToolChain, Set<IPath>> tcMap = (Map<ToolChain, Set<IPath>>) storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, false);
@SuppressWarnings("unchecked")
Map<Tool, Set<IPath>> toolMap = (Map<Tool, Set<IPath>>) storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, false); Map<Tool, Set<IPath>> toolMap = (Map<Tool, Set<IPath>>) storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, false);

View file

@ -18,6 +18,7 @@ import java.util.SortedSet;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.TreeSet; import java.util.TreeSet;
import org.eclipse.cdt.managedbuilder.internal.core.IRealBuildObjectAssociation;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
public class PathComparator implements Comparator<IPath> { public class PathComparator implements Comparator<IPath> {
@ -69,12 +70,12 @@ public class PathComparator implements Comparator<IPath> {
return path.append("\0"); //$NON-NLS-1$ return path.append("\0"); //$NON-NLS-1$
} }
public static SortedMap<IPath, PerTypeSetStorage> getChildPathMap(SortedMap<IPath, PerTypeSetStorage> map, IPath path, boolean includeThis, boolean copy){ public static SortedMap<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>> getChildPathMap(SortedMap<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>> map, IPath path, boolean includeThis, boolean copy){
IPath start = includeThis ? path : getFirstChild(path); IPath start = includeThis ? path : getFirstChild(path);
IPath next = getNext(path); IPath next = getNext(path);
SortedMap<IPath, PerTypeSetStorage> result = next != null ? map.subMap(start, next) : map.tailMap(start); SortedMap<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>> result = next != null ? map.subMap(start, next) : map.tailMap(start);
if(copy) if(copy)
result = new TreeMap<IPath, PerTypeSetStorage>(result); result = new TreeMap<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>>(result);
return result; return result;
} }
@ -99,12 +100,12 @@ public class PathComparator implements Comparator<IPath> {
return result; return result;
} }
public static SortedMap<IPath,PerTypeSetStorage> getDirectChildPathMap(SortedMap<IPath, PerTypeSetStorage> map, IPath path){ public static SortedMap<IPath,PerTypeSetStorage<IRealBuildObjectAssociation>> getDirectChildPathMap(SortedMap<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>> map, IPath path){
//all children //all children
SortedMap<IPath,PerTypeSetStorage> children = getChildPathMap(map, path, false, false); SortedMap<IPath,PerTypeSetStorage<IRealBuildObjectAssociation>> children = getChildPathMap(map, path, false, false);
SortedMap<IPath,PerTypeSetStorage> result = new TreeMap<IPath, PerTypeSetStorage>(INSTANCE); SortedMap<IPath,PerTypeSetStorage<IRealBuildObjectAssociation>> result = new TreeMap<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>>(INSTANCE);
for(Iterator<Map.Entry<IPath,PerTypeSetStorage>> iter = children.entrySet().iterator(); iter.hasNext(); iter = children.entrySet().iterator()){ for(Iterator<Map.Entry<IPath,PerTypeSetStorage<IRealBuildObjectAssociation>>> iter = children.entrySet().iterator(); iter.hasNext(); iter = children.entrySet().iterator()){
Map.Entry<IPath,PerTypeSetStorage> entry = iter.next(); Map.Entry<IPath,PerTypeSetStorage<IRealBuildObjectAssociation>> entry = iter.next();
IPath childPath = entry.getKey(); IPath childPath = entry.getKey();
result.put(childPath, entry.getValue()); result.put(childPath, entry.getValue());

View file

@ -15,6 +15,13 @@ import java.util.Map;
import org.eclipse.cdt.managedbuilder.internal.core.IRealBuildObjectAssociation; import org.eclipse.cdt.managedbuilder.internal.core.IRealBuildObjectAssociation;
/**
* The class implements the storage of maps (Map<K, V>) organized by types extending
* {@link IRealBuildObjectAssociation}.
*
* @param <K> - the type of keys of the map
* @param <V> - the type of values in the map
*/
public class PerTypeMapStorage<K extends IRealBuildObjectAssociation, V> implements Cloneable { public class PerTypeMapStorage<K extends IRealBuildObjectAssociation, V> implements Cloneable {
private ObjectTypeBasedStorage<Map<K, V>> fStorage = new ObjectTypeBasedStorage<Map<K, V>>(); private ObjectTypeBasedStorage<Map<K, V>> fStorage = new ObjectTypeBasedStorage<Map<K, V>>();

View file

@ -10,7 +10,6 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.tcmodification; package org.eclipse.cdt.managedbuilder.internal.tcmodification;
import java.lang.reflect.Array;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
@ -43,7 +42,7 @@ import org.eclipse.core.runtime.IPath;
public class TcModificationUtil { 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<IRealBuildObjectAssociation, Set<IPath>> storage, IToolChain rtc, Map<IRealBuildObjectAssociation, Set<IPath>> tcMap, Map<IRealBuildObjectAssociation, Set<IPath>> toolMap, boolean addSkipInfo){
IResourceInfo rcInfos[] = foInfo.getDirectChildResourceInfos(); IResourceInfo rcInfos[] = foInfo.getDirectChildResourceInfos();
for(int i = 0; i < rcInfos.length; i++){ for(int i = 0; i < rcInfos.length; i++){
IResourceInfo rc = rcInfos[i]; IResourceInfo rc = rcInfos[i];
@ -69,8 +68,8 @@ public class TcModificationUtil {
} }
} }
public static PerTypeMapStorage createChildObjectsRealToolToPathSet(FolderInfo foInfo, Map toolChainMap, Map toolsMap, boolean addSkipPaths){ public static PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>> createChildObjectsRealToolToPathSet(FolderInfo foInfo, Map<IRealBuildObjectAssociation, Set<IPath>> toolChainMap, Map<IRealBuildObjectAssociation, Set<IPath>> toolsMap, boolean addSkipPaths){
PerTypeMapStorage storage = new PerTypeMapStorage(); PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>> storage = new PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>>();
IToolChain tc = foInfo.getToolChain(); IToolChain tc = foInfo.getToolChain();
IToolChain rTc = ManagedBuildManager.getRealToolChain(tc); IToolChain rTc = ManagedBuildManager.getRealToolChain(tc);
@ -80,7 +79,7 @@ public class TcModificationUtil {
toolChainMap.clear(); toolChainMap.clear();
for(int i = 0; i < tools.length; i++){ 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; return storage;
} }
public static PerTypeMapStorage createParentObjectsRealToolToPathSet(final FolderInfo foInfo){ public static PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>> createParentObjectsRealToolToPathSet(final FolderInfo foInfo){
PerTypeMapStorage storage = new PerTypeMapStorage(); PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>> storage = new PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>>();
IConfiguration cfg = foInfo.getParent(); IConfiguration cfg = foInfo.getParent();
FolderInfo rf = (FolderInfo)cfg.getRootFolderInfo(); FolderInfo rf = (FolderInfo)cfg.getRootFolderInfo();
IPath p = rf.getPath(); IPath p = rf.getPath();
IBuilder realBuilder = ManagedBuildManager.getRealBuilder(cfg.getBuilder()); IBuilder realBuilder = ManagedBuildManager.getRealBuilder(cfg.getBuilder());
Map map = storage.getMap(IRealBuildObjectAssociation.OBJECT_BUILDER, true); Map<IRealBuildObjectAssociation, Set<IPath>> map = storage.getMap(IRealBuildObjectAssociation.OBJECT_BUILDER, true);
Set<IPath> pathSet = new TreeSet<IPath>(PathComparator.INSTANCE); Set<IPath> pathSet = new TreeSet<IPath>(PathComparator.INSTANCE);
pathSet.add(p); pathSet.add(p);
map.put(realBuilder, pathSet); map.put((Builder)realBuilder, pathSet);
IRealBuildObjectAssociation realCfg = ((Configuration)cfg).getRealBuildObject(); IRealBuildObjectAssociation realCfg = ((Configuration)cfg).getRealBuildObject();
map = storage.getMap(IRealBuildObjectAssociation.OBJECT_CONFIGURATION, true); map = storage.getMap(IRealBuildObjectAssociation.OBJECT_CONFIGURATION, true);
pathSet = new TreeSet(PathComparator.INSTANCE); pathSet = new TreeSet<IPath>(PathComparator.INSTANCE);
pathSet.add(p); pathSet.add(p);
map.put(realCfg, pathSet); map.put(realCfg, pathSet);
if(!foInfo.isRoot()){ if(!foInfo.isRoot()){
Set allRcInfos = new HashSet(Arrays.asList(cfg.getResourceInfos())); Set<IResourceInfo> allRcInfos = new HashSet<IResourceInfo>(Arrays.asList(cfg.getResourceInfos()));
allRcInfos.removeAll(foInfo.getChildResourceInfoList(true)); allRcInfos.removeAll(foInfo.getChildResourceInfoList(true));
for(Iterator iter = allRcInfos.iterator(); iter.hasNext(); ){ for (IResourceInfo rc : allRcInfos) {
Object rc = iter.next();
if(rc instanceof ResourceConfiguration){ if(rc instanceof ResourceConfiguration){
processFileInfo(storage, (ResourceConfiguration)rc, null, false); processFileInfo(storage, (ResourceConfiguration)rc, null, false);
} else { } else {
@ -123,15 +121,19 @@ public class TcModificationUtil {
return storage; return storage;
} }
public static PerTypeMapStorage cloneRealToolToPathSet(PerTypeMapStorage storage){ public static PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>> cloneRealToolToPathSet(PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>> storage){
storage = (PerTypeMapStorage)storage.clone(); @SuppressWarnings("unchecked")
PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>> cloneStorage = (PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>>)storage.clone();
storage = cloneStorage;
int types[] = ObjectTypeBasedStorage.getSupportedObjectTypes(); int types[] = ObjectTypeBasedStorage.getSupportedObjectTypes();
for(int i = 0; i < types.length; i++){ for(int i = 0; i < types.length; i++){
Map map = storage.getMap(types[i], false); Map<IRealBuildObjectAssociation, Set<IPath>> map = storage.getMap(types[i], false);
if(map != null){ if(map != null){
for(Iterator iter = map.entrySet().iterator(); iter.hasNext(); ){ Set<Entry<IRealBuildObjectAssociation, Set<IPath>>> entrySet = map.entrySet();
Map.Entry entry = (Map.Entry)iter.next(); for (Entry<IRealBuildObjectAssociation, Set<IPath>> entry : entrySet) {
entry.setValue(((TreeSet)entry.getValue()).clone()); @SuppressWarnings("unchecked")
Set<IPath> clone = (Set<IPath>) ((TreeSet<IPath>)entry.getValue()).clone();
entry.setValue(clone);
} }
} }
} }
@ -139,12 +141,12 @@ public class TcModificationUtil {
return storage; return storage;
} }
public static PerTypeMapStorage createRealToolToPathSet(IConfiguration cfg, PerTypeMapStorage skipMapStorage, boolean addSkipPaths){ public static PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>> createRealToolToPathSet(IConfiguration cfg, PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>> skipMapStorage, boolean addSkipPaths){
PerTypeMapStorage storage = new PerTypeMapStorage(); PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>> storage = new PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>>();
FolderInfo rf = (FolderInfo)cfg.getRootFolderInfo(); FolderInfo rf = (FolderInfo)cfg.getRootFolderInfo();
IPath p = rf.getPath(); IPath p = rf.getPath();
Map skipMap = skipMapStorage != null ? skipMapStorage.getMap(IRealBuildObjectAssociation.OBJECT_BUILDER, false) : null; Map<IRealBuildObjectAssociation, Set<IPath>> skipMap = skipMapStorage != null ? skipMapStorage.getMap(IRealBuildObjectAssociation.OBJECT_BUILDER, false) : null;
IBuilder realBuilder = ManagedBuildManager.getRealBuilder(cfg.getBuilder()); IBuilder realBuilder = ManagedBuildManager.getRealBuilder(cfg.getBuilder());
if(skipMap != null && skipMap.containsKey(realBuilder)){ if(skipMap != null && skipMap.containsKey(realBuilder)){
if(addSkipPaths){ if(addSkipPaths){
@ -152,10 +154,10 @@ public class TcModificationUtil {
set.add(p); set.add(p);
} }
} else { } else {
Map map = storage.getMap(IRealBuildObjectAssociation.OBJECT_BUILDER, true); Map<IRealBuildObjectAssociation, Set<IPath>> map = storage.getMap(IRealBuildObjectAssociation.OBJECT_BUILDER, true);
Set<IPath> pathSet = new TreeSet<IPath>(PathComparator.INSTANCE); Set<IPath> pathSet = new TreeSet<IPath>(PathComparator.INSTANCE);
pathSet.add(p); pathSet.add(p);
map.put(realBuilder, pathSet); map.put((Builder)realBuilder, pathSet);
} }
skipMap = skipMapStorage != null ? skipMapStorage.getMap(IRealBuildObjectAssociation.OBJECT_CONFIGURATION, false) : null; skipMap = skipMapStorage != null ? skipMapStorage.getMap(IRealBuildObjectAssociation.OBJECT_CONFIGURATION, false) : null;
@ -166,7 +168,7 @@ public class TcModificationUtil {
set.add(p); set.add(p);
} }
} else { } else {
Map map = storage.getMap(IRealBuildObjectAssociation.OBJECT_CONFIGURATION, true); Map<IRealBuildObjectAssociation, Set<IPath>> map = storage.getMap(IRealBuildObjectAssociation.OBJECT_CONFIGURATION, true);
Set<IPath> pathSet = new TreeSet<IPath>(PathComparator.INSTANCE); Set<IPath> pathSet = new TreeSet<IPath>(PathComparator.INSTANCE);
pathSet.add(p); pathSet.add(p);
map.put(realCfg, pathSet); map.put(realCfg, pathSet);
@ -186,43 +188,45 @@ public class TcModificationUtil {
return storage; return storage;
} }
public static TreeMap<IPath, PerTypeSetStorage> createResultingChangesMap(TreeMap<IPath, PerTypeSetStorage> resultingMap, TreeMap<IPath, PerTypeSetStorage> initialMap){ public static TreeMap<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>> createResultingChangesMap(TreeMap<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>> resultingMap, TreeMap<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>> initialMap){
int[] types = new int []{ int[] types = new int []{
IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, IRealBuildObjectAssociation.OBJECT_TOOLCHAIN,
IRealBuildObjectAssociation.OBJECT_BUILDER, IRealBuildObjectAssociation.OBJECT_BUILDER,
IRealBuildObjectAssociation.OBJECT_TOOL, IRealBuildObjectAssociation.OBJECT_TOOL,
}; };
TreeMap<IPath, PerTypeSetStorage> result = new TreeMap<IPath, PerTypeSetStorage>(PathComparator.INSTANCE); TreeMap<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>> result = new TreeMap<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>>(PathComparator.INSTANCE);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
TreeMap<IPath, PerTypeSetStorage> clone = (TreeMap<IPath, PerTypeSetStorage>)initialMap.clone(); TreeMap<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>> clone = (TreeMap<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>>)initialMap.clone();
initialMap = clone; initialMap = clone;
for (Entry<IPath, PerTypeSetStorage> entry : resultingMap.entrySet()) { for (Entry<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>> entry : resultingMap.entrySet()) {
IPath oPath = entry.getKey(); IPath oPath = entry.getKey();
PerTypeSetStorage resStorage = entry.getValue(); PerTypeSetStorage<IRealBuildObjectAssociation> resStorage = entry.getValue();
PerTypeSetStorage initStorage = initialMap.remove(oPath); PerTypeSetStorage<IRealBuildObjectAssociation> initStorage = initialMap.remove(oPath);
PerTypeSetStorage storage; PerTypeSetStorage<IRealBuildObjectAssociation> storage;
if(initStorage == null || initStorage.isEmpty(true)){ if(initStorage == null || initStorage.isEmpty(true)){
if(resStorage != null && !resStorage.isEmpty(true)){ if(resStorage != null && !resStorage.isEmpty(true)){
storage = (PerTypeSetStorage)resStorage.clone(); @SuppressWarnings("unchecked")
PerTypeSetStorage<IRealBuildObjectAssociation> clone2 = (PerTypeSetStorage<IRealBuildObjectAssociation>)resStorage.clone();
storage = clone2;
} else { } else {
storage = new PerTypeSetStorage(); storage = new PerTypeSetStorage<IRealBuildObjectAssociation>();
} }
} else if(resStorage == null || resStorage.isEmpty(true)){ } else if(resStorage == null || resStorage.isEmpty(true)){
storage = new PerTypeSetStorage(); storage = new PerTypeSetStorage<IRealBuildObjectAssociation>();
for(int i = 0; i < types.length; i++){ for(int i = 0; i < types.length; i++){
Set set = initStorage.getSet(types[i], false); Set<IRealBuildObjectAssociation> set = initStorage.getSet(types[i], false);
if(set != null && set.size() != 0){ if(set != null && set.size() != 0){
storage.getSet(types[i], true); storage.getSet(types[i], true);
} }
} }
} else { } else {
Set tcInitSet, resSet, setToStore; Set<IRealBuildObjectAssociation> tcInitSet, resSet, setToStore;
Set bInitSet = null, tInitSet = null; Set<IRealBuildObjectAssociation> bInitSet = null, tInitSet = null;
storage = new PerTypeSetStorage(); storage = new PerTypeSetStorage<IRealBuildObjectAssociation>();
tcInitSet = initStorage.getSet(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, false); tcInitSet = initStorage.getSet(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, false);
resSet = resStorage.getSet(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, false); resSet = resStorage.getSet(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, false);
@ -239,19 +243,19 @@ public class TcModificationUtil {
IPath path = oPath; IPath path = oPath;
if(tc != null){ if(tc != null){
tInitSet = new LinkedHashSet(); tInitSet = new LinkedHashSet<IRealBuildObjectAssociation>();
TcModificationUtil.getRealObjectsSet((Tool[])tc.getTools(), tInitSet); TcModificationUtil.getRealObjectsSet((Tool[])tc.getTools(), tInitSet);
if(path.segmentCount() == 0){ if(path.segmentCount() == 0){
bInitSet = new LinkedHashSet(); bInitSet = new LinkedHashSet<IRealBuildObjectAssociation>();
IBuilder builder = tc.getBuilder(); IBuilder builder = tc.getBuilder();
if(builder != null){ if(builder != null){
bInitSet.add(ManagedBuildManager.getRealBuilder(builder)); bInitSet.add((Builder)ManagedBuildManager.getRealBuilder(builder));
} }
} }
} else { } else {
tcInitSet = Collections.EMPTY_SET; tcInitSet = Collections.emptySet();
if(path.segmentCount() == 0){ if(path.segmentCount() == 0){
bInitSet = Collections.EMPTY_SET; bInitSet = Collections.emptySet();
} }
} }
} }
@ -281,17 +285,17 @@ public class TcModificationUtil {
} }
if(initialMap.size() != 0){ if(initialMap.size() != 0){
for(Iterator iter = initialMap.entrySet().iterator(); iter.hasNext(); ){ Set<Entry<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>>> entrySet = initialMap.entrySet();
Map.Entry entry = (Map.Entry)iter.next(); for (Entry<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>> entry : entrySet) {
IPath oPath = (IPath) entry.getKey(); IPath oPath = entry.getKey();
PerTypeSetStorage initStorage = (PerTypeSetStorage)entry.getValue(); PerTypeSetStorage<IRealBuildObjectAssociation> initStorage = entry.getValue();
if(!initStorage.isEmpty(true)){ if(!initStorage.isEmpty(true)){
PerTypeSetStorage storage = new PerTypeSetStorage(); PerTypeSetStorage<IRealBuildObjectAssociation> storage = new PerTypeSetStorage<IRealBuildObjectAssociation>();
for(int i = 0; i < types.length; i++){ for(int i = 0; i < types.length; i++){
Set set = initStorage.getSet(types[i], false); Set<IRealBuildObjectAssociation> set = initStorage.getSet(types[i], false);
if(set != null && set.size() != 0){ if(set != null && set.size() != 0){
storage.getSet(types[i], true).addAll(set); storage.getSet(types[i], true).addAll(set);
} }
@ -310,14 +314,14 @@ public class TcModificationUtil {
return result; return result;
} }
private static Set compareSets(Set resSet, Set initSet){ private static Set<IRealBuildObjectAssociation> compareSets(Set<IRealBuildObjectAssociation> resSet, Set<IRealBuildObjectAssociation> initSet){
Set result = null; Set<IRealBuildObjectAssociation> result = null;
if(initSet == null || initSet.isEmpty()){ if(initSet == null || initSet.isEmpty()){
if(resSet != null && !resSet.isEmpty()){ if(resSet != null && !resSet.isEmpty()){
result = resSet; result = resSet;
} }
} else if (resSet == null || resSet.isEmpty()){ } else if (resSet == null || resSet.isEmpty()){
result = Collections.EMPTY_SET; result = Collections.emptySet();
} else { } else {
if(!initSet.equals(resSet)){ if(!initSet.equals(resSet)){
result = resSet; result = resSet;
@ -327,17 +331,17 @@ public class TcModificationUtil {
return result; return result;
} }
private static void processFolderInfo(PerTypeMapStorage storage, FolderInfo info, PerTypeMapStorage skipMapStorage, boolean addSkipPaths){ private static void processFolderInfo(PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>> storage, FolderInfo info, PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>> skipMapStorage, boolean addSkipPaths){
IPath p = info.getPath(); IPath p = info.getPath();
IToolChain rtc = ManagedBuildManager.getRealToolChain(info.getToolChain()); IToolChain rtc = ManagedBuildManager.getRealToolChain(info.getToolChain());
Map skipMap = skipMapStorage != null ? skipMapStorage.getMap(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, false) : null; Map<IRealBuildObjectAssociation, Set<IPath>> skipMap = skipMapStorage != null ? skipMapStorage.getMap(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, false) : null;
if(skipMap != null && skipMap.containsKey(rtc)){ if(skipMap != null && skipMap.containsKey(rtc)){
if(addSkipPaths){ if(addSkipPaths){
Set<IPath> set = getPathTreeSet(skipMap, (ToolChain)rtc); Set<IPath> set = getPathTreeSet(skipMap, (ToolChain)rtc);
set.add(p); set.add(p);
} }
} else { } else {
Map map = storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, true); Map<IRealBuildObjectAssociation, Set<IPath>> map = storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, true);
Set<IPath> set = getPathTreeSet(map, (ToolChain)rtc); Set<IPath> set = getPathTreeSet(map, (ToolChain)rtc);
set.add(p); set.add(p);
} }
@ -346,18 +350,18 @@ public class TcModificationUtil {
processTools(storage, p, tools, skipMapStorage, addSkipPaths); processTools(storage, p, tools, skipMapStorage, addSkipPaths);
} }
public static IRealBuildObjectAssociation[] getRealObjects(IRealBuildObjectAssociation[] objs, Class clazz){ // public static IRealBuildObjectAssociation[] getRealObjects(IRealBuildObjectAssociation[] objs, Class clazz){
LinkedHashSet set = new LinkedHashSet(); // LinkedHashSet set = new LinkedHashSet();
for(int i = 0; i < objs.length; i++){ // for(int i = 0; i < objs.length; i++){
set.add(objs[i].getRealBuildObject()); // set.add(objs[i].getRealBuildObject());
} // }
Object[] array = (Object[])Array.newInstance(clazz, set.size()); // Object[] array = (Object[])Array.newInstance(clazz, set.size());
return (IRealBuildObjectAssociation[])set.toArray(array); // return (IRealBuildObjectAssociation[])set.toArray(array);
} // }
public static Set getRealObjectsSet(IRealBuildObjectAssociation[] objs, Set set){ public static Set<IRealBuildObjectAssociation> getRealObjectsSet(IRealBuildObjectAssociation[] objs, Set<IRealBuildObjectAssociation> set){
if(set == null) if(set == null)
set = new LinkedHashSet(); set = new LinkedHashSet<IRealBuildObjectAssociation>();
for(int i = 0; i < objs.length; i++){ for(int i = 0; i < objs.length; i++){
set.add(objs[i].getRealBuildObject()); set.add(objs[i].getRealBuildObject());
} }
@ -373,20 +377,20 @@ public class TcModificationUtil {
return map; return map;
} }
private static void processFileInfo(PerTypeMapStorage storage, ResourceConfiguration info, PerTypeMapStorage skipMapStorage, boolean addSkipPaths){ private static void processFileInfo(PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>> storage, ResourceConfiguration info, PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>> skipMapStorage, boolean addSkipPaths){
IPath p = info.getPath(); IPath p = info.getPath();
ITool[] tools = info.getTools(); ITool[] tools = info.getTools();
processTools(storage, p, tools, skipMapStorage, addSkipPaths); processTools(storage, p, tools, skipMapStorage, addSkipPaths);
} }
private static void processTools(PerTypeMapStorage storage, IPath path, ITool[] tools, PerTypeMapStorage skipMapStorage, boolean addSkipPaths){ private static void processTools(PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>> storage, IPath path, ITool[] tools, PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>> skipMapStorage, boolean addSkipPaths){
Map map = storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, true); Map<IRealBuildObjectAssociation, Set<IPath>> map = storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, true);
Map skipMap = skipMapStorage != null ? skipMapStorage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, false) : null; Map<IRealBuildObjectAssociation, Set<IPath>> skipMap = skipMapStorage != null ? skipMapStorage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, false) : null;
processTools(map, path, tools, skipMap, addSkipPaths); 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<IRealBuildObjectAssociation, Set<IPath>> storageMap, IPath path, ITool[] tools, Map<IRealBuildObjectAssociation, Set<IPath>> skipMap, boolean addSkipPaths){
for(int i = 0; i < tools.length; i++){ for(int i = 0; i < tools.length; i++){
ITool rt = ManagedBuildManager.getRealTool(tools[i]); ITool rt = ManagedBuildManager.getRealTool(tools[i]);
if(skipMap != null && skipMap.containsKey(rt)){ if(skipMap != null && skipMap.containsKey(rt)){
@ -420,12 +424,12 @@ public class TcModificationUtil {
return list; return list;
} }
public static Object removeBuilderInfo(PerTypeMapStorage storage, IBuilder builder){ public static Set<IPath> removeBuilderInfo(PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>> storage, IBuilder builder){
return storage.getMap(IRealBuildObjectAssociation.OBJECT_BUILDER, true).remove(builder); return storage.getMap(IRealBuildObjectAssociation.OBJECT_BUILDER, true).remove(builder);
} }
public static void restoreBuilderInfo(PerTypeMapStorage storage, IBuilder builder, Object obj){ public static void restoreBuilderInfo(PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>> storage, IBuilder builder, Set<IPath> obj){
storage.getMap(IRealBuildObjectAssociation.OBJECT_BUILDER, true).put(builder, obj); storage.getMap(IRealBuildObjectAssociation.OBJECT_BUILDER, true).put((Builder)builder, obj);
} }
// public static boolean removeToolInfo(PerTypeMapStorage storage, IPath path, ITool tool){ // public static boolean removeToolInfo(PerTypeMapStorage storage, IPath path, ITool tool){
@ -502,31 +506,31 @@ public class TcModificationUtil {
objPaths.add(path); objPaths.add(path);
} }
public static void applyBuilder(PerTypeMapStorage storage, IPath path, IBuilder builder){ public static void applyBuilder(PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>> storage, IPath path, IBuilder builder){
Map bMap = storage.getMap(IRealBuildObjectAssociation.OBJECT_BUILDER, true); Map<IRealBuildObjectAssociation, Set<IPath>> bMap = storage.getMap(IRealBuildObjectAssociation.OBJECT_BUILDER, true);
bMap.clear(); bMap.clear();
IBuilder realBuilder = ManagedBuildManager.getRealBuilder(builder); IBuilder realBuilder = ManagedBuildManager.getRealBuilder(builder);
Set<IPath> set = getPathTreeSet(bMap, (Builder)realBuilder); Set<IPath> set = getPathTreeSet(bMap, (Builder)realBuilder);
set.add(path); set.add(path);
} }
public static void applyBuilder(TreeMap pathMap, IPath path, IBuilder builder){ // public static void applyBuilder(TreeMap pathMap, IPath path, IBuilder builder){
IBuilder realBuilder = ManagedBuildManager.getRealBuilder(builder); // IBuilder realBuilder = ManagedBuildManager.getRealBuilder(builder);
PerTypeSetStorage storage = (PerTypeSetStorage)pathMap.get(path); // PerTypeSetStorage storage = (PerTypeSetStorage)pathMap.get(path);
Set set = storage.getSet(IRealBuildObjectAssociation.OBJECT_BUILDER, true); // Set set = storage.getSet(IRealBuildObjectAssociation.OBJECT_BUILDER, true);
set.clear(); // set.clear();
set.add(realBuilder); // set.add(realBuilder);
} // }
public static TreeMap<IPath, PerTypeSetStorage> createPathMap(IConfiguration cfg){ public static TreeMap<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>> createPathMap(IConfiguration cfg){
//TODO: optimize to calculate the map directly //TODO: optimize to calculate the map directly
PerTypeMapStorage storage = createRealToolToPathSet(cfg, null, false); PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>> storage = createRealToolToPathSet(cfg, null, false);
return createPathMap(storage); return createPathMap(storage);
} }
public static TreeMap<IPath,PerTypeSetStorage> createPathMap(PerTypeMapStorage storage){ public static TreeMap<IPath,PerTypeSetStorage<IRealBuildObjectAssociation>> createPathMap(PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>> storage){
int[] types = ObjectTypeBasedStorage.getSupportedObjectTypes(); int[] types = ObjectTypeBasedStorage.getSupportedObjectTypes();
TreeMap<IPath,PerTypeSetStorage> result = new TreeMap<IPath,PerTypeSetStorage>(PathComparator.INSTANCE); TreeMap<IPath,PerTypeSetStorage<IRealBuildObjectAssociation>> result = new TreeMap<IPath,PerTypeSetStorage<IRealBuildObjectAssociation>>(PathComparator.INSTANCE);
for(int i = 0; i < types.length; i++){ for(int i = 0; i < types.length; i++){
int type = types[i]; int type = types[i];
Map<IRealBuildObjectAssociation, Set<IPath>> map = storage.getMap(type, false); Map<IRealBuildObjectAssociation, Set<IPath>> map = storage.getMap(type, false);
@ -538,13 +542,12 @@ public class TcModificationUtil {
IRealBuildObjectAssociation pathKey = entry.getKey(); IRealBuildObjectAssociation pathKey = entry.getKey();
Set<IPath> pathSet = entry.getValue(); Set<IPath> pathSet = entry.getValue();
for (IPath path : pathSet) { for (IPath path : pathSet) {
PerTypeSetStorage oset = result.get(path); PerTypeSetStorage<IRealBuildObjectAssociation> oset = result.get(path);
if(oset == null){ if(oset == null){
oset = new PerTypeSetStorage(); oset = new PerTypeSetStorage<IRealBuildObjectAssociation>();
result.put(path, oset); result.put(path, oset);
} }
@SuppressWarnings("unchecked")
Set<IRealBuildObjectAssociation> set = oset.getSet(type, true); Set<IRealBuildObjectAssociation> set = oset.getSet(type, true);
set.add(pathKey); set.add(pathKey);
} }
@ -554,58 +557,58 @@ public class TcModificationUtil {
return result; return result;
} }
public static TreeMap clonePathMap(TreeMap map){ // public static TreeMap clonePathMap(TreeMap map){
map = (TreeMap)map.clone(); // 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;
// }
for(Iterator iter = map.entrySet().iterator(); iter.hasNext(); ){ // private static boolean pathContainsObjects(PerTypeMapStorage storage, IPath path, int type){
Map.Entry entry = (Map.Entry)iter.next(); // Map map = storage.getMap(type, false);
entry.setValue(((PerTypeSetStorage)entry.getValue()).clone()); // 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;
// }
return map; public static SortedSet<IPath> getDirectChildUsagePaths(PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>> storage, IPath path, IRealBuildObjectAssociation obj, SortedSet<IPath> inclusionPaths){
} Map<IRealBuildObjectAssociation, Set<IPath>> objMap = storage.getMap(obj.getType(), false);
private static boolean pathContainsObjects(PerTypeMapStorage storage, IPath path, int type){ SortedSet<IPath> objPaths = (SortedSet<IPath>)objMap.get(obj);
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);
SortedSet objPaths = (SortedSet)objMap.get(obj);
if(DbgTcmUtil.DEBUG){ if(DbgTcmUtil.DEBUG){
if(!objPaths.contains(path)){ if(!objPaths.contains(path)){
DbgTcmUtil.fail(); DbgTcmUtil.fail();
} }
} }
SortedSet objChildPaths = PathComparator.getChildPathSet(objPaths, path, false, true); SortedSet<IPath> objChildPaths = PathComparator.getChildPathSet(objPaths, path, false, true);
if(inclusionPaths != null) { if(inclusionPaths != null) {
objChildPaths.retainAll(inclusionPaths); objChildPaths.retainAll(inclusionPaths);
} }
for(Iterator iter = objMap.entrySet().iterator(); iter.hasNext(); ){ for(Iterator<Entry<IRealBuildObjectAssociation, Set<IPath>>> iter = objMap.entrySet().iterator(); iter.hasNext(); ){
Map.Entry entry = (Map.Entry)iter.next(); Map.Entry<IRealBuildObjectAssociation, Set<IPath>> entry = iter.next();
Object cur = entry.getKey(); IRealBuildObjectAssociation cur = entry.getKey();
if(obj == cur) if(obj == cur)
continue; continue;
SortedSet curPaths = (SortedSet)entry.getValue(); SortedSet<IPath> curPaths = (SortedSet<IPath>)entry.getValue();
curPaths = PathComparator.getChildPathSet(curPaths, path, false, false); curPaths = PathComparator.getChildPathSet(curPaths, path, false, false);
for(Iterator pathIter = objChildPaths.iterator(); pathIter.hasNext(); ){ for (IPath childPath : objChildPaths) {
SortedSet sub = curPaths.tailSet(pathIter.next()); SortedSet<IPath> sub = curPaths.tailSet(childPath);
if(sub.size() != 0) if(sub.size() != 0)
iter.remove(); iter.remove();
} }
@ -617,7 +620,7 @@ public class TcModificationUtil {
} }
public static boolean containCommonEntries(Set set, Object[] objs){ public static boolean containCommonEntries(Set<String> set, String[] objs){
for(int i = 0; i < objs.length; i++){ for(int i = 0; i < objs.length; i++){
if(set.contains(objs[i])) if(set.contains(objs[i]))
return true; return true;

View file

@ -59,8 +59,8 @@ public abstract class ToolListModification implements IToolListModification {
private HashSet<ITool> fFilteredOutSysTools; private HashSet<ITool> fFilteredOutSysTools;
// private LinkedHashMap fRealToToolMap = new LinkedHashMap(); // private LinkedHashMap fRealToToolMap = new LinkedHashMap();
// private boolean fSysInfoMapInited; // private boolean fSysInfoMapInited;
private PerTypeMapStorage fCompleteObjectStorage; private PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>> fCompleteObjectStorage;
protected TreeMap<IPath, PerTypeSetStorage> fCompletePathMapStorage; protected TreeMap<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>> fCompletePathMapStorage;
private HashSet<Tool> fAddCapableTools; private HashSet<Tool> fAddCapableTools;
private Map<Tool, Tool> fFilteredOutTools; private Map<Tool, Tool> fFilteredOutTools;
@ -164,10 +164,11 @@ public abstract class ToolListModification implements IToolListModification {
if(DbgTcmUtil.DEBUG) if(DbgTcmUtil.DEBUG)
DbgTcmUtil.println("calculating compatibility for tool " + fRealTool.getUniqueRealName()); //$NON-NLS-1$ DbgTcmUtil.println("calculating compatibility for tool " + fRealTool.getUniqueRealName()); //$NON-NLS-1$
PerTypeMapStorage storage = getCompleteObjectStore(); PerTypeMapStorage<? extends IRealBuildObjectAssociation, Set<IPath>> storage = getCompleteObjectStore();
Tool tool = fRealTool; Tool tool = fRealTool;
Set<IPath> rmSet = getToolApplicabilityPathSet(tool, true); Set<IPath> rmSet = getToolApplicabilityPathSet(tool, true);
Map<Tool, Set<IPath>> toolMap = storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, false); @SuppressWarnings("unchecked")
Map<Tool, Set<IPath>> toolMap = (Map<Tool, Set<IPath>>) storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, false);
try { try {
if(rmSet != null && rmSet.size() != 0) if(rmSet != null && rmSet.size() != 0)
TcModificationUtil.removePaths(toolMap, tool, rmSet); TcModificationUtil.removePaths(toolMap, tool, rmSet);
@ -175,11 +176,13 @@ public abstract class ToolListModification implements IToolListModification {
if(DbgTcmUtil.DEBUG) if(DbgTcmUtil.DEBUG)
DbgTcmUtil.dumpStorage(storage); DbgTcmUtil.dumpStorage(storage);
ConflictMatchSet conflicts = ToolChainModificationManager.getInstance().getConflictInfo(IRealBuildObjectAssociation.OBJECT_TOOL, storage); @SuppressWarnings("unchecked")
ConflictMatchSet conflicts = ToolChainModificationManager.getInstance().getConflictInfo(IRealBuildObjectAssociation.OBJECT_TOOL, (PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>>) storage);
fCompatibleTools = new HashMap<Tool, ToolCompatibilityInfoElement>(); fCompatibleTools = new HashMap<Tool, ToolCompatibilityInfoElement>();
fInCompatibleTools = new HashMap<Tool, ToolCompatibilityInfoElement>(); fInCompatibleTools = new HashMap<Tool, ToolCompatibilityInfoElement>();
Tool sysTools[] = getTools(false, true); Tool sysTools[] = getTools(false, true);
@SuppressWarnings("unchecked")
Map<Tool, List<ConflictMatch>> conflictMap = (Map<Tool, List<ConflictMatch>>) conflicts.fObjToConflictListMap; Map<Tool, List<ConflictMatch>> conflictMap = (Map<Tool, List<ConflictMatch>>) conflicts.fObjToConflictListMap;
for(int i = 0; i < sysTools.length; i++){ for(int i = 0; i < sysTools.length; i++){
Tool t = sysTools[i]; Tool t = sysTools[i];
@ -368,7 +371,7 @@ public abstract class ToolListModification implements IToolListModification {
private Set<Tool> getAddCompatibleSysTools(){ private Set<Tool> getAddCompatibleSysTools(){
if(fAddCapableTools == null){ if(fAddCapableTools == null){
fAddCapableTools = new HashSet<Tool>(Arrays.asList(getAllSysTools())); fAddCapableTools = new HashSet<Tool>(Arrays.asList(getAllSysTools()));
PerTypeMapStorage storage = getCompleteObjectStore(); PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>> storage = getCompleteObjectStore();
ConflictMatchSet conflicts = ToolChainModificationManager.getInstance().getConflictInfo(IRealBuildObjectAssociation.OBJECT_TOOL, storage); ConflictMatchSet conflicts = ToolChainModificationManager.getInstance().getConflictInfo(IRealBuildObjectAssociation.OBJECT_TOOL, storage);
fAddCapableTools.removeAll(conflicts.fObjToConflictListMap.keySet()); fAddCapableTools.removeAll(conflicts.fObjToConflictListMap.keySet());
} }
@ -383,8 +386,10 @@ public abstract class ToolListModification implements IToolListModification {
public ToolListModification(ResourceInfo rcInfo, ToolListModification base){ public ToolListModification(ResourceInfo rcInfo, ToolListModification base){
fRcInfo = rcInfo; fRcInfo = rcInfo;
Tool[] initialTools = (Tool[])rcInfo.getTools(); Tool[] initialTools = (Tool[])rcInfo.getTools();
@SuppressWarnings("unchecked")
Map<Tool, Tool> initRealToToolMap = (Map<Tool, Tool>) TcModificationUtil.getRealToObjectsMap(initialTools, null); Map<Tool, Tool> initRealToToolMap = (Map<Tool, Tool>) TcModificationUtil.getRealToObjectsMap(initialTools, null);
Tool[] updatedTools = base.getTools(true, false); Tool[] updatedTools = base.getTools(true, false);
@SuppressWarnings("unchecked")
Map<Tool, Tool> updatedRealToToolMap = (Map<Tool, Tool>) TcModificationUtil.getRealToObjectsMap(updatedTools, null); Map<Tool, Tool> updatedRealToToolMap = (Map<Tool, Tool>) TcModificationUtil.getRealToObjectsMap(updatedTools, null);
Set<Entry<Tool, Tool>> entrySet = updatedRealToToolMap.entrySet(); Set<Entry<Tool, Tool>> entrySet = updatedRealToToolMap.entrySet();
for (Entry<Tool, Tool> entry : entrySet) { for (Entry<Tool, Tool> entry : entrySet) {
@ -502,13 +507,13 @@ public abstract class ToolListModification implements IToolListModification {
} }
public final void apply() throws CoreException { public final void apply() throws CoreException {
TreeMap<IPath, PerTypeSetStorage> initialMap = TcModificationUtil.createPathMap(fRcInfo.getParent()); TreeMap<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>> initialMap = TcModificationUtil.createPathMap(fRcInfo.getParent());
TreeMap<IPath, PerTypeSetStorage> cur = getCompletePathMapStorage(); TreeMap<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>> cur = getCompletePathMapStorage();
TreeMap<IPath, PerTypeSetStorage> result = TcModificationUtil.createResultingChangesMap(cur, initialMap); TreeMap<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>> result = TcModificationUtil.createResultingChangesMap(cur, initialMap);
apply(result); apply(result);
} }
private void apply(TreeMap<IPath, PerTypeSetStorage> resultingChangeMap) throws CoreException { private void apply(TreeMap<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>> resultingChangeMap) throws CoreException {
//the order matters here: we first should process tool-chain than a builder and then tools //the order matters here: we first should process tool-chain than a builder and then tools
int types[] = new int[]{ int types[] = new int[]{
IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, IRealBuildObjectAssociation.OBJECT_TOOLCHAIN,
@ -518,17 +523,17 @@ public abstract class ToolListModification implements IToolListModification {
int type; int type;
IConfiguration cfg = fRcInfo.getParent(); IConfiguration cfg = fRcInfo.getParent();
Set<Entry<IPath, PerTypeSetStorage>> entrySet = resultingChangeMap.entrySet(); Set<Entry<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>>> entrySet = resultingChangeMap.entrySet();
for (Entry<IPath, PerTypeSetStorage> entry : entrySet) { for (Entry<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>> entry : entrySet) {
IPath path = entry.getKey(); IPath path = entry.getKey();
ResourceInfo rcInfo = (ResourceInfo)cfg.getResourceInfo(path, true); ResourceInfo rcInfo = (ResourceInfo)cfg.getResourceInfo(path, true);
if(rcInfo == null){ if(rcInfo == null){
rcInfo = (FolderInfo)cfg.createFolderInfo(path); rcInfo = (FolderInfo)cfg.createFolderInfo(path);
} }
PerTypeSetStorage storage = entry.getValue(); PerTypeSetStorage<IRealBuildObjectAssociation> storage = entry.getValue();
for(int i = 0; i < types.length; i++){ for(int i = 0; i < types.length; i++){
type = types[i]; type = types[i];
Set<? extends IRealBuildObjectAssociation> set = storage.getSet(type, false); Set<IRealBuildObjectAssociation> set = storage.getSet(type, false);
if(set != null){ if(set != null){
apply(rcInfo, type, set); apply(rcInfo, type, set);
} }
@ -654,8 +659,9 @@ public abstract class ToolListModification implements IToolListModification {
list.addAll(map.values()); list.addAll(map.values());
clearToolInfo(map.values().toArray(new Tool[map.size()])); clearToolInfo(map.values().toArray(new Tool[map.size()]));
PerTypeMapStorage storage = getCompleteObjectStore(); PerTypeMapStorage<? extends IRealBuildObjectAssociation, Set<IPath>> storage = getCompleteObjectStore();
Map<Tool, Set<IPath>> toolMap = storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, true); @SuppressWarnings("unchecked")
Map<Tool, Set<IPath>> toolMap = (Map<Tool, Set<IPath>>) storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, true);
if(rmSet != null) if(rmSet != null)
TcModificationUtil.removePaths(toolMap, realRemoved, rmSet); TcModificationUtil.removePaths(toolMap, realRemoved, rmSet);
if(addSet != null) if(addSet != null)
@ -700,7 +706,9 @@ public abstract class ToolListModification implements IToolListModification {
} }
filteredTools = filterTools(allTools); filteredTools = filterTools(allTools);
@SuppressWarnings("unchecked")
Map<Tool, Tool> filteredMap = (Map<Tool, Tool>) TcModificationUtil.getRealToObjectsMap(filteredTools, null); Map<Tool, Tool> filteredMap = (Map<Tool, Tool>) TcModificationUtil.getRealToObjectsMap(filteredTools, null);
@SuppressWarnings("unchecked")
Map<Tool, Tool> allMap = (Map<Tool, Tool>) TcModificationUtil.getRealToObjectsMap(allTools, null); Map<Tool, Tool> allMap = (Map<Tool, Tool>) TcModificationUtil.getRealToObjectsMap(allTools, null);
allMap.keySet().removeAll(filteredMap.keySet()); allMap.keySet().removeAll(filteredMap.keySet());
fFilteredOutTools = allMap; fFilteredOutTools = allMap;
@ -728,7 +736,7 @@ public abstract class ToolListModification implements IToolListModification {
fCompletePathMapStorage = null; fCompletePathMapStorage = null;
} }
protected PerTypeMapStorage getCompleteObjectStore(){ protected PerTypeMapStorage<IRealBuildObjectAssociation, Set<IPath>> getCompleteObjectStore(){
if(fCompleteObjectStorage == null){ if(fCompleteObjectStorage == null){
fCompleteObjectStorage = TcModificationUtil.createRealToolToPathSet(fRcInfo.getParent(), null, false); fCompleteObjectStorage = TcModificationUtil.createRealToolToPathSet(fRcInfo.getParent(), null, false);
if(DbgTcmUtil.DEBUG){ if(DbgTcmUtil.DEBUG){
@ -739,7 +747,7 @@ public abstract class ToolListModification implements IToolListModification {
return fCompleteObjectStorage; return fCompleteObjectStorage;
} }
protected TreeMap<IPath, PerTypeSetStorage> getCompletePathMapStorage(){ protected TreeMap<IPath, PerTypeSetStorage<IRealBuildObjectAssociation>> getCompletePathMapStorage(){
if(fCompletePathMapStorage == null){ if(fCompletePathMapStorage == null){
fCompletePathMapStorage = TcModificationUtil.createPathMap(getCompleteObjectStore()); fCompletePathMapStorage = TcModificationUtil.createPathMap(getCompleteObjectStore());
} }