1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-24 08:44:01 +02:00

formatting, mostly spaces and loops to enhanced

This commit is contained in:
Andrew Gvozdev 2009-07-31 01:54:45 +00:00
parent 7a2e4aeffe
commit 482d0431f3

View file

@ -116,9 +116,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
* to avoid a missing target error.
*/
public class ResourceDeltaVisitor implements IResourceDeltaVisitor {
private GnuMakefileGenerator generator;
private final GnuMakefileGenerator generator;
// private IManagedBuildInfo info;
private IConfiguration config;
private final IConfiguration config;
/**
* The constructor
@ -212,8 +212,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
* modules contribute buildable source files.
*/
protected class ResourceProxyVisitor implements IResourceProxyVisitor {
private GnuMakefileGenerator generator;
private IConfiguration config;
private final GnuMakefileGenerator generator;
private final IConfiguration config;
// private IManagedBuildInfo info;
/**
@ -360,13 +360,13 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
private IPath topBuildDir; // Build directory - relative to the workspace
// private Set outputExtensionsSet;
// Maps of macro names (String) to values (List)
private HashMap buildSrcVars = new HashMap(); // Map of source file build variable names
private final HashMap buildSrcVars = new HashMap(); // Map of source file build variable names
// to a List of source file Path's
private HashMap buildOutVars = new HashMap(); // Map of output file build variable names
private final HashMap buildOutVars = new HashMap(); // Map of output file build variable names
// to a List of output file Path's
private HashMap buildDepVars = new HashMap(); // Map of dependency file build variable names
private final HashMap buildDepVars = new HashMap(); // Map of dependency file build variable names
// to a List of GnuDependencyGroupInfo objects
private LinkedHashMap topBuildOutVars = new LinkedHashMap();
private final LinkedHashMap topBuildOutVars = new LinkedHashMap();
// Dependency file variables
// private Vector dependencyMakefiles; // IPath's - relative to the top build directory or absolute
@ -798,8 +798,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
IPath path = resource.getProjectRelativePath();
//TODO: fix to use builder output dir instead
String[] configNames = ManagedBuildManager.getBuildInfo(project).getConfigurationNames();
for (int i = 0; i < configNames.length; i++) {
String name = configNames[i];
for (String name : configNames) {
IPath root = new Path(name);
// It is if it is a root of the resource pathname
if (root.isPrefixOf(path)) return true;
@ -1016,18 +1015,16 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
// Add the libraries this project depends on
valueList = new ArrayList();
String[] libs = config.getLibs(buildTargetExt);
for (int i = 0; i < libs.length; i++) {
String string = libs[i];
valueList.add(string);
for (String lib : libs) {
valueList.add(lib);
}
outputMacros.put("LIBS", valueList); //$NON-NLS-1$
// Add the extra user-specified objects
valueList = new ArrayList();
String[] userObjs = config.getUserObjects(buildTargetExt);
for (int i = 0; i < userObjs.length; i++) {
String string = userObjs[i];
valueList.add(string);
for (String obj : userObjs) {
valueList.add(obj);
}
outputMacros.put("USER_OBJS", valueList); //$NON-NLS-1$
@ -1079,14 +1076,14 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
ITool[] buildTools = h.buildTools;
HashSet handledInputExtensions = new HashSet();
String buildMacro;
for (int i=0; i<buildTools.length; i++) {
if(buildTools[i].getCustomBuildStep())
for (ITool buildTool : buildTools) {
if(buildTool.getCustomBuildStep())
continue;
// Add the known sources macros
String[] extensionsList = buildTools[i].getAllInputExtensions();
for (int j=0; j<extensionsList.length; j++) {
String[] extensionsList = buildTool.getAllInputExtensions();
for (String ext : extensionsList) {
// create a macro of the form "EXTENSION_SRCS :="
String extensionName = extensionsList[j];
String extensionName = ext;
if(//!getOutputExtensions().contains(extensionName) &&
!handledInputExtensions.contains(extensionName)) {
handledInputExtensions.add(extensionName);
@ -1095,7 +1092,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
buildSrcVars.put(buildMacro, new ArrayList());
}
// Add any generated dependency file macros
IManagedDependencyGeneratorType depType = buildTools[i].getDependencyGeneratorForExtension(extensionName);
IManagedDependencyGeneratorType depType = buildTool.getDependencyGeneratorForExtension(extensionName);
if (depType != null) {
int calcType = depType.getCalculatorType();
if (calcType == IManagedDependencyGeneratorType.TYPE_COMMAND ||
@ -1114,17 +1111,17 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
}
}
// Add the specified output build variables
IOutputType[] outTypes = buildTools[i].getOutputTypes();
IOutputType[] outTypes = buildTool.getOutputTypes();
if (outTypes != null && outTypes.length > 0) {
for (int j=0; j<outTypes.length; j++) {
buildMacro = outTypes[j].getBuildVariable();
for (IOutputType outputType : outTypes) {
buildMacro = outputType.getBuildVariable();
if (!buildOutVars.containsKey(buildMacro)) {
buildOutVars.put(buildMacro, new ArrayList());
}
}
} else {
// For support of pre-CDT 3.0 integrations.
buildMacro = OBJS_MACRO; //$NON-NLS-1$
buildMacro = OBJS_MACRO;
if (!buildOutVars.containsKey(buildMacro)) {
buildOutVars.put(buildMacro, new ArrayList());
}
@ -1400,9 +1397,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
if (refConfigs.length > 0) {
boolean addDeps = true;
// if (refdProjects != null) {
for (int i = 0; i < refConfigs.length; i++) {
for (IConfiguration depCfg : refConfigs) {
// IProject dep = refdProjects[i];
IConfiguration depCfg = refConfigs[i];
if(!depCfg.isManagedBuildOn())
continue;
@ -1796,16 +1792,16 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
ITool[] buildTools = h.buildTools;
boolean[] buildToolsUsed = h.buildToolsUsed;
IOutputType[] outTypes = generatingTool.getOutputTypes();
for (int i=0; i<outTypes.length; i++) {
String[] outExts = outTypes[i].getOutputExtensions(generatingTool);
String outVariable = outTypes[i].getBuildVariable();
for (IOutputType outType : outTypes) {
String[] outExts = outType.getOutputExtensions(generatingTool);
String outVariable = outType.getBuildVariable();
if (outExts != null) {
for (int j=0; j<outExts.length; j++) {
for (String outExt : outExts) {
for (int k=0; k<buildTools.length; k++) {
ITool tool = buildTools[k];
if (!buildToolsUsed[k]) {
// Also has to match build variables if specified
IInputType inType = tool.getInputType(outExts[j]);
IInputType inType = tool.getInputType(outExt);
if (inType != null) {
String inVariable = inType.getBuildVariable();
if ((outVariable == null && inVariable == null) ||
@ -1861,7 +1857,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
if (bTargetTool && managedProjectOutputs != null) {
Iterator refIter = managedProjectOutputs.listIterator();
while (refIter.hasNext()) {
dependencies.add((String)refIter.next());
dependencies.add(refIter.next());
}
}
return true;
@ -1911,10 +1907,10 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
// Is this one of the secondary outputs?
// Look for an outputType with this ID, or one with a superclass with this id
thisType:
for (int k = 0; k < secondaryOutputs.length; k++) {
for (IOutputType secondaryOutput : secondaryOutputs) {
IOutputType matchType = outType;
do {
if (matchType.getId().equals(secondaryOutputs[k].getId())) {
if (matchType.getId().equals(secondaryOutput.getId())) {
if (outType.getBuildVariable().equals(varName)) {
return true;
}
@ -2016,8 +2012,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
IResourceInfo rcInfo;
IFolder folder = project.getFolder(config.getName());
for (int i = 0; i < resources.length; i++) {
IResource resource = resources[i];
for (IResource resource : resources) {
if (resource.getType() == IResource.FILE) {
// Check whether this resource is excluded from build
IPath rcProjRelPath = resource.getProjectRelativePath();
@ -2096,10 +2091,10 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
h = getToolInfo(Path.EMPTY);
buildTools = h.buildTools;
for (int j=0; j<buildTools.length; j++) {
if (buildTools[j].buildsFileType(ext)) {
for (ITool buildTool : buildTools) {
if (buildTool.buildsFileType(ext)) {
if (tool == null) {
tool = buildTools[j];
tool = buildTool;
}
addToBuildVar(buildVarToRuleStringMap, ext, varName, relativePath, sourceLocation, generatedSource);
break;
@ -2146,9 +2141,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
String firstExt = firstOutput.getFileExtension();
ToolInfoHolder tmpH = getFolderToolInfo(rcInfo.getPath());
ITool[] tmpBuildTools = tmpH.buildTools;
for (int j=0; j<tmpBuildTools.length; j++) {
if (tmpBuildTools[j].buildsFileType(firstExt)) {
String bV = tmpBuildTools[j].getPrimaryInputType().getBuildVariable();
for (ITool tmpBuildTool : tmpBuildTools) {
if (tmpBuildTool.buildsFileType(firstExt)) {
String bV = tmpBuildTool.getPrimaryInputType().getBuildVariable();
if (bV.length() > 0) {
buildVariable = bV;
break;
@ -2190,8 +2185,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
} else {
// If this is a secondary input, add it to build vars
if (varName == null) {
for (int j=0; j<buildTools.length; j++) {
if (buildTools[j].isInputFileType(ext)) {
for (ITool buildTool : buildTools) {
if (buildTool.isInputFileType(ext)) {
addToBuildVar(buildVarToRuleStringMap, ext, varName, relativePath, sourceLocation, generatedSource);
break;
}
@ -2402,9 +2397,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
depFiles = depPreBuild.getDependencyFiles();
}
if (depFiles != null) {
for (int i=0; i<depFiles.length; i++) {
getDependencyMakefiles(h).add(depFiles[i]);
generatedDepFiles.add(depFiles[i]);
for (IPath depFile : depFiles) {
getDependencyMakefiles(h).add(depFile);
generatedDepFiles.add(depFile);
}
}
}
@ -2539,7 +2534,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
// Make sure that at least one of the rule outputs contains a %.
for (int i=0; i<ruleOutputs.size(); i++) {
String ruleOutput = ((IPath)ruleOutputs.get(i)).toString();
if (ruleOutput.indexOf('%') >= 0) { //$NON-NLS-1$
if (ruleOutput.indexOf('%') >= 0) {
patternRule = true;
break;
}
@ -2559,7 +2554,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
boolean first = true;
for (int i=0; i<ruleOutputs.size(); i++) {
String ruleOutput = ((IPath)ruleOutputs.get(i)).toString();
if (ruleOutput.indexOf('%') >= 0) { //$NON-NLS-1$
if (ruleOutput.indexOf('%') >= 0) {
if (first) {
first = false;
} else {
@ -2579,9 +2574,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
// Other additional inputs
// Get any additional dependencies specified for the tool in other InputType elements and AdditionalInput elements
IPath[] addlDepPaths = tool.getAdditionalDependencies();
for (int i=0; i<addlDepPaths.length; i++) {
for (IPath addlDepPath : addlDepPaths) {
// Translate the path from project relative to build directory relative
IPath addlPath = addlDepPaths[i];
IPath addlPath = addlDepPath;
if (!(addlPath.toString().startsWith("$("))) { //$NON-NLS-1$
if (!addlPath.isAbsolute()) {
IPath tempPath = project.getLocation().append(new Path(ensureUnquoted(addlPath.toString())));
@ -2614,10 +2609,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
if (depCommands != null) {
String[] preToolCommands = depCommands.getPreToolDependencyCommands();
if (preToolCommands != null && preToolCommands.length > 0) {
for (int i=0; i<preToolCommands.length; i++) {
for (String preCmd : preToolCommands) {
try {
String resolvedCommand;
String preCmd = preToolCommands[i];
IBuildMacroProvider provider = ManagedBuildManager.getBuildMacroProvider();
if (!needExplicitRuleForFile) {
resolvedCommand = provider.resolveValueToMakefileFormat(
@ -2654,9 +2648,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
// Other additional inputs
// Get any additional dependencies specified for the tool in other InputType elements and AdditionalInput elements
IPath[] addlInputPaths = getAdditionalResourcesForSource(tool);
for (int i=0; i<addlInputPaths.length; i++) {
for (IPath addlInputPath : addlInputPaths) {
// Translate the path from project relative to build directory relative
IPath addlPath = addlInputPaths[i];
IPath addlPath = addlInputPath;
if (!(addlPath.toString().startsWith("$("))) { //$NON-NLS-1$
if (!addlPath.isAbsolute()) {
IPath tempPath = getPathForResource(project).append(addlPath);
@ -2712,9 +2706,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
buildCmd = cmdLInfo.getCommandLine();
} else {
StringBuffer buildFlags = new StringBuffer();
for (int index = 0; index < flags.length; index++) {
if( flags[ index ] != null ) {
buildFlags.append( flags[ index ] + WHITESPACE );
for (String flag : flags) {
if( flag != null ) {
buildFlags.append( flag + WHITESPACE );
}
}
buildCmd = cmd + WHITESPACE + buildFlags.toString().trim() + WHITESPACE + outflag + WHITESPACE +
@ -2770,11 +2764,10 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
}
if (depCmds != null) {
for (int i=0; i<depCmds.length; i++) {
for (String depCmd : depCmds) {
// Resolve any macros in the dep command after it has been generated.
// Note: do not trim the result because it will strip out necessary tab characters.
buffer.append(WHITESPACE + LOGICAL_AND + WHITESPACE + LINEBREAK);
String depCmd = depCmds[i];
try {
if (!needExplicitRuleForFile) {
depCmd = ManagedBuildManager.getBuildMacroProvider()
@ -2834,8 +2827,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
if (addlDeps != null && addlDeps.length > 0) {
calculatedDependencies = new String();
for (int i=0; i<addlDeps.length; i++) {
calculatedDependencies += WHITESPACE + escapeWhitespaces(addlDeps[i].toString());
for (IPath addlDep : addlDeps) {
calculatedDependencies += WHITESPACE + escapeWhitespaces(addlDep.toString());
}
}
@ -2856,7 +2849,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
}
addlOutputs.addAll(enumeratedSecondaryOutputs);
if (addlTargets != null) {
for (int i=0; i<addlTargets.length; i++) addlOutputs.add(addlTargets[i]);
for (IPath addlTarget : addlTargets)
addlOutputs.add(addlTarget);
}
for (int i=0; i<addlOutputs.size(); i++) {
depLine = escapeWhitespaces(((IPath)addlOutputs.get(i)).toString()) + COLON + WHITESPACE + primaryOutputName;
@ -2900,8 +2894,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
addedDepLines = true;
buffer.append(depLine + NEWLINE);
buffer.append(TAB + AT + escapedEcho(MESSAGE_START_DEPENDENCY + WHITESPACE + OUT_MACRO));
for (int i=0; i<preBuildCommands.length; i++) {
depLine = preBuildCommands[i];
for (String preBuildCommand : preBuildCommands) {
depLine = preBuildCommand;
// Resolve macros
try {
if (!needExplicitRuleForFile) {
@ -2968,13 +2962,12 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
protected IPath[] getAdditionalResourcesForSource(ITool tool) {
List allRes = new ArrayList();
IInputType[] types = tool.getInputTypes();
for (int i=0; i<types.length; i++) {
IInputType type = types[i];
for (IInputType type : types) {
// Additional resources come from 2 places.
// 1. From AdditionalInput childen
IPath[] res = type.getAdditionalResources();
for (int j=0; j<res.length; j++) {
allRes.add(res[j]);
for (IPath re : res) {
allRes.add(re);
}
// 2. From InputTypes that other than the primary input type
if (type != tool.getPrimaryInputType()) {
@ -2984,15 +2977,15 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
} else {
// Use file extensions
String[] typeExts = type.getSourceExtensions(tool);
for (int j=0; j<projectResources.length; j++) {
if (projectResources[j].getType() == IResource.FILE) {
String fileExt = projectResources[j].getFileExtension();
for (IResource projectResource : projectResources) {
if (projectResource.getType() == IResource.FILE) {
String fileExt = projectResource.getFileExtension();
if(fileExt == null) {
fileExt = ""; //$NON-NLS-1$
}
for (int k=0; k<typeExts.length; k++) {
if (fileExt.equals(typeExts[k])) {
allRes.add(projectResources[j].getProjectRelativePath());
for (String typeExt : typeExts) {
if (fileExt.equals(typeExt)) {
allRes.add(projectResource.getProjectRelativePath());
break;
}
}
@ -3103,8 +3096,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
IOutputType[] outTypes = tool.getOutputTypes();
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());
//if (primaryOutput && ignorePrimary) continue;
String outputPrefix = type.getOutputPrefix();
@ -3440,10 +3432,10 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
case IManagedDependencyGeneratorType.TYPE_EXTERNAL:
IResource[] res = depGen.findDependencies(resource, project);
if (res != null) {
for (int i=0; i<res.length; i++) {
for (IResource re : res) {
IPath dep = null;
if (res[i] != null) {
IPath addlPath = res[i].getLocation();
if (re != null) {
IPath addlPath = re.getLocation();
if (addlPath != null) {
dep = ManagedBuildManager.calculateRelativePath(getTopBuildDir(), addlPath);
}
@ -3455,7 +3447,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
}
break;
case IManagedDependencyGenerator.TYPE_NODEPS:
case IManagedDependencyGeneratorType.TYPE_NODEPS:
default:
break;
}
@ -3474,7 +3466,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
for (int i=0; i<addlDeps.length; i++) {
if (!addlDeps[i].isAbsolute()) {
// Convert from project relative to build directory relative
IPath absolutePath = project.getLocation().append((IPath)addlDeps[i]);
IPath absolutePath = project.getLocation().append(addlDeps[i]);
addlDeps[i] = ManagedBuildManager.calculateRelativePath(getTopBuildDir(), absolutePath);
}
}
@ -3546,8 +3538,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
// For each tool for the target, lookup the kinds of sources it outputs
// and add that to our list of output extensions.
for (int i=0; i<h.buildTools.length; i++) {
ITool tool = h.buildTools[i];
for (ITool tool : h.buildTools) {
String[] outputs = tool.getAllOutputExtensions();
if (outputs != null) {
h.outputExtensionsSet.addAll(Arrays.asList(outputs));
@ -3605,8 +3596,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
// Try to determine if this file already has dummy targets defined.
// If so, we will only add the comment.
String[] bufferLines = inBufferString.split("[\\r\\n]"); //$NON-NLS-1$
for (int i=0; i<bufferLines.length; i++) {
String bufferLine = bufferLines[i];
for (String bufferLine : bufferLines) {
if (bufferLine.endsWith(":")) { //$NON-NLS-1$
StringBuffer outBuffer = addDefaultHeader();
outBuffer.append(inBuffer);
@ -3955,7 +3945,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
buffer.append(COMMENT_SYMBOL + WHITESPACE + ManagedMakeMessages.getResourceString(MOD_VARS) + NEWLINE);
for (int i=0; i<varList.size(); i++) {
String addition = (String)varMap.get((String)varList.get(i));
String addition = (String)varMap.get(varList.get(i));
StringBuffer currentBuffer = new StringBuffer();
currentBuffer.append(addition);
currentBuffer.append(NEWLINE);
@ -4079,8 +4069,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
}
// Are all calculated? If so, done.
done = true;
for (int i=0; i<testState.length; i++) {
if (testState[i] != 3) {
for (int element : testState) {
if (element != 3) {
done = false;
break;
}
@ -4492,8 +4482,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
// Delete the files if they exist
if (depFilePaths != null) {
for (int i=0; i<depFilePaths.length; i++) {
IPath depFilePath = getBuildWorkingDir().append(depFilePaths[i]);
for (IPath dfp : depFilePaths) {
IPath depFilePath = getBuildWorkingDir().append(dfp);
IResource depFile = project.findMember(depFilePath);
if (depFile != null && depFile.exists()) {
try {
@ -4739,8 +4729,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
toolInfos = PathSettingsContainer.createRootContainer();
IResourceInfo rcInfos[] = config.getResourceInfos();
for(int i = 0; i < rcInfos.length; i++){
IResourceInfo rcInfo = rcInfos[i];
for (IResourceInfo rcInfo : rcInfos) {
if(rcInfo.isExcluded() /*&& !((ResourceInfo)rcInfo).isRoot()*/)
continue;