Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gvozdev2010-11-04 16:04:12 -0400
committerAndrew Gvozdev2010-11-04 16:04:12 -0400
commit4b6bf637420b77fac55098880e6888434a079c21 (patch)
tree7ec596d459063ae51d9955f180d0a55a9bdd45ce
parent5f088e7a74a61867fbad68e2c25178b305e2fdda (diff)
downloadorg.eclipse.cdt-4b6bf637420b77fac55098880e6888434a079c21.tar.gz
org.eclipse.cdt-4b6bf637420b77fac55098880e6888434a079c21.tar.xz
org.eclipse.cdt-4b6bf637420b77fac55098880e6888434a079c21.zip
bug 272432: tidied up a bit
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/templateengine/processes/SetMBSStringOptionValue.java56
1 files changed, 23 insertions, 33 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/templateengine/processes/SetMBSStringOptionValue.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/templateengine/processes/SetMBSStringOptionValue.java
index 964fdc46e0..fbb5c76a58 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/templateengine/processes/SetMBSStringOptionValue.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/templateengine/processes/SetMBSStringOptionValue.java
@@ -10,11 +10,11 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.templateengine.processes;
-import org.eclipse.cdt.core.templateengine.process.processes.Messages;
import org.eclipse.cdt.core.templateengine.TemplateCore;
import org.eclipse.cdt.core.templateengine.process.ProcessArgument;
import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
import org.eclipse.cdt.core.templateengine.process.ProcessRunner;
+import org.eclipse.cdt.core.templateengine.process.processes.Messages;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
@@ -35,12 +35,12 @@ import org.eclipse.core.runtime.IProgressMonitor;
/**
* This class sets the Managed Build System Option Values. Note that this class
* handles both string options and enumerated options.
- *
+ *
* @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
*/
public class SetMBSStringOptionValue extends ProcessRunner {
-
+
@Override
public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) throws ProcessFailureException {
String projectName = args[0].getSimpleValue();
@@ -53,11 +53,10 @@ public class SetMBSStringOptionValue extends ProcessRunner {
workspace.setDescription(workspaceDesc);
} catch (CoreException e) {//ignore
}
-
+
ProcessArgument[][] resourcePathObjects = args[1].getComplexArrayValue();
boolean modified = false;
- for(int i=0; i<resourcePathObjects.length; i++) {
- ProcessArgument[] resourcePathObject = resourcePathObjects[i];
+ for (ProcessArgument[] resourcePathObject : resourcePathObjects) {
String id = resourcePathObject[0].getSimpleValue();
String value = resourcePathObject[1].getSimpleValue();
String path = resourcePathObject[2].getSimpleValue();
@@ -77,15 +76,14 @@ public class SetMBSStringOptionValue extends ProcessRunner {
} catch (CoreException e) {//ignore
}
}
-
+
private boolean setOptionValue(IProject projectHandle, String id, String value, String path) throws BuildException, ProcessFailureException {
IConfiguration[] projectConfigs = ManagedBuildManager.getBuildInfo(projectHandle).getManagedProject().getConfigurations();
-
+
boolean resource = !(path == null || path.equals("") || path.equals("/")); //$NON-NLS-1$ //$NON-NLS-2$
boolean modified = false;
-
- for(int i=0; i<projectConfigs.length; i++) {
- IConfiguration config = projectConfigs[i];
+
+ for (IConfiguration config : projectConfigs) {
IResourceConfiguration resourceConfig = null;
if (resource) {
resourceConfig = config.getResourceConfiguration(path);
@@ -97,35 +95,31 @@ public class SetMBSStringOptionValue extends ProcessRunner {
resourceConfig = config.createResourceConfiguration(file);
}
ITool[] tools = resourceConfig.getTools();
- for(int j=0; j<tools.length; j++) {
- modified |= setOptionForResourceConfig(id, value, resourceConfig, tools[j].getOptions(), tools[j]);
+ for (ITool tool : tools) {
+ modified |= setOptionForResourceConfig(id, value, resourceConfig, tool.getOptions(), tool);
}
} else {
IToolChain toolChain = config.getToolChain();
modified |= setOptionForConfig(id, value, config, toolChain.getOptions(), toolChain);
-
+
ITool[] tools = config.getTools();
- for(int j=0; j<tools.length; j++) {
- modified |= setOptionForConfig(id, value, config, tools[j].getOptions(), tools[j]);
+ for (ITool tool : tools) {
+ modified |= setOptionForConfig(id, value, config, tool.getOptions(), tool);
}
}
}
-
+
return modified;
}
private boolean setOptionForResourceConfig(String id, String value, IResourceConfiguration resourceConfig, IOption[] options, IHoldsOptions optionHolder) throws BuildException {
boolean modified = false;
String lowerId = id.toLowerCase();
- int optionType;
- for (int i = 0; i < options.length; i++) {
- if (options[i].getBaseId().toLowerCase().matches(lowerId)) {
- optionType = options[i].getValueType();
+ for (IOption option : options) {
+ if (option.getBaseId().toLowerCase().matches(lowerId)) {
+ int optionType = option.getValueType();
if ((optionType == IOption.STRING) || (optionType == IOption.ENUMERATED)) {
- IOption setOption = ManagedBuildManager.setOption(resourceConfig, optionHolder, options[i], value);
- if (setOption == null) {
- setOption = options[i];
- }
+ ManagedBuildManager.setOption(resourceConfig, optionHolder, option, value);
modified = true;
}
}
@@ -136,15 +130,11 @@ public class SetMBSStringOptionValue extends ProcessRunner {
private boolean setOptionForConfig(String id, String value, IConfiguration config, IOption[] options, IHoldsOptions optionHolder) throws BuildException {
boolean modified = false;
String lowerId = id.toLowerCase();
- int optionType;
- for (int i = 0; i < options.length; i++) {
- if (options[i].getBaseId().toLowerCase().matches(lowerId)) {
- optionType = options[i].getValueType();
+ for (IOption option : options) {
+ if (option.getBaseId().toLowerCase().matches(lowerId)) {
+ int optionType = option.getValueType();
if ((optionType == IOption.STRING) || (optionType == IOption.ENUMERATED)) {
- IOption setOption = ManagedBuildManager.setOption(config, optionHolder, options[i], value);
- if (setOption == null) {
- setOption = options[i];
- }
+ ManagedBuildManager.setOption(config, optionHolder, option, value);
modified = true;
}
}

Back to the top