From 4c9e17c86ddc689f3a2a545159c607e784e216e6 Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Tue, 27 Jul 2010 03:28:25 +0000 Subject: [PATCH] bug 319512: Compilation warnings --- .../cdt/managedbuilder/core/ITool.java | 6 +- .../managedbuilder/core/IToolReference.java | 2 +- .../internal/core/ConfigurationV2.java | 93 ++++------ .../managedbuilder/internal/core/Target.java | 175 ++++++++---------- .../internal/core/ToolReference.java | 38 ++-- 5 files changed, 138 insertions(+), 176 deletions(-) diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITool.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITool.java index a27cf26291a..9fa7b0ed88c 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITool.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITool.java @@ -26,7 +26,7 @@ import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType; * @noextend This class is not intended to be subclassed by clients. * @noimplement This interface is not intended to be implemented by clients. */ -public interface ITool extends IBuildObject, IHoldsOptions { +public interface ITool extends IHoldsOptions { // Schema element names public static final String COMMAND = "command"; //$NON-NLS-1$ public static final String COMMAND_LINE_PATTERN = "commandLinePattern"; //$NON-NLS-1$ @@ -288,7 +288,7 @@ public interface ITool extends IBuildObject, IHoldsOptions { * @deprecated - use getPrimaryInputExtensions or getAllInputExtensions */ @Deprecated - public List getInputExtensions(); + public List getInputExtensions(); /** * Returns the array of valid primary source extensions this tool knows how to build. @@ -330,7 +330,7 @@ public interface ITool extends IBuildObject, IHoldsOptions { * @deprecated - use getDependency* methods */ @Deprecated - public List getInterfaceExtensions(); + public List getInterfaceExtensions(); /** * Answers a constant corresponding to the project nature the tool should be used diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IToolReference.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IToolReference.java index 954fe331685..5e4d7ec202f 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IToolReference.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IToolReference.java @@ -37,7 +37,7 @@ public interface IToolReference extends ITool { * * @return List */ - public List getOptionReferenceList(); + public List getOptionReferenceList(); /** * Answers the tool that the reference has been created for. diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ConfigurationV2.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ConfigurationV2.java index 78326a04bab..8d3e5f2055c 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ConfigurationV2.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ConfigurationV2.java @@ -12,7 +12,6 @@ package org.eclipse.cdt.managedbuilder.internal.core; import java.util.ArrayList; import java.util.Arrays; -import java.util.Iterator; import java.util.List; import java.util.Vector; @@ -36,9 +35,7 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; /** - * This class is deprecated in 2.1 - * - * @deprecated + * @deprecated This class is deprecated in 2.1 */ @Deprecated public class ConfigurationV2 extends BuildObject implements IConfigurationV2 { @@ -47,7 +44,7 @@ public class ConfigurationV2 extends BuildObject implements IConfigurationV2 { private boolean rebuildNeeded = false; private boolean resolved = true; private ITarget target; - private List toolReferences; + private List toolReferences; private IConfiguration createdConfig; /** @@ -113,12 +110,9 @@ public class ConfigurationV2 extends BuildObject implements IConfigurationV2 { IProject project = (IProject) target.getOwner(); // Get the tool references from the target and parent - List allToolRefs = new Vector(target.getLocalToolReferences()); + List allToolRefs = new Vector(target.getLocalToolReferences()); allToolRefs.addAll(((ConfigurationV2)parentConfig).getLocalToolReferences()); - Iterator iter = allToolRefs.listIterator(); - while (iter.hasNext()) { - ToolReference toolRef = (ToolReference)iter.next(); - + for (IToolReference toolRef : allToolRefs) { // Make a new ToolReference based on the tool in the ref ITool parentTool = toolRef.getTool(); ToolReference newRef = new ToolReference(this, parentTool); @@ -129,10 +123,8 @@ public class ConfigurationV2 extends BuildObject implements IConfigurationV2 { newRef.setToolCommand(refCmd); } - List optRefs = toolRef.getOptionReferenceList(); - Iterator optIter = optRefs.listIterator(); - while (optIter.hasNext()) { - OptionReference optRef = (OptionReference)optIter.next(); + List optRefs = toolRef.getOptionReferenceList(); + for (OptionReference optRef : optRefs) { IOption opt = optRef.getOption(); try { switch (opt.getValueType()) { @@ -218,10 +210,9 @@ public class ConfigurationV2 extends BuildObject implements IConfigurationV2 { if (!resolved) { resolved = true; // IManagedConfigElement element = ManagedBuildManager.getConfigElement(this); - Iterator refIter = getLocalToolReferences().iterator(); - while (refIter.hasNext()) { - ToolReference ref = (ToolReference)refIter.next(); - ref.resolveReferences(); + List localToolReferences = getLocalToolReferences(); + for (IToolReference ref : localToolReferences) { + ((ToolReference)ref).resolveReferences(); } } } @@ -239,7 +230,7 @@ public class ConfigurationV2 extends BuildObject implements IConfigurationV2 { * @see org.eclipse.cdt.core.build.managed.IConfigurationV2#getToolReferences() */ public IToolReference[] getToolReferences() { - List list = getLocalToolReferences(); + List list = getLocalToolReferences(); IToolReference[] tools = new IToolReference[list.size()]; list.toArray(tools); return tools; @@ -251,7 +242,7 @@ public class ConfigurationV2 extends BuildObject implements IConfigurationV2 { */ private OptionReference createOptionReference(IOption option) { ToolReference searchRef = null; - ToolReference answer = null; + IToolReference answer = null; // The option may already be a reference created to hold user settings if (option instanceof OptionReference) { // The option reference belongs to an existing tool reference @@ -293,11 +284,9 @@ public class ConfigurationV2 extends BuildObject implements IConfigurationV2 { * @param toolRef * @return */ - private ToolReference findLocalReference(ToolReference toolRef) { - Iterator iter = getLocalToolReferences().iterator(); - - while (iter.hasNext()) { - ToolReference ref = (ToolReference)iter.next(); + private IToolReference findLocalReference(ToolReference toolRef) { + List localToolReferences = getLocalToolReferences(); + for (IToolReference ref : localToolReferences) { if (toolRef.getTool().equals(ref.getTool())) { return ref; } @@ -311,9 +300,8 @@ public class ConfigurationV2 extends BuildObject implements IConfigurationV2 { */ public ITool[] getFilteredTools(IProject project) { ITool[] localTools = getTools(); - Vector tools = new Vector(localTools.length); - for (int i = 0; i < localTools.length; i++) { - ITool tool = localTools[i]; + Vector tools = new Vector(localTools.length); + for (ITool tool : localTools) { try { // Make sure the tool is right for the project switch (tool.getNatureFilter()) { @@ -339,7 +327,7 @@ public class ConfigurationV2 extends BuildObject implements IConfigurationV2 { } // Answer the filtered tools as an array - return (ITool[])tools.toArray(new ITool[tools.size()]); + return tools.toArray(new ITool[tools.size()]); } /* (non-javadoc) @@ -348,9 +336,9 @@ public class ConfigurationV2 extends BuildObject implements IConfigurationV2 { * * @return List */ - protected List getLocalToolReferences() { + protected List getLocalToolReferences() { if (toolReferences == null) { - toolReferences = new ArrayList(); + toolReferences = new ArrayList(); } return toolReferences; } @@ -374,7 +362,7 @@ public class ConfigurationV2 extends BuildObject implements IConfigurationV2 { // Validate that the tools correspond to the nature IProject project = (IProject)target.getOwner(); if (project != null) { - List validTools = new ArrayList(); + List validTools = new ArrayList(); // The target is associated with a real project for (int i = 0; i < tools.length; ++i) { @@ -405,7 +393,7 @@ public class ConfigurationV2 extends BuildObject implements IConfigurationV2 { } } // Now put the valid tools back into the array - tools = (ITool[]) validTools.toArray(new ITool[validTools.size()]); + tools = validTools.toArray(new ITool[validTools.size()]); } // Replace tools with local overrides @@ -426,9 +414,8 @@ public class ConfigurationV2 extends BuildObject implements IConfigurationV2 { if (isDirty) return true; // Otherwise see if any tool references need saving - Iterator iter = getLocalToolReferences().listIterator(); - while (iter.hasNext()) { - IToolReference ref = (IToolReference) iter.next(); + List localToolReferences = getLocalToolReferences(); + for (IToolReference ref : localToolReferences) { if (ref.isDirty()) return true; } @@ -454,8 +441,8 @@ public class ConfigurationV2 extends BuildObject implements IConfigurationV2 { * @param tool * @return List */ - protected List getOptionReferences(ITool tool) { - List references = new ArrayList(); + protected List getOptionReferences(ITool tool) { + List references = new ArrayList(); // Get all the option references I add for this tool IToolReference toolRef = getToolReference(tool); @@ -465,10 +452,8 @@ public class ConfigurationV2 extends BuildObject implements IConfigurationV2 { // See if there is anything that my parents add that I don't if (parent != null) { - List temp = ((ConfigurationV2)parent).getOptionReferences(tool); - Iterator iter = temp.listIterator(); - while (iter.hasNext()) { - OptionReference ref = (OptionReference) iter.next(); + List temp = ((ConfigurationV2)parent).getOptionReferences(tool); + for (OptionReference ref : temp) { if (!references.contains(ref)) { references.add(ref); } @@ -529,9 +514,8 @@ public class ConfigurationV2 extends BuildObject implements IConfigurationV2 { if (tool == null) return null; // See if the receiver has a reference to the tool - Iterator iter = getLocalToolReferences().listIterator(); - while (iter.hasNext()) { - ToolReference temp = (ToolReference)iter.next(); + List localToolReferences = getLocalToolReferences(); + for (IToolReference temp : localToolReferences) { if (temp.references(tool)) { return temp; } @@ -583,12 +567,11 @@ public class ConfigurationV2 extends BuildObject implements IConfigurationV2 { element.setAttribute(IConfigurationV2.PARENT, parent.getId()); // Serialize only the tool references defined in the configuration - Iterator iter = getLocalToolReferences().listIterator(); - while (iter.hasNext()) { - ToolReference toolRef = (ToolReference) iter.next(); + List localToolReferences = getLocalToolReferences(); + for (IToolReference toolRef : localToolReferences) { Element toolRefElement = doc.createElement(IConfigurationV2.TOOLREF_ELEMENT_NAME); element.appendChild(toolRefElement); - toolRef.serialize(doc, toolRefElement); + ((ToolReference)toolRef).serialize(doc, toolRefElement); } // I am clean now @@ -602,9 +585,9 @@ public class ConfigurationV2 extends BuildObject implements IConfigurationV2 { // Override the dirty flag this.isDirty = isDirty; // And do the same for the tool references - Iterator iter = getLocalToolReferences().listIterator(); - while (iter.hasNext()) { - ((ToolReference)iter.next()).setDirty(isDirty); + List localToolReferences = getLocalToolReferences(); + for (IToolReference toolRef : localToolReferences) { + ((ToolReference)toolRef).setDirty(isDirty); } } @@ -692,10 +675,8 @@ public class ConfigurationV2 extends BuildObject implements IConfigurationV2 { ref = new ToolReference(this, tool); } // Set the ref's command - if (ref != null) { - isDirty = ref.setToolCommand(command); - rebuildNeeded = isDirty; - } + isDirty = ref.setToolCommand(command); + rebuildNeeded = isDirty; } } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Target.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Target.java index c87b7e277e6..5fae8f6c0a8 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Target.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Target.java @@ -12,13 +12,12 @@ package org.eclipse.cdt.managedbuilder.internal.core; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.StringTokenizer; import java.util.Vector; -import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.ErrorParserManager; import org.eclipse.cdt.managedbuilder.core.IBuilder; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfigurationV2; @@ -41,14 +40,13 @@ import org.w3c.dom.Node; public class Target extends BuildObject implements ITarget { private static final String EMPTY_STRING = new String(); - private static final IConfigurationV2[] emptyConfigs = new IConfigurationV2[0]; private String artifactName; private String binaryParserId; private String cleanCommand; - private List configList; - private Map configMap; + private List configList; + private Map configMap; private String defaultExtension; - private Map depCalculatorsMap; +// private Map depCalculatorsMap; private String errorParserIds; private String extension; private boolean isAbstract = false; @@ -59,11 +57,11 @@ public class Target extends BuildObject implements ITarget { private IResource owner; private ITarget parent; private boolean resolved = true; - private List targetArchList; - private List targetOSList; - private List toolList; - private Map toolMap; - private List toolReferences; + private List targetArchList; + private List targetOSList; + private List toolList; + private Map toolMap; + private List toolReferences; private ProjectType createdProjectType; private String scannerInfoCollectorId; @@ -125,7 +123,7 @@ public class Target extends BuildObject implements ITarget { // Get the comma-separated list of valid OS String os = element.getAttribute(OS_LIST); if (os != null) { - targetOSList = new ArrayList(); + targetOSList = new ArrayList(); String[] osTokens = os.split(","); //$NON-NLS-1$ for (int i = 0; i < osTokens.length; ++i) { targetOSList.add(osTokens[i].trim()); @@ -135,7 +133,7 @@ public class Target extends BuildObject implements ITarget { // Get the comma-separated list of valid Architectures String arch = element.getAttribute(ARCH_LIST); if (arch != null) { - targetArchList = new ArrayList(); + targetArchList = new ArrayList(); String[] archTokens = arch.split(","); //$NON-NLS-1$ for (int j = 0; j < archTokens.length; ++j) { targetArchList.add(archTokens[j].trim()); @@ -303,7 +301,7 @@ public class Target extends BuildObject implements ITarget { * * @param toolArray */ - private void addToolsToArray(Vector toolArray) { + private void addToolsToArray(Vector toolArray) { if (parent != null) { ((Target)parent).addToolsToArray(toolArray); } @@ -410,7 +408,7 @@ public class Target extends BuildObject implements ITarget { * @see org.eclipse.cdt.core.build.managed.ITarget#getConfiguration() */ public IConfigurationV2 getConfiguration(String id) { - return (IConfigurationV2)getConfigurationMap().get(id); + return getConfigurationMap().get(id); } /* (non-Javadoc) @@ -418,9 +416,9 @@ public class Target extends BuildObject implements ITarget { * * @return List containing the configurations */ - private List getConfigurationList() { + private List getConfigurationList() { if (configList == null) { - configList = new ArrayList(); + configList = new ArrayList(); } return configList; } @@ -430,9 +428,9 @@ public class Target extends BuildObject implements ITarget { * * @return */ - private Map getConfigurationMap() { + private Map getConfigurationMap() { if (configMap == null) { - configMap = new HashMap(); + configMap = new HashMap(); } return configMap; } @@ -441,7 +439,7 @@ public class Target extends BuildObject implements ITarget { * @see org.eclipse.cdt.managedbuilder.core.ITarget#getConfigurations() */ public IConfigurationV2[] getConfigurations() { - return (IConfigurationV2[])getConfigurationList().toArray(new IConfigurationV2[getConfigurationList().size()]); + return getConfigurationList().toArray(new IConfigurationV2[getConfigurationList().size()]); } /* (non-Javadoc) @@ -451,12 +449,12 @@ public class Target extends BuildObject implements ITarget { return defaultExtension == null ? EMPTY_STRING : defaultExtension; } - private Map getDepCalcMap() { - if (depCalculatorsMap == null) { - depCalculatorsMap = new HashMap(); - } - return depCalculatorsMap; - } +// private Map getDepCalcMap() { +// if (depCalculatorsMap == null) { +// depCalculatorsMap = new HashMap(); +// } +// return depCalculatorsMap; +// } /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.core.ITarget#getErrorParserIds() @@ -483,17 +481,17 @@ public class Target extends BuildObject implements ITarget { errorParsers = new String[0]; } else { StringTokenizer tok = new StringTokenizer(parserIDs, ";"); //$NON-NLS-1$ - List list = new ArrayList(tok.countTokens()); + List list = new ArrayList(tok.countTokens()); while (tok.hasMoreElements()) { list.add(tok.nextToken()); } String[] strArr = {""}; //$NON-NLS-1$ - errorParsers = (String[]) list.toArray(strArr); + errorParsers = list.toArray(strArr); } } else { // If no error parsers are specified by the target, the default is // all error parsers - errorParsers = CCorePlugin.getDefault().getAllErrorParsersIDs(); + errorParsers = ErrorParserManager.getErrorParserAvailableIds(); } return errorParsers; } @@ -504,9 +502,9 @@ public class Target extends BuildObject implements ITarget { * * @return List */ - protected List getLocalToolReferences() { + protected List getLocalToolReferences() { if (toolReferences == null) { - toolReferences = new ArrayList(); + toolReferences = new ArrayList(); } return toolReferences; } @@ -566,8 +564,8 @@ public class Target extends BuildObject implements ITarget { * @param tool * @return List */ - protected List getOptionReferences(ITool tool) { - List references = new ArrayList(); + protected List getOptionReferences(ITool tool) { + List references = new ArrayList(); // Get all the option references I add for this tool ToolReference toolRef = getToolReference(tool); @@ -577,10 +575,8 @@ public class Target extends BuildObject implements ITarget { // See if there is anything that my parents add that I don't if (parent != null) { - List temp = ((Target)parent).getOptionReferences(tool); - Iterator iter = temp.listIterator(); - while (iter.hasNext()) { - OptionReference ref = (OptionReference) iter.next(); + List refs = ((Target)parent).getOptionReferences(tool); + for (OptionReference ref : refs) { if (!references.contains(ref)) { references.add(ref); } @@ -617,7 +613,7 @@ public class Target extends BuildObject implements ITarget { return new String[] {"all"}; //$NON-NLS-1$ } } - return (String[]) targetArchList.toArray(new String[targetArchList.size()]); + return targetArchList.toArray(new String[targetArchList.size()]); } /* (non-Javadoc) @@ -633,7 +629,7 @@ public class Target extends BuildObject implements ITarget { return new String[] {"all"}; //$NON-NLS-1$ } } - return (String[]) targetOSList.toArray(new String[targetOSList.size()]); + return targetOSList.toArray(new String[targetOSList.size()]); } /* (non-Javadoc) @@ -643,7 +639,7 @@ public class Target extends BuildObject implements ITarget { ITool result = null; // See if receiver has it in list - result = (ITool) getToolMap().get(id); + result = getToolMap().get(id); // If not, check if parent has it if (result == null && parent != null) { @@ -663,9 +659,9 @@ public class Target extends BuildObject implements ITarget { * target * */ - private List getToolList() { + private List getToolList() { if (toolList == null) { - toolList = new ArrayList(); + toolList = new ArrayList(); } return toolList; } @@ -674,9 +670,9 @@ public class Target extends BuildObject implements ITarget { * A safe accessor for the tool map * */ - private Map getToolMap() { + private Map getToolMap() { if (toolMap == null) { - toolMap = new HashMap(); + toolMap = new HashMap(); } return toolMap; } @@ -692,9 +688,8 @@ public class Target extends BuildObject implements ITarget { // See if the receiver has a reference to the tool ToolReference ref = null; if (tool == null) return ref; - Iterator iter = getLocalToolReferences().listIterator(); - while (iter.hasNext()) { - ToolReference temp = (ToolReference)iter.next(); + List localToolReferences = getLocalToolReferences(); + for (ToolReference temp : localToolReferences) { if (temp.references(tool)) { ref = temp; break; @@ -707,9 +702,9 @@ public class Target extends BuildObject implements ITarget { * @see org.eclipse.cdt.managedbuilder.core.ITarget#getTools() */ public ITool[] getTools() { - Vector toolArray = new Vector(); + Vector toolArray = new Vector(); addToolsToArray(toolArray); - return (ITool[]) toolArray.toArray(new ITool[toolArray.size()]); + return toolArray.toArray(new ITool[toolArray.size()]); } /* (non-Javadoc) @@ -738,9 +733,9 @@ public class Target extends BuildObject implements ITarget { } // Iterate over the configurations and ask them if they need saving - Iterator iter = getConfigurationList().listIterator(); - while (iter.hasNext()) { - if (((IConfigurationV2)iter.next()).isDirty()) { + List configurationList = getConfigurationList(); + for (IConfigurationV2 cfgV2 : configurationList) { + if (cfgV2.isDirty()) { return true; } } @@ -760,9 +755,9 @@ public class Target extends BuildObject implements ITarget { */ public boolean needsRebuild(){ // Iterate over the configurations and ask them if they need saving - Iterator iter = getConfigurationList().listIterator(); - while (iter.hasNext()) { - if (((IConfigurationV2)iter.next()).needsRebuild()) { + List configurationList = getConfigurationList(); + for (IConfigurationV2 cfgV2 : configurationList) { + if (cfgV2.needsRebuild()) { return true; } } @@ -774,11 +769,10 @@ public class Target extends BuildObject implements ITarget { */ public void removeConfiguration(String id) { // Remove the specified configuration from the list and map - Iterator iter = getConfigurationList().listIterator(); - while (iter.hasNext()) { - IConfigurationV2 config = (IConfigurationV2)iter.next(); + List configurationList = getConfigurationList(); + for (IConfigurationV2 config : configurationList) { if (config.getId().equals(id)) { - getConfigurationList().remove(config); + configurationList.remove(config); getConfigurationMap().remove(id); isDirty = true; break; @@ -813,25 +807,23 @@ public class Target extends BuildObject implements ITarget { ((Target)parent).resolveReferences(); // copy over the parents configs IConfigurationV2[] parentConfigs = parent.getConfigurations(); - for (int i = 0; i < parentConfigs.length; ++i) - addConfiguration(parentConfigs[i]); + for (IConfigurationV2 cfgV2 : parentConfigs) { + addConfiguration(cfgV2); + } } // call resolve references on any children - Iterator toolIter = getToolList().iterator(); - while (toolIter.hasNext()) { - Tool current = (Tool)toolIter.next(); + List toolList = getToolList(); + for (ITool current : toolList) { + ((Tool)current).resolveReferences(); + } + List localToolReferences = getLocalToolReferences(); + for (ToolReference current : localToolReferences) { current.resolveReferences(); } - Iterator refIter = getLocalToolReferences().iterator(); - while (refIter.hasNext()) { - ToolReference current = (ToolReference)refIter.next(); - current.resolveReferences(); - } - Iterator configIter = getConfigurationList().iterator(); - while (configIter.hasNext()) { - ConfigurationV2 current = (ConfigurationV2)configIter.next(); - current.resolveReferences(); + List configurationList = getConfigurationList(); + for (IConfigurationV2 current : configurationList) { + ((ConfigurationV2)current).resolveReferences(); } } } @@ -868,12 +860,11 @@ public class Target extends BuildObject implements ITarget { } // Serialize the configuration settings - Iterator iter = getConfigurationList().listIterator(); - while (iter.hasNext()) { - ConfigurationV2 config = (ConfigurationV2) iter.next(); + List configurationList = getConfigurationList(); + for (IConfigurationV2 config : configurationList) { Element configElement = doc.createElement(IConfigurationV2.CONFIGURATION_ELEMENT_NAME); element.appendChild(configElement); - config.serialize(doc, configElement); + ((ConfigurationV2)config).serialize(doc, configElement); } // I am clean now @@ -908,9 +899,8 @@ public class Target extends BuildObject implements ITarget { // Override the dirty flag here this.isDirty = isDirty; // and in the configurations - Iterator iter = getConfigurationList().listIterator(); - while (iter.hasNext()) { - IConfigurationV2 config = (IConfigurationV2)iter.next(); + List configurationList = getConfigurationList(); + for (IConfigurationV2 config : configurationList) { config.setDirty(isDirty); } } @@ -953,9 +943,9 @@ public class Target extends BuildObject implements ITarget { * @see org.eclipse.cdt.managedbuilder.core.ITarget#setRebuildState(boolean) */ public void setRebuildState(boolean rebuild) { - Iterator iter = getConfigurationList().listIterator(); - while (iter.hasNext()) { - ((IConfigurationV2)iter.next()).setRebuildState(rebuild); + List configurationList = getConfigurationList(); + for (IConfigurationV2 config : configurationList) { + config.setRebuildState(rebuild); } } @@ -993,9 +983,8 @@ public class Target extends BuildObject implements ITarget { projectType.setIsTest(isTest); // Add children // Add configurations (Configuration -> ToolChain -> Builder -> TargetPlatform) - Iterator iter = getConfigurationList().listIterator(); - while (iter.hasNext()) { - IConfigurationV2 configV2 = (IConfigurationV2)iter.next(); + List configurationList = getConfigurationList(); + for (IConfigurationV2 configV2 : configurationList) { if (configV2.getCreatedConfig() != null) continue; // The new config's superClass needs to be the // Configuration created from the ConfigurationV2 parent... @@ -1056,7 +1045,7 @@ public class Target extends BuildObject implements ITarget { IToolReference[] configToolRefs = configV2.getToolReferences(); // Add the "local" tool references (they are direct children of the target and // its parent targets) - Vector targetToolRefs = new Vector(); + Vector targetToolRefs = new Vector(); addTargetToolReferences(targetToolRefs); IToolReference[] toolRefs; if (targetToolRefs.size() > 0) { @@ -1064,10 +1053,9 @@ public class Target extends BuildObject implements ITarget { int i; for (i = 0; i < configToolRefs.length; ++i) { toolRefs[i] = configToolRefs[i]; - } - Iterator localToolRefIter = targetToolRefs.iterator(); - while (localToolRefIter.hasNext()) { - toolRefs[i++] = (IToolReference)localToolRefIter.next(); + } + for (IToolReference toolRef : targetToolRefs) { + toolRefs[i++] = toolRef; } } else { toolRefs = configToolRefs; @@ -1083,9 +1071,8 @@ public class Target extends BuildObject implements ITarget { newTool.setOutputFlag(toolRef.getRawOutputFlag()); newTool.setOutputsAttribute(toolRef.getRawOutputExtensions()); // Handle ToolReference children (OptionReference) - Iterator optRefIter = toolRef.getOptionReferenceList().listIterator(); - while (optRefIter.hasNext()) { - OptionReference optRef = (OptionReference)optRefIter.next(); + List optionReferenceList = toolRef.getOptionReferenceList(); + for (OptionReference optRef : optionReferenceList) { subId = id + "." + optRef.getId(); //$NON-NLS-1$ IOption newOption = newTool.createOption(optRef.getOption(), subId, optRef.getName(), true); // Set the option attributes diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java index e2e6b9c94bb..0945f812284 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java @@ -12,7 +12,6 @@ package org.eclipse.cdt.managedbuilder.internal.core; import java.util.ArrayList; import java.util.Arrays; -import java.util.Iterator; import java.util.List; import org.eclipse.cdt.core.settings.model.extension.CLanguageData; @@ -50,7 +49,7 @@ public class ToolReference implements IToolReference { private String command; private boolean isDirty = false; - private List optionReferences; + private List optionReferences; private IBuildObject owner; private String outputExtensions; private String outputFlag; @@ -193,10 +192,8 @@ public class ToolReference implements IToolReference { // Create a copy of the option references of the parent in the receiver if (tool instanceof ToolReference) { - List parentRefs = ((ToolReference)tool).getOptionReferenceList(); - Iterator iter = parentRefs.iterator(); - while (iter.hasNext()) { - IOption parent = (IOption)iter.next(); + List parentRefs = ((ToolReference)tool).getOptionReferenceList(); + for (OptionReference parent : parentRefs) { OptionReference clone = createOptionReference(parent); try { switch (parent.getValueType()) { @@ -265,9 +262,8 @@ public class ToolReference implements IToolReference { ((ToolReference)parent).resolveReferences(); } - Iterator it = getOptionReferenceList().iterator(); - while (it.hasNext()) { - OptionReference optRef = (OptionReference)it.next(); + List optionReferenceList = getOptionReferenceList(); + for (OptionReference optRef : optionReferenceList) { optRef.resolveReferences(); } } @@ -327,7 +323,7 @@ public class ToolReference implements IToolReference { /* (non-Javadoc) * @return */ - protected List getAllOptionRefs() { + protected List getAllOptionRefs() { // First get all the option references this tool reference contains if (owner instanceof ConfigurationV2) { return ((ConfigurationV2)owner).getOptionReferences(parent); @@ -364,9 +360,9 @@ public class ToolReference implements IToolReference { /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.core.ITool#getInputExtensions() */ - public List getInputExtensions() { + public List getInputExtensions() { String[] exts = getPrimaryInputExtensions(); - List extList = new ArrayList(); + List extList = new ArrayList(); for (int i=0; i getOutputsList() { + ArrayList answer = new ArrayList(); if (outputExtensions != null) { String[] exts = outputExtensions.split(DEFAULT_SEPARATOR); answer.addAll(Arrays.asList(exts)); @@ -574,9 +570,8 @@ public class ToolReference implements IToolReference { */ private OptionReference getOptionReference(IOption option) { // Get all the option references for this option - Iterator iter = getAllOptionRefs().listIterator(); - while (iter.hasNext()) { - OptionReference optionRef = (OptionReference) iter.next(); + List allOptionRefs = getAllOptionRefs(); + for (OptionReference optionRef : allOptionRefs) { if (optionRef.references(option)) return optionRef; } @@ -605,9 +600,9 @@ public class ToolReference implements IToolReference { /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.core.IToolReference#getOptionReferenceList() */ - public List getOptionReferenceList() { + public List getOptionReferenceList() { if (optionReferences == null) { - optionReferences = new ArrayList(); + optionReferences = new ArrayList(); } return optionReferences; } @@ -747,9 +742,8 @@ public class ToolReference implements IToolReference { } // Output the option references - Iterator iter = getOptionReferenceList().listIterator(); - while (iter.hasNext()) { - OptionReference optionRef = (OptionReference) iter.next(); + List optionReferenceList = getOptionReferenceList(); + for (OptionReference optionRef : optionReferenceList) { Element optionRefElement = doc.createElement(ITool.OPTION_REF); element.appendChild(optionRefElement); optionRef.serialize(doc, optionRefElement);