From 3e29fc70a16424d17158a8e2fb072c91aff35f67 Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Mon, 18 Jan 2010 20:08:52 +0000 Subject: [PATCH] cosmetics: ehnanced loops etc --- .../managedbuilder/internal/core/Tool.java | 119 ++++++++---------- 1 file changed, 54 insertions(+), 65 deletions(-) diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java index 5ed19a8b671..5bdfde31e56 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java @@ -353,6 +353,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch * * @param parent The {@link IToolChain} or {@link IResourceConfiguration} * the tool will be added to. + * @param toolSuperClass superclass of the tool * @param Id The new Tool ID * @param name The new Tool name * @param tool The existing tool to clone. @@ -661,10 +662,10 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch ManagedBuildManager.putConfigElement(this, element); // id - setId(element.getAttribute(ITool.ID)); + setId(element.getAttribute(IBuildObject.ID)); // name - setName(element.getAttribute(ITool.NAME)); + setName(element.getAttribute(IBuildObject.NAME)); // version setVersion(getVersionFromId()); @@ -1330,9 +1331,8 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch return types; List list = new ArrayList(types.length); - OutputType type; - for(int i = 0; i < types.length; i++){ - type = (OutputType)types[i]; + for (IOutputType itype : types) { + OutputType type = (OutputType)itype; if(type.isEnabled(this)) list.add(type); } @@ -1345,9 +1345,8 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch return types; List list = new ArrayList(types.length); - InputType type; - for(int i = 0; i < types.length; i++){ - type = (InputType)types[i]; + for (IInputType itype : types) { + InputType type = (InputType)itype; if(type.isEnabled(this)) list.add(type); } @@ -1457,14 +1456,14 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch private Object[][] getOptions(ITool[] tools) { ITool catTool = this; ITool tool = null; - for (int i = 0; i < tools.length; ++i) { - ITool current = tools[i]; + for (ITool curTool : tools) { + ITool superTool = curTool; do { - if (catTool == current) { - tool = tools[i]; + if (catTool == superTool) { + tool = curTool; break; } - } while ((current = current.getSuperClass()) != null); + } while ((superTool = superTool.getSuperClass()) != null); if (tool != null) break; } // Get all of the tool's options and see which ones are part of @@ -1479,8 +1478,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch IOption[] allOptions = tool.getOptions(); Object[][] myOptions = new Object[allOptions.length][2]; int index = 0; - for (int i = 0; i < allOptions.length; ++i) { - IOption option = allOptions[i]; + for (IOption option : allOptions) { IOptionCategory optCat = option.getCategory(); if (optCat instanceof ITool) { // Determine if the category is this tool or a superclass @@ -1701,8 +1699,8 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch public List getInputExtensions() { String[] exts = getPrimaryInputExtensions(); List extList = new ArrayList(); - for (int i=0; i 0) { List allExts = new ArrayList(); - for (int i=0; i 0) { @@ -1818,9 +1816,9 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch IInputType type = null; IInputType[] types = getInputTypes(); if (types != null && types.length > 0) { - for (int i=0; i allDeps = new ArrayList(); IInputType[] types = getInputTypes(); - for (int i=0; i 0) { - for (int i=0; i 0 @@ -2585,8 +2583,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch macroSubstitutor.setMacroContextInfo(info); String[] list = CdtVariableResolver.resolveStringListValues(option.getBasicStringListValue(), macroSubstitutor, true); if(list != null){ - for (int j = 0; j < list.length; j++) { - String temp = list[j]; + for (String temp : list) { if(temp.length() > 0) sb.append( evaluateCommand( listCmd, temp ) + WHITE_SPACE ); } @@ -2604,8 +2601,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch macroSubstitutor.setMacroContextInfo(info); String[] paths = CdtVariableResolver.resolveStringListValues(option.getBasicStringListValue(), macroSubstitutor, true); if(paths != null){ - for (int j = 0; j < paths.length; j++) { - String temp = paths[j]; + for (String temp : paths) { if(temp.length() > 0 && !temp.equals(EMPTY_QUOTED_STRING)) sb.append( evaluateCommand( incCmd, temp ) + WHITE_SPACE); } @@ -2623,8 +2619,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch macroSubstitutor.setMacroContextInfo(info); String[] symbols = CdtVariableResolver.resolveStringListValues(option.getBasicStringListValue(), macroSubstitutor, true); if(symbols != null){ - for (int j = 0; j < symbols.length; j++) { - String temp = symbols[j]; + for (String temp : symbols) { if(temp.length() > 0) sb.append( evaluateCommand( defCmd, temp ) + WHITE_SPACE); } @@ -2663,9 +2658,9 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch // Get all of the optionList StringBuilder buf = new StringBuilder(); String[] flags = getToolCommandFlags(inputFileLocation,outputFileLocation); - for (int index = 0; index < flags.length; index++) { - if( flags[ index ] != null ) { - buf.append( flags[ index ] + WHITE_SPACE ); + for (String flag : flags) { + if( flag != null ) { + buf.append( flag + WHITE_SPACE ); } } @@ -2680,8 +2675,8 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch return false; } String[] exts = getAllDependencyExtensions(); - for (int i=0; i