Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gvozdev2010-11-04 16:24:20 -0400
committerAndrew Gvozdev2010-11-04 16:24:20 -0400
commit0f4a1ee55d7481a8eff312a1170f7d575f39f341 (patch)
tree0b09c7842f65611f2ea499008a64d0dec195501e
parent4b6bf637420b77fac55098880e6888434a079c21 (diff)
downloadorg.eclipse.cdt-0f4a1ee55d7481a8eff312a1170f7d575f39f341.tar.gz
org.eclipse.cdt-0f4a1ee55d7481a8eff312a1170f7d575f39f341.tar.xz
org.eclipse.cdt-0f4a1ee55d7481a8eff312a1170f7d575f39f341.zip
bug 272432: tidied up + setBaseId()
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/templateengine/processes/SetMBSBooleanOptionValue.java54
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/templateengine/processes/SetMBSStringListOptionValues.java54
2 files changed, 44 insertions, 64 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/templateengine/processes/SetMBSBooleanOptionValue.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/templateengine/processes/SetMBSBooleanOptionValue.java
index 391615a8bb..b0f14f1812 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/templateengine/processes/SetMBSBooleanOptionValue.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/templateengine/processes/SetMBSBooleanOptionValue.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;
@@ -34,12 +34,12 @@ import org.eclipse.core.runtime.IProgressMonitor;
/**
* This class sets the Managed Build System Option boolean Values.
- *
+ *
* @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
*/
public class SetMBSBooleanOptionValue extends ProcessRunner {
-
+
@Override
public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) throws ProcessFailureException {
String projectName = args[0].getSimpleValue();
@@ -52,11 +52,10 @@ public class SetMBSBooleanOptionValue 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();
@@ -76,15 +75,14 @@ public class SetMBSBooleanOptionValue 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);
@@ -96,33 +94,30 @@ public class SetMBSBooleanOptionValue 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();
- for (int i = 0; i < options.length; i++) {
- if (options[i].getId().toLowerCase().matches(lowerId)) {
- if (options[i].getValueType() == IOption.BOOLEAN) {
- IOption setOption = ManagedBuildManager.setOption(resourceConfig, optionHolder, options[i], Boolean.valueOf(value).booleanValue());
- if (setOption == null) {
- setOption = options[i];
- }
+ for (IOption option : options) {
+ if (option.getBaseId().toLowerCase().matches(lowerId)) {
+ if (option.getValueType() == IOption.BOOLEAN) {
+ ManagedBuildManager.setOption(resourceConfig, optionHolder, option, Boolean.valueOf(value).booleanValue());
modified = true;
}
}
@@ -133,13 +128,10 @@ public class SetMBSBooleanOptionValue extends ProcessRunner {
private boolean setOptionForConfig(String id, String value, IConfiguration config, IOption[] options, IHoldsOptions optionHolder) throws BuildException {
boolean modified = false;
String lowerId = id.toLowerCase();
- for (int i = 0; i < options.length; i++) {
- if (options[i].getId().toLowerCase().matches(lowerId)) {
- if (options[i].getValueType() == IOption.BOOLEAN) {
- IOption setOption = ManagedBuildManager.setOption(config, optionHolder, options[i], Boolean.valueOf(value).booleanValue());
- if (setOption == null) {
- setOption = options[i];
- }
+ for (IOption option : options) {
+ if (option.getBaseId().toLowerCase().matches(lowerId)) {
+ if (option.getValueType() == IOption.BOOLEAN) {
+ ManagedBuildManager.setOption(config, optionHolder, option, Boolean.valueOf(value).booleanValue());
modified = true;
}
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/templateengine/processes/SetMBSStringListOptionValues.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/templateengine/processes/SetMBSStringListOptionValues.java
index 1e3eb02339..74ab0cb50f 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/templateengine/processes/SetMBSStringListOptionValues.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/templateengine/processes/SetMBSStringListOptionValues.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;
@@ -34,12 +34,12 @@ import org.eclipse.core.runtime.IProgressMonitor;
/**
* This class Sets (overwrites) contents of Managed Build System StringList Option Values.
- *
+ *
* @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
*/
public class SetMBSStringListOptionValues extends ProcessRunner {
-
+
@Override
public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) throws ProcessFailureException {
String projectName = args[0].getSimpleValue();
@@ -52,11 +52,10 @@ public class SetMBSStringListOptionValues 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[] values = resourcePathObject[1].getSimpleArrayValue();
String path = resourcePathObject[2].getSimpleValue();
@@ -76,15 +75,14 @@ public class SetMBSStringListOptionValues 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);
@@ -96,30 +94,28 @@ public class SetMBSStringListOptionValues 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();
- for (int i = 0; i < options.length; i++) {
- IOption option = options[i];
- if (option.getId().toLowerCase().matches(lowerId)) {
- IOption setOption = null;
+ for (IOption option : options) {
+ if (option.getBaseId().toLowerCase().matches(lowerId)) {
switch (option.getValueType()) {
case IOption.STRING_LIST:
case IOption.INCLUDE_PATH:
@@ -130,14 +126,11 @@ public class SetMBSStringListOptionValues extends ProcessRunner {
case IOption.LIBRARY_PATHS:
case IOption.LIBRARY_FILES:
case IOption.MACRO_FILES:
- setOption = ManagedBuildManager.setOption(resourceConfig, optionHolder, option, value);
+ ManagedBuildManager.setOption(resourceConfig, optionHolder, option, value);
break;
default:
continue;
}
- if (setOption == null) {
- setOption = option;
- }
modified = true;
}
}
@@ -147,10 +140,8 @@ public class SetMBSStringListOptionValues extends ProcessRunner {
private boolean setOptionForConfig(String id, String[] value, IConfiguration config, IOption[] options, IHoldsOptions optionHolder) throws BuildException {
boolean modified = false;
String lowerId = id.toLowerCase();
- for (int i = 0; i < options.length; i++) {
- IOption option = options[i];
- if (option.getId().toLowerCase().matches(lowerId)) {
- IOption setOption = null;
+ for (IOption option : options) {
+ if (option.getBaseId().toLowerCase().matches(lowerId)) {
switch (option.getValueType()) {
case IOption.STRING_LIST:
case IOption.INCLUDE_PATH:
@@ -161,14 +152,11 @@ public class SetMBSStringListOptionValues extends ProcessRunner {
case IOption.LIBRARY_PATHS:
case IOption.LIBRARY_FILES:
case IOption.MACRO_FILES:
- setOption = ManagedBuildManager.setOption(config, optionHolder, option, value);
+ ManagedBuildManager.setOption(config, optionHolder, option, value);
break;
default:
continue;
}
- if (setOption == null) {
- setOption = option;
- }
modified = true;
}
}

Back to the top