diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/FileInfoModification.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/FileInfoModification.java index 755dcb9c3e0..b814b673770 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/FileInfoModification.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/FileInfoModification.java @@ -21,11 +21,12 @@ import org.eclipse.cdt.managedbuilder.internal.core.ResourceConfiguration; import org.eclipse.cdt.managedbuilder.internal.core.Tool; import org.eclipse.cdt.managedbuilder.tcmodification.IFileInfoModification; import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.IPath; public class FileInfoModification extends ToolListModification implements IFileInfoModification { private String fFileExt; - private Set fApplPathSet; + private Set fApplPathSet; private IProject fProject; public FileInfoModification(ResourceConfiguration rcInfo) { @@ -54,9 +55,9 @@ public class FileInfoModification extends } @Override - protected Set getToolApplicabilityPathSet(Tool realTool, boolean isProject) { + protected Set getToolApplicabilityPathSet(Tool realTool, boolean isProject) { if(fApplPathSet == null){ - Set s = new HashSet(1); + Set s = new HashSet(1); s.add(getResourceInfo().getPath()); fApplPathSet = Collections.unmodifiableSet(s); } @@ -64,8 +65,8 @@ public class FileInfoModification extends } @Override - protected Set getExtensionConflictToolSet(Tool tool, Tool[] toos) { - return Collections.EMPTY_SET; + protected Set getExtensionConflictToolSet(Tool tool, Tool[] toos) { + return Collections.emptySet(); } @Override 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 780db85a907..d9d8240be03 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 @@ -18,6 +18,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; @@ -29,12 +30,14 @@ import org.eclipse.cdt.managedbuilder.core.IResourceInfo; import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.IToolChain; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.cdt.managedbuilder.internal.core.Builder; import org.eclipse.cdt.managedbuilder.internal.core.FolderInfo; import org.eclipse.cdt.managedbuilder.internal.core.IRealBuildObjectAssociation; import org.eclipse.cdt.managedbuilder.internal.core.ResourceInfo; import org.eclipse.cdt.managedbuilder.internal.core.Tool; import org.eclipse.cdt.managedbuilder.internal.core.ToolChain; import org.eclipse.cdt.managedbuilder.internal.dataprovider.ConfigurationDataProvider; +import org.eclipse.cdt.managedbuilder.internal.tcmodification.ToolChainModificationManager.ConflictMatch; import org.eclipse.cdt.managedbuilder.internal.tcmodification.ToolChainModificationManager.ConflictMatchSet; import org.eclipse.cdt.managedbuilder.tcmodification.CompatibilityStatus; import org.eclipse.cdt.managedbuilder.tcmodification.IFolderInfoModification; @@ -47,8 +50,8 @@ public class FolderInfoModification extends ToolListModification implements IFol private ToolChainCompatibilityInfoElement fCurrentCompatibilityInfo; private ToolChain fSelectedToolChain; private IToolChain[] fAllSysToolChains; - private Map fCompatibleToolChains; - private Map fInCompatibleToolChains; + private Map fCompatibleToolChains; + private Map fInCompatibleToolChains; private PerTypeMapStorage fParentObjectStorage; private ConflictMatchSet fParentConflicts; // private PerTypeMapStorage fChildObjectStorage; @@ -93,18 +96,18 @@ public class FolderInfoModification extends ToolListModification implements IFol } private static class ToolChainApplicabilityPaths { - private Set fFileInfoPaths = new HashSet(); - private Set fFolderInfoPaths = new HashSet(); - private Map fToolPathMap = new HashMap(); + private Set fFileInfoPaths = new HashSet(); + private Set fFolderInfoPaths = new HashSet(); + private Map> fToolPathMap = new HashMap>(); } public static class ToolChainCompatibilityInfoElement { private ToolChain fTc; - private List fErrComflictMatchList; - private List fWarningConflictMatchList; + private List fErrComflictMatchList; +// private List fWarningConflictMatchList; private CompatibilityStatus fStatus; - ToolChainCompatibilityInfoElement(ToolChain tc, List errConflictList){ + ToolChainCompatibilityInfoElement(ToolChain tc, List errConflictList){ fTc = tc; if(errConflictList != null && errConflictList.size() != 0) fErrComflictMatchList = errConflictList; @@ -135,14 +138,13 @@ public class FolderInfoModification extends ToolListModification implements IFol initCompatibilityInfo(); FolderInfo foInfo = (FolderInfo)getResourceInfo(); - List l = new ArrayList(fCompatibleToolChains.size()); - for(Iterator iter = fCompatibleToolChains.keySet().iterator(); iter.hasNext(); ){ - ToolChain tc = (ToolChain)iter.next(); - + List l = new ArrayList(fCompatibleToolChains.size()); + Set keySet = fCompatibleToolChains.keySet(); + for (ToolChain tc : keySet) { if(tc != fRealToolChain && foInfo.isToolChainCompatible(fRealToolChain, tc)) l.add(tc); } - return (ToolChain[])l.toArray(new ToolChain[l.size()]); + return l.toArray(new ToolChain[l.size()]); } public CompatibilityStatus getToolChainCompatibilityStatus(){ @@ -152,9 +154,9 @@ public class FolderInfoModification extends ToolListModification implements IFol private ToolChainCompatibilityInfoElement getCurrentCompatibilityInfo(){ if(fCurrentCompatibilityInfo == null){ initCompatibilityInfo(); - ToolChainCompatibilityInfoElement info = (ToolChainCompatibilityInfoElement)fCompatibleToolChains.get(fRealToolChain); + ToolChainCompatibilityInfoElement info = fCompatibleToolChains.get(fRealToolChain); if(info == null) - info = (ToolChainCompatibilityInfoElement)fInCompatibleToolChains.get(fRealToolChain); + info = fInCompatibleToolChains.get(fRealToolChain); fCurrentCompatibilityInfo = info; } return fCurrentCompatibilityInfo; @@ -168,15 +170,14 @@ public class FolderInfoModification extends ToolListModification implements IFol if(fCompatibilityInfoInited) return; - fCompatibleToolChains = new HashMap(); - fInCompatibleToolChains = new HashMap(); + fCompatibleToolChains = new HashMap(); + fInCompatibleToolChains = new HashMap(); ConflictMatchSet parentConflicts = getParentConflictMatchSet(); ToolChain sysTCs[] = (ToolChain[])getAllSysToolChains(); - Map conflictMap = parentConflicts.fObjToConflictListMap; - for(int i = 0; i < sysTCs.length; i++){ - ToolChain tc = sysTCs[i]; - List l = (List)conflictMap.get(tc); + Map> conflictMap = parentConflicts.fObjToConflictListMap; + for (ToolChain tc : sysTCs) { + List l = conflictMap.get(tc); ToolChainCompatibilityInfoElement info = new ToolChainCompatibilityInfoElement(tc, l); if(info.isCompatible()){ fCompatibleToolChains.put(tc, info); @@ -243,14 +244,14 @@ public class FolderInfoModification extends ToolListModification implements IFol @Override protected boolean canReplace(Tool fromTool, Tool toTool) { String[] exts = toTool.getPrimaryInputExtensions(); - Set curInputExts = null; - Set inputExts = getInputExtsSet(); - for(int k = 0; k < exts.length; k++){ - if(inputExts.contains(exts[k])){ + Set curInputExts = null; + Set inputExts = getInputExtsSet(); + for (String ext : exts) { + if(inputExts.contains(ext)){ if(curInputExts == null) - curInputExts = new HashSet(Arrays.asList(fromTool.getPrimaryInputExtensions())); + curInputExts = new HashSet(Arrays.asList(fromTool.getPrimaryInputExtensions())); - if(curInputExts.contains(exts[k])){ + if(curInputExts.contains(ext)){ return true; } } @@ -259,17 +260,17 @@ public class FolderInfoModification extends ToolListModification implements IFol } @Override - protected Set getExtensionConflictToolSet(Tool tool, Tool[] tools) { + protected Set getExtensionConflictToolSet(Tool tool, Tool[] tools) { String exts[] = tool.getPrimaryInputExtensions(); - Set extsSet = new HashSet(Arrays.asList(exts)); - Set conflictsSet = null; + Set extsSet = new HashSet(Arrays.asList(exts)); + Set conflictsSet = null; for(int i = 0; i < tools.length; i++){ Tool t = tools[i]; if(t == tool) continue; if(TcModificationUtil.containCommonEntries(extsSet, t.getPrimaryInputExtensions())){ if(conflictsSet == null) - conflictsSet = new HashSet(); + conflictsSet = new HashSet(); conflictsSet.add(t); } @@ -277,14 +278,14 @@ public class FolderInfoModification extends ToolListModification implements IFol } if(conflictsSet == null) - conflictsSet = Collections.EMPTY_SET; + conflictsSet = Collections.emptySet(); return conflictsSet; } @Override - protected Set getToolApplicabilityPathSet(Tool realTool, boolean isProject) { + protected Set getToolApplicabilityPathSet(Tool realTool, boolean isProject) { if(isProject) - return (Set)getToolChainApplicabilityPaths().fToolPathMap.get(realTool); + return getToolChainApplicabilityPaths().fToolPathMap.get(realTool); return getToolChainApplicabilityPaths().fFolderInfoPaths; } @@ -306,24 +307,24 @@ public class FolderInfoModification extends ToolListModification implements IFol ToolChainApplicabilityPaths tcApplicabilityPaths = new ToolChainApplicabilityPaths(); IPath path = getResourceInfo().getPath(); - TreeMap pathMap = getCompletePathMapStorage(); + TreeMap pathMap = getCompletePathMapStorage(); - PerTypeSetStorage oSet = (PerTypeSetStorage)pathMap.get(path); - Set toolSet = oSet.getSet(IRealBuildObjectAssociation.OBJECT_TOOL, false); - Set tcSet = oSet.getSet(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, false); + PerTypeSetStorage oSet = pathMap.get(path); + Set toolSet = oSet.getSet(IRealBuildObjectAssociation.OBJECT_TOOL, false); + Set tcSet = oSet.getSet(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, false); ToolChain curTc = (ToolChain)tcSet.iterator().next(); - Set foInfoPaths = tcApplicabilityPaths.fFolderInfoPaths; - Set fileInfoPaths = tcApplicabilityPaths.fFileInfoPaths; + Set foInfoPaths = tcApplicabilityPaths.fFolderInfoPaths; + Set fileInfoPaths = tcApplicabilityPaths.fFileInfoPaths; foInfoPaths.add(path); - Map toolPathsMap = tcApplicabilityPaths.fToolPathMap; + Map> toolPathsMap = tcApplicabilityPaths.fToolPathMap; if(toolSet != null){ - for(Iterator iter = toolSet.iterator(); iter.hasNext(); ){ - Set set = new HashSet(); - toolPathsMap.put(iter.next(), set); + for (Tool tool : toolSet) { + Set set = new HashSet(); + toolPathsMap.put(tool, set); set.add(path); } } @@ -339,11 +340,10 @@ public class FolderInfoModification extends ToolListModification implements IFol fTcApplicabilityPaths = null; } - private static void putToolInfo(Set ct, Map toolPathsMap, Set fileInfoPaths, Object p){ + private static void putToolInfo(Set ct, Map> toolPathsMap, Set fileInfoPaths, IPath p){ if(ct != null && ct.size() != 0){ - for(Iterator toolIter = ct.iterator(); toolIter.hasNext(); ){ - Object t = toolIter.next(); - Set set = (Set)toolPathsMap.get(t); + for (Tool t : ct) { + Set set = toolPathsMap.get(t); if(set != null){ if(fileInfoPaths != null) fileInfoPaths.add(p); @@ -353,14 +353,14 @@ 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); - for(Iterator iter = directCMap.entrySet().iterator(); iter.hasNext(); ){ - Map.Entry entry = (Map.Entry)iter.next(); - PerTypeSetStorage cst = (PerTypeSetStorage)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(); - Set ctc = cst.getSet(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, false); - Set ct = cst.getSet(IRealBuildObjectAssociation.OBJECT_TOOL, false); + Set ctc = cst.getSet(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, false); + Set ct = cst.getSet(IRealBuildObjectAssociation.OBJECT_TOOL, false); if(ctc == null || ctc.size() == 0){ @@ -368,7 +368,7 @@ public class FolderInfoModification extends ToolListModification implements IFol putToolInfo(ct, toolPathsMap, fileInfoPaths, entry.getKey()); } else { if(ctc.contains(tc)){ - IPath cp = (IPath)entry.getKey(); + IPath cp = entry.getKey(); tcPaths.add(cp); putToolInfo(ct, toolPathsMap, null, entry.getKey()); //recurse @@ -384,8 +384,8 @@ public class FolderInfoModification extends ToolListModification implements IFol ToolChainApplicabilityPaths tcApplicability = getToolChainApplicabilityPaths(); PerTypeMapStorage storage = getCompleteObjectStore(); - Map tcMap = storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, false); - Map toolMap = storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, false); + Map> tcMap = storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, false); + Map> toolMap = storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, false); TcModificationUtil.removePaths(tcMap, fRealToolChain, tcApplicability.fFolderInfoPaths); @@ -396,10 +396,11 @@ public class FolderInfoModification extends ToolListModification implements IFol newTools[i] = (Tool)ManagedBuildManager.getRealTool(newTools[i]); } - for(Iterator iter = tcApplicability.fToolPathMap.entrySet().iterator(); iter.hasNext(); ){ - Map.Entry entry = (Map.Entry)iter.next(); - Tool tool = (Tool)entry.getKey(); - Set pathSet = (Set)entry.getValue(); + Set>> entrySet = tcApplicability.fToolPathMap.entrySet(); + for(Iterator>> iter = entrySet.iterator(); iter.hasNext(); ){ + Map.Entry> entry = iter.next(); + Tool tool = entry.getKey(); + Set pathSet = entry.getValue(); TcModificationUtil.removePaths(toolMap, tool, pathSet); } @@ -414,8 +415,7 @@ public class FolderInfoModification extends ToolListModification implements IFol IProject project = mProj.getOwner().getProject(); Tool[] filtered = (Tool[])foInfo.filterTools(newTools, mProj); if(filtered.length != 0){ - for(Iterator iter = tcApplicability.fFileInfoPaths.iterator(); iter.hasNext(); ){ - IPath p = (IPath)iter.next(); + for (IPath p : tcApplicability.fFileInfoPaths) { boolean found = false; String ext = p.getFileExtension(); if(ext == null) 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 ff688de9055..f340b890bef 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 @@ -20,7 +20,7 @@ import java.util.TreeSet; import org.eclipse.core.runtime.IPath; -public class PathComparator implements Comparator { +public class PathComparator implements Comparator { public static PathComparator INSTANCE = new PathComparator(); // public static final SortedSet EMPTY_SET = Collections.unmodifiableSortedSet(new TreeSet(INSTANCE)); // public static final SortedMap EMPTY_MAP = Collections.unmodifiableSortedMap(new TreeMap(INSTANCE)); @@ -28,12 +28,12 @@ public class PathComparator implements Comparator { private PathComparator(){ } - public int compare(Object arg0, Object arg1) { + public int compare(IPath arg0, IPath arg1) { if(arg0 == arg1) return 0; - IPath path1 = (IPath)arg0; - IPath path2 = (IPath)arg1; + IPath path1 = arg0; + IPath path2 = arg1; int length1 = path1.segmentCount(); int length2 = path2.segmentCount(); @@ -69,45 +69,43 @@ 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; } - public static SortedSet getChildPathSet(SortedSet set, IPath path, boolean includeThis, boolean copy){ + public static SortedSet getChildPathSet(SortedSet set, IPath path, boolean includeThis, boolean copy){ IPath start = includeThis ? path : getFirstChild(path); IPath next = getNext(path); - SortedSet result = next != null ? set.subSet(start, next) : set.tailSet(start); + SortedSet result = next != null ? set.subSet(start, next) : set.tailSet(start); if(copy) - result = new TreeSet(result); + result = new TreeSet(result); return result; } - public static SortedSet getDirectChildPathSet(SortedSet set, IPath path){ + public static SortedSet getDirectChildPathSet(SortedSet set, IPath path){ //all children - SortedSet children = getChildPathSet(set, path, false, false); - SortedSet result = new TreeSet(INSTANCE); - for(Iterator iter = children.iterator(); iter.hasNext(); iter = children.iterator()){ - IPath childPath = (IPath)iter.next(); + SortedSet children = getChildPathSet(set, path, false, false); + SortedSet result = new TreeSet(INSTANCE); + for (IPath childPath : children) { result.add(childPath); - - children = children.tailSet(getNext(childPath));//getChildPathSet(children, getNext(childPath), true, false); + children = children.tailSet(getNext(childPath)); } 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 = (Map.Entry)iter.next(); - IPath childPath = (IPath)entry.getKey(); + 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()); children = children.tailMap(getNext(childPath));//getChildPathMap(children, getNext(childPath), true, false);