Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gvozdev2010-11-04 15:53:56 -0400
committerAndrew Gvozdev2010-11-04 15:53:56 -0400
commit5f088e7a74a61867fbad68e2c25178b305e2fdda (patch)
tree74432423298d7e7924ab1f760298ef58e99cec7b
parent5b51ec0206b571b028dbceca00ab08f3270ae2b2 (diff)
downloadorg.eclipse.cdt-5f088e7a74a61867fbad68e2c25178b305e2fdda.tar.gz
org.eclipse.cdt-5f088e7a74a61867fbad68e2c25178b305e2fdda.tar.xz
org.eclipse.cdt-5f088e7a74a61867fbad68e2c25178b305e2fdda.zip
bug 272432: support template process for setting Enumerated options
Patch from Miwako Tokugawa was used for this change.
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuildObject.java5
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java26
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildObject.java8
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/templateengine/processes/SetMBSStringOptionValue.java7
4 files changed, 41 insertions, 5 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuildObject.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuildObject.java
index 9d29f2962b..fe2bf1bcda 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuildObject.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuildObject.java
@@ -23,7 +23,12 @@ public interface IBuildObject {
public String getId();
public String getName();
+
+ /**
+ * @return id of the object this class was based on during creation or id of the object itself.
+ */
public String getBaseId();
+
/** @since 8.0 */
public Version getVersion();
/** @since 8.0 */
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java
index 8c99ce19e3..487f5e2b95 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java
@@ -3697,6 +3697,32 @@ public class ManagedBuildManager extends AbstractCExtension {
return superId + "." + suffix; //$NON-NLS-1$
}
+
+ private static int isInt(String s) {
+ try {
+ return Integer.parseInt(s);
+ } catch (NumberFormatException e) {
+ return 0;
+ }
+ }
+
+ /**
+ * @return base id when the given id was generated by {@link #calculateChildId(String, String)}.
+ * @since 8.0
+ */
+ public static String calculateBaseId(String id) {
+ int index = id.lastIndexOf('.');
+ if (index<0)
+ return id;
+
+ String lastSeg = id.substring(index+1,id.length());
+ if (isInt(lastSeg)>0) {
+ String baseId = id.substring(0,index);
+ return baseId;
+ }
+ return getIdFromIdAndVersion(id);
+ }
+
/**
* @return calculated relative path given the full path to a folder and a file
*/
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildObject.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildObject.java
index 47389dc2ae..40de8e7fc8 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildObject.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildObject.java
@@ -19,6 +19,7 @@ public class BuildObject implements IBuildObject {
protected String id;
protected String name;
+ private String baseId=null;
protected Version version = null;
protected String managedBuildRevision = null;
@@ -81,10 +82,13 @@ public class BuildObject implements IBuildObject {
}
/**
- * @return Returns the Id without the version (if any).
+ * @return id of the object this class was based on. Note that this function
+ * assumes that id was generated by {@link ManagedBuildManager#calculateChildId(String, String)}.
*/
public String getBaseId() {
- return ManagedBuildManager.getIdFromIdAndVersion(id);
+ if (baseId==null)
+ baseId = ManagedBuildManager.calculateBaseId(id);
+ return baseId;
}
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 624caeb7a5..964fdc46e0 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
@@ -33,7 +33,8 @@ import org.eclipse.core.runtime.IProgressMonitor;
/**
- * This class sets the Managed Build System Option Values.
+ * 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.
@@ -118,7 +119,7 @@ public class SetMBSStringOptionValue extends ProcessRunner {
String lowerId = id.toLowerCase();
int optionType;
for (int i = 0; i < options.length; i++) {
- if (options[i].getId().toLowerCase().matches(lowerId)) {
+ if (options[i].getBaseId().toLowerCase().matches(lowerId)) {
optionType = options[i].getValueType();
if ((optionType == IOption.STRING) || (optionType == IOption.ENUMERATED)) {
IOption setOption = ManagedBuildManager.setOption(resourceConfig, optionHolder, options[i], value);
@@ -137,7 +138,7 @@ public class SetMBSStringOptionValue extends ProcessRunner {
String lowerId = id.toLowerCase();
int optionType;
for (int i = 0; i < options.length; i++) {
- if (options[i].getId().toLowerCase().matches(lowerId)) {
+ if (options[i].getBaseId().toLowerCase().matches(lowerId)) {
optionType = options[i].getValueType();
if ((optionType == IOption.STRING) || (optionType == IOption.ENUMERATED)) {
IOption setOption = ManagedBuildManager.setOption(config, optionHolder, options[i], value);

Back to the top