1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 14:12:10 +02:00

cleanup: loops to enhanced and spaces, no functionality changes

This commit is contained in:
Andrew Gvozdev 2009-09-14 01:00:47 +00:00
parent 241396290b
commit c20ac81db5

View file

@ -334,15 +334,15 @@ public class BuildDescription implements IBuildDescription {
}
if(!removed && !rebuild){
for(int i = 0; i < rcs.length; i++){
if(rcs[i].needsRebuild()){
for (BuildResource rc : rcs) {
if(rc.needsRebuild()){
if(DbgUtil.DEBUG)
DbgUtil.trace("resource " + locationToRel(rcs[i].getLocation()).toString() + " needs rebuild"); //$NON-NLS-1$ //$NON-NLS-2$
DbgUtil.trace("resource " + locationToRel(rc.getLocation()).toString() + " needs rebuild"); //$NON-NLS-1$ //$NON-NLS-2$
rebuild = true;
break;
} else if(rcs[i].isRemoved()){
} else if(rc.isRemoved()){
if(DbgUtil.DEBUG)
DbgUtil.trace("resource " + locationToRel(rcs[i].getLocation()).toString() + " is removed"); //$NON-NLS-1$ //$NON-NLS-2$
DbgUtil.trace("resource " + locationToRel(rc.getLocation()).toString() + " is removed"); //$NON-NLS-1$ //$NON-NLS-2$
rebuild = true;
break;
}
@ -355,13 +355,11 @@ public class BuildDescription implements IBuildDescription {
action.setRemoved();
IBuildResource[] outRcs = action.getOutputResources();
for(int i = 0; i < outRcs.length; i++){
for (IBuildResource outRc : action.getOutputResources()) {
if(DbgUtil.DEBUG)
DbgUtil.trace("setting remove state for resource " + locationToRel(outRcs[i].getLocation()).toString()); //$NON-NLS-1$
DbgUtil.trace("setting remove state for resource " + locationToRel(outRc.getLocation()).toString()); //$NON-NLS-1$
((BuildResource)outRcs[i]).setRemoved(true);
((BuildResource)outRc).setRemoved(true);
}
} else if(rebuild){
@ -370,13 +368,11 @@ public class BuildDescription implements IBuildDescription {
action.setRebuildState(true);
IBuildResource[] outRcs = action.getOutputResources();
for(int i = 0; i < outRcs.length; i++){
for (IBuildResource outRc : action.getOutputResources()) {
if(DbgUtil.DEBUG)
DbgUtil.trace("setting rebuild state for resource " + locationToRel(outRcs[i].getLocation()).toString()); //$NON-NLS-1$
DbgUtil.trace("setting rebuild state for resource " + locationToRel(outRc.getLocation()).toString()); //$NON-NLS-1$
((BuildResource)outRcs[i]).setRebuildState(true);
((BuildResource)outRc).setRebuildState(true);
}
}
@ -449,16 +445,15 @@ public class BuildDescription implements IBuildDescription {
BuildIOType types[] = input ? (BuildIOType[])step.getInputIOTypes() : (BuildIOType[])step.getOutputIOTypes();
for(int i = 0; i < types.length; i++){
IBuildResource rcs[] = types[i].getResources();
for(int j = 0; j < rcs.length; j++){
String e = rcs[j].getLocation().getFileExtension();
for (BuildIOType type : types) {
for (IBuildResource rc : type.getResources()) {
String e = rc.getLocation().getFileExtension();
if(e == null){
if(ext.length() == 0)
return types[i];
return type;
} else {
if(ext.equals(e))
return types[i];
return type;
}
}
}
@ -467,16 +462,11 @@ public class BuildDescription implements IBuildDescription {
private Map<String, List<ToolAndType>> initToolAndTypeMap(IFolderInfo foInfo){
Map<String, List<ToolAndType>> extToToolAndTypeListMap = new HashMap<String, List<ToolAndType>>();
ITool tools[] = foInfo.getFilteredTools();
for(int i = 0; i < tools.length; i++){
ITool tool = tools[i];
for (ITool tool : foInfo.getFilteredTools()) {
IInputType types[] = tool.getInputTypes();
if(types.length != 0){
for(int j = 0; j < types.length; j++){
IInputType type = types[j];
String exts[] = type.getSourceExtensions(tool);
for(int k = 0; k < exts.length; k++){
String ext = exts[k];
for (IInputType type : types) {
for (String ext : type.getSourceExtensions(tool)) {
if(tool.buildsFileType(ext)){
List<ToolAndType> list = extToToolAndTypeListMap.get(ext);
if(list == null){
@ -488,9 +478,7 @@ public class BuildDescription implements IBuildDescription {
}
}
} else {
String exts[] = tool.getAllInputExtensions();
for(int k = 0; k < exts.length; k++){
String ext = exts[k];
for (String ext : tool.getAllInputExtensions()) {
if(tool.buildsFileType(ext)){
List<ToolAndType> list = extToToolAndTypeListMap.get(ext);
if(list == null){
@ -572,9 +560,8 @@ public class BuildDescription implements IBuildDescription {
return;
} else {
IOutputType[] secondaryOutputs = fCfg.getToolChain().getSecondaryOutputs();
for(int i = 0; i < secondaryOutputs.length; i++){
if(secondaryOutputs[i] == inputActionArg.getIoType()){
for (IOutputType secondaryOutput : fCfg.getToolChain().getSecondaryOutputs()) {
if(secondaryOutput == inputActionArg.getIoType()){
BuildIOType arg = findTypeForExtension(fOutputStep,true,rc.getLocation().getFileExtension());
if(arg == null || arg.isPrimary()){
arg = fOutputStep.createIOType(true, false, null);
@ -608,10 +595,8 @@ public class BuildDescription implements IBuildDescription {
if(tools.length > 0 )
{
tool = fi.getToolsToInvoke()[0];
String exts[] = tool.getAllInputExtensions();
String locString = location.toString();
for(int i = 0; i < exts.length; i++){
String e = exts[i];
for (String e : tool.getAllInputExtensions()) {
if(locString.endsWith(e)){
inputType = tool.getInputType(e);
ext = e;
@ -666,10 +651,10 @@ public class BuildDescription implements IBuildDescription {
BuildIOType outputs[] = (BuildIOType[])action.getOutputIOTypes();
for(int i = 0; i < outputs.length; i++){
BuildResource rcs[] = (BuildResource[])outputs[i].getResources();
for(int j = 0; j < rcs.length; j++){
composeOutputs(action, outputs[i], rcs[j]);
for (BuildIOType output : outputs) {
BuildResource rcs[] = (BuildResource[])output.getResources();
for (BuildResource outputRc : rcs) {
composeOutputs(action, output, outputRc);
}
}
} else {
@ -790,8 +775,8 @@ public class BuildDescription implements IBuildDescription {
}
protected void processBuildState(int state, IPath fullPaths[]){
for(int i = 0; i < fullPaths.length; i++){
processBuildState(state, fullPaths[i]);
for (IPath fullPath : fullPaths) {
processBuildState(state, fullPath);
}
}
@ -847,9 +832,7 @@ public class BuildDescription implements IBuildDescription {
}
private void handleMultiSteps() throws CoreException{
for(int i = 0; i < fOrderedMultiActions.length; i++){
BuildStep action = fOrderedMultiActions[i];
for (BuildStep action : fOrderedMultiActions) {
calculateInputs(action);
calculateOutputs(action, action.getPrimaryTypes(true)[0], null);
@ -859,11 +842,9 @@ public class BuildDescription implements IBuildDescription {
}
BuildIOType args[] = (BuildIOType[])action.getOutputIOTypes();
for(int j = 0; j < args.length; j++){
BuildIOType arg = args[j];
for (BuildIOType arg : args) {
BuildResource rcs[] = (BuildResource[])arg.getResources();
for(int k = 0; k < rcs.length; k++){
BuildResource rc = rcs[k];
for (BuildResource rc : rcs) {
composeOutputs(action, arg, rc);
}
}
@ -871,11 +852,9 @@ public class BuildDescription implements IBuildDescription {
}
private void initMultiSteps(){
ITool tools[] = fCfg.getFilteredTools();
ITool targetTool = fCfg.calculateTargetTool();
for(int i = 0; i < tools.length; i++){
ITool tool = tools[i];
for (ITool tool : fCfg.getFilteredTools()) {
IInputType type = tool.getPrimaryInputType();
BuildStep action = null;
if(type != null ? type.getMultipleOfType() : tool == targetTool){
@ -887,10 +866,9 @@ public class BuildDescription implements IBuildDescription {
}
fOrderedMultiActions = new BuildStep[fToolToMultiStepMap.size()];
ITool orderedTools[] = getOrderedTools();
int index = 0;
for(int i = 0; i < orderedTools.length; i++){
BuildStep action = fToolToMultiStepMap.get(orderedTools[i]);
for (ITool orderedTool : getOrderedTools()) {
BuildStep action = fToolToMultiStepMap.get(orderedTool);
if(action != null)
fOrderedMultiActions[index++] = action;
}
@ -904,8 +882,7 @@ public class BuildDescription implements IBuildDescription {
do{
BuildStep steps[] = (BuildStep[])getSteps();
foundUnused = false;
for(int k = 0; k < steps.length; k++){
BuildStep step = steps[k];
for (BuildStep step : steps) {
if(step == fOutputStep || step == fInputStep)
continue;
@ -967,9 +944,9 @@ public class BuildDescription implements IBuildDescription {
}
BuildIOType deps[] = types[1];
for(int i = 0; i < deps.length; i++){
if(deps[i].getResources().length == 0)
((BuildStep)deps[i].getStep()).removeIOType(deps[i]);
for (BuildIOType dep : deps) {
if(dep.getResources().length == 0)
((BuildStep)dep.getStep()).removeIOType(dep);
}
}
@ -1017,9 +994,9 @@ public class BuildDescription implements IBuildDescription {
private BuildResource[] addOutputs(IPath paths[], BuildIOType buildArg, IPath outDirPath){
if(paths != null){
List<BuildResource> list = new ArrayList<BuildResource>();
for(int k = 0; k < paths.length; k++){
IPath outFullPath = paths[k];
IPath outWorkspacePath = paths[k];
for (IPath path : paths) {
IPath outFullPath = path;
IPath outWorkspacePath = path;
IPath outProjPath;
IPath projLocation = new Path(fProject.getLocationURI().getPath());
@ -1164,8 +1141,7 @@ public class BuildDescription implements IBuildDescription {
ioType = action.createIOType(false, true, type);
addOutputs(new IPath[]{path}, ioType, outDirPath);
} else if (outTypes != null && outTypes.length > 0) {
for (int i=0; i<outTypes.length; i++) {
IOutputType type = outTypes[i];
for (IOutputType type : outTypes) {
boolean primaryOutput = (type == tool.getPrimaryOutputType());
String outputPrefix = type.getOutputPrefix();
String[] pathStrings = null;
@ -1407,11 +1383,10 @@ public class BuildDescription implements IBuildDescription {
IInputType type = action.getInputType();
String ext = null;
if(type != null){
String exts[] = type.getSourceExtensions(tool);
String location = buildRc.getLocation().toOSString();
for(int i = 0; i < exts.length; i++){
if(location.endsWith(exts[i])){
ext = exts[i];
for (String srcExt : type.getSourceExtensions(tool)) {
if(location.endsWith(srcExt)){
ext = srcExt;
break;
}
}
@ -1500,10 +1475,8 @@ public class BuildDescription implements IBuildDescription {
}
public IBuildResource[] getResources(boolean generated){
IBuildResource[] rcs = getResources();
List<IBuildResource> list = new ArrayList<IBuildResource>();
for(int i = 0; i < rcs.length; i++){
IBuildResource rc = rcs[i];
for (IBuildResource rc : getResources()) {
if(generated == (rc.getProducerStep() != fInputStep))
list.add(rc);
}
@ -1528,8 +1501,7 @@ public class BuildDescription implements IBuildDescription {
IBuildEnvironmentVariable variables[] = ManagedBuildManager.getEnvironmentVariableProvider().getVariables(fCfg,true,true);
Map<String, String> map = new HashMap<String, String>();
for(int i = 0; i < variables.length; i++){
IBuildEnvironmentVariable var = variables[i];
for (IBuildEnvironmentVariable var : variables) {
map.put(var.getName(), var.getValue());
}
return map;
@ -1552,8 +1524,7 @@ public class BuildDescription implements IBuildDescription {
ITool tool = step.getTool();
IInputType[] inTypes = tool.getInputTypes();
if (inTypes != null && inTypes.length > 0) {
for (int i=0; i<inTypes.length; i++) {
IInputType type = inTypes[i];
for (IInputType type : inTypes) {
boolean primaryInput = type.getPrimaryInput();
IOption option = tool.getOptionBySuperClassId(type.getOptionId());
BuildIOType arg = step.getIOTypeForType(type, true);
@ -1618,15 +1589,14 @@ public class BuildDescription implements IBuildDescription {
// Get any additional inputs specified in the manifest file or the project file
IAdditionalInput[] addlInputs = type.getAdditionalInputs();
if (addlInputs != null) {
for (int j=0; j<addlInputs.length; j++) {
IAdditionalInput addlInput = addlInputs[j];
for (IAdditionalInput addlInput : addlInputs) {
int kind = addlInput.getKind();
if (kind == IAdditionalInput.KIND_ADDITIONAL_INPUT ||
kind == IAdditionalInput.KIND_ADDITIONAL_INPUT_DEPENDENCY) {
String[] paths = addlInput.getPaths();
if (paths != null) {
for (int k = 0; k < paths.length; k++) {
String strPath = paths[k];
for (String path : paths) {
String strPath = path;
// Translate the path from project relative to
// build directory relative
@ -1646,8 +1616,8 @@ public class BuildDescription implements IBuildDescription {
if(arg == null)
arg = step.createIOType(true, primaryInput, type);
for(int o = 0; o < objs.length; o++){
addInput(objs[o], arg);
for (String userObj : objs) {
addInput(userObj, arg);
}
}
//TODO
@ -1695,12 +1665,12 @@ public class BuildDescription implements IBuildDescription {
BuildResource rcs[] = (BuildResource[])step.getInputResources();
Set<IPath> depSet = new HashSet<IPath>();
for(int i = 0; i < rcs.length; i++){
IManagedDependencyCalculator depCalc = getDependencyCalculator(step, rcs[i]);
for (BuildResource rc : rcs) {
IManagedDependencyCalculator depCalc = getDependencyCalculator(step, rc);
if(depCalc != null){
IPath paths[] = depCalc.getDependencies();
for(int j = 0; j < paths.length; j++){
depSet.add(paths[j]);
for (IPath path : paths) {
depSet.add(path);
}
}
}
@ -1822,10 +1792,8 @@ public class BuildDescription implements IBuildDescription {
ITool tool = step.getLibTool();
if(tool != null){
IOption[] opts = tool.getOptions();
// Look for the lib option type
for (int i = 0; i < opts.length; i++) {
IOption option = opts[i];
for (IOption option : tool.getOptions()) {
try {
if (option.getValueType() == IOption.LIBRARIES) {
@ -1835,19 +1803,16 @@ public class BuildDescription implements IBuildDescription {
if (applicabilitytCalculator == null
|| applicabilitytCalculator.isOptionUsedInCommandLine(fCfg, tool, option)) {
String command = option.getCommand();
String[] allLibs = option.getLibraries();
for (int j = 0; j < allLibs.length; j++)
{
for (String lib : option.getLibraries()) {
try {
String resolved[] = ManagedBuildManager.getBuildMacroProvider().resolveStringListValueToMakefileFormat(
allLibs[j],
lib,
"", //$NON-NLS-1$
" ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_OPTION,
new OptionContextData(option, tool));
if(resolved != null && resolved.length > 0){
for(int k = 0; k < resolved.length; k++){
String string = resolved[k];
for (String string : resolved) {
if(string.length() > 0)
libs.add(command + string);
}
@ -1876,18 +1841,16 @@ public class BuildDescription implements IBuildDescription {
tool = step.getTool();
if(tool != null){
IOption[] opts = tool.getOptions();
// Look for the user object option type
for (int i = 0; i < opts.length; i++) {
IOption option = opts[i];
for (IOption option : tool.getOptions()) {
try {
if (option.getValueType() == IOption.OBJECTS) {
String unresolved[] = option.getUserObjects();
if(unresolved != null && unresolved.length > 0){
for(int k = 0; k < unresolved.length; k++){
for (String unresolvedObj : unresolved) {
try {
String resolved[] = ManagedBuildManager.getBuildMacroProvider().resolveStringListValueToMakefileFormat(
unresolved[k],
unresolvedObj,
"", //$NON-NLS-1$
" ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_OPTION,
@ -1932,8 +1895,8 @@ public class BuildDescription implements IBuildDescription {
inLocation = inFullPath;
inFullPath = null;
IFile files[] = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(inLocation);
for(int i = 0; i < files.length; i++){
IPath fl = files[i].getFullPath();
for (IFile file : files) {
IPath fl = file.getFullPath();
if(fl.segment(0).equals(fProject.getName())){
inFullPath = fl;
break;
@ -2017,8 +1980,8 @@ public class BuildDescription implements IBuildDescription {
boolean put = deps.length == 0;
if(!put && deps.length <= i){
put = true;
for(int k = 0; k < deps.length; k++){
if(indexOf(deps[k], tools, 0, i) == -1){
for (ITool dep : deps) {
if(indexOf(dep, tools, 0, i) == -1){
put = false;
break;
}
@ -2077,15 +2040,12 @@ public class BuildDescription implements IBuildDescription {
String exts[] = tool.getAllInputExtensions();
ITool tools[] = fCfg.getFilteredTools();
Set<ITool> set = new HashSet<ITool>();
for(int i = 0; i < tools.length; i++){
ITool t = tools[i];
for (ITool t : fCfg.getFilteredTools()) {
if(t == tool)
continue;
for(int j = 0; j < exts.length; j++){
String e = exts[j];
for (String e : exts) {
if(t.producesFileType(e)){
IInputType inType = tool.getInputType(e);
IOutputType outType = t.getOutputType(e);
@ -2094,10 +2054,9 @@ public class BuildDescription implements IBuildDescription {
set.add(t);
ToolOrderEstimation est = getToolOrder(t);
ITool deps[] = est.getDeps();
for(int k = 0; k < deps.length; k++){
if(deps[k] != tool)
set.add(deps[k]);
for (ITool dep : est.getDeps()) {
if(dep != tool)
set.add(dep);
else{
if(DbgUtil.DEBUG)
DbgUtil.trace("loop dependency for tool" + tool.getName()); //$NON-NLS-1$
@ -2123,15 +2082,12 @@ public class BuildDescription implements IBuildDescription {
String exts[] = tool.getAllOutputExtensions();
ITool tools[] = fCfg.getFilteredTools();
Set<ITool> set = new HashSet<ITool>();
for(int i = 0; i < tools.length; i++){
ITool t = tools[i];
for (ITool t : fCfg.getFilteredTools()) {
if(t == tool)
continue;
for(int j = 0; j < exts.length; j++){
String e = exts[j];
for (String e : exts) {
if(t.buildsFileType(e)){
IOutputType inType = tool.getOutputType(e);
IInputType outType = t.getInputType(e);
@ -2140,10 +2096,9 @@ public class BuildDescription implements IBuildDescription {
set.add(t);
ToolOrderEstimation est = getToolOrder(t);
ITool consumers[] = est.getConsumers();
for(int k = 0; k < consumers.length; k++){
if(consumers[k] != tool)
set.add(consumers[k]);
for (ITool consumer : est.getConsumers()) {
if(consumer != tool)
set.add(consumer);
else{
if(DbgUtil.DEBUG)
DbgUtil.trace("loop dependency for tool" + tool.getName()); //$NON-NLS-1$
@ -2174,9 +2129,8 @@ public class BuildDescription implements IBuildDescription {
}
protected boolean isGenerated(IPath path){
IPath paths[] = getGeneratedPaths();
for(int i = 0; i < paths.length; i++){
if(paths[i].isPrefixOf(path))
for (IPath genPath : getGeneratedPaths()) {
if(genPath.isPrefixOf(path))
return true;
}
@ -2269,9 +2223,7 @@ public class BuildDescription implements IBuildDescription {
private void initToolInfos(){
fToolInfos = PathSettingsContainer.createRootContainer();
IResourceInfo rcInfos[] = fCfg.getResourceInfos();
for(int i = 0; i < rcInfos.length; i++){
IResourceInfo rcInfo = rcInfos[i];
for (IResourceInfo rcInfo : fCfg.getResourceInfos()) {
// if(rcInfo.isExcluded())
// continue;