Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2003-05-21 12:30:00 -0400
committerDoug Schaefer2003-05-21 12:30:00 -0400
commit7b1c64d5fe4a293fbeb9decf07bb5eaec28090e0 (patch)
treee1f479962f95cec64f0ed1bfce656b70aaee9320 /core/org.eclipse.cdt.core/build
parent188519819460c20ea2781c622bf74dcca6bfaecb (diff)
downloadorg.eclipse.cdt-7b1c64d5fe4a293fbeb9decf07bb5eaec28090e0.tar.gz
org.eclipse.cdt-7b1c64d5fe4a293fbeb9decf07bb5eaec28090e0.tar.xz
org.eclipse.cdt-7b1c64d5fe4a293fbeb9decf07bb5eaec28090e0.zip
Patch for Sean Evoy:
Core 1. Added 2 new option types: Boolean and enumerated 2. Changed the IOption interface to get new option type values 3. In plugin manifest and IOption interface added concept of a default enumerated value to support on-going GUI work 4. In plugin manifest and IOption, added field to map the actual command line argument with the option for makefile generation. Tests 1. Changed the plugin.xml manifest to match the new option types 2. AllBuildTests.java updated to test new option types and fields added in core
Diffstat (limited to 'core/org.eclipse.cdt.core/build')
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOption.java59
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Option.java79
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java104
3 files changed, 204 insertions, 38 deletions
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOption.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOption.java
index 7926ed79cb..1004a71123 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOption.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOption.java
@@ -16,16 +16,25 @@ package org.eclipse.cdt.core.build.managed;
public interface IOption extends IBuildObject {
// Type for the value of the option
- public static final int STRING = 0;
- public static final int STRING_LIST = 1;
+ public static final int BOOLEAN = 0;
+ public static final int ENUMERATED = 1;
+ public static final int STRING = 2;
+ public static final int STRING_LIST = 3;
/**
- * Returns the tool defining this option.
+ * If this option is defined as an enumeration, this function returns
+ * the list of possible values for that enum.
*
+ * If this option is not defined as an enumeration, it returns null.
* @return
*/
- public ITool getTool();
-
+ public String [] getApplicableValues();
+
+ /**
+ * @return the value for a boolean option.
+ */
+ public boolean getBooleanValue() throws BuildException;
+
/**
* Returns the category for this option.
*
@@ -34,27 +43,37 @@ public interface IOption extends IBuildObject {
public IOptionCategory getCategory();
/**
- * Returns the name of this option.
- *
- * @return
+ * @return a String containing the actual command line option
+ * associated with the <code>IOption</code>
*/
- public String getName();
+ public String getCommand();
/**
- * Get the type for the value of the option.
+ * @return a <code>String</code> containing the default value for the
+ * enumerated option.
+ */
+ public String getDefaultEnumName ();
+
+
+ /**
+ * @return <code>String</code> containing the command associated with the
+ * enumeration name.
+ */
+ public String getEnumCommand (String name);
+
+ /**
+ * Returns the name of this option.
*
* @return
*/
- public int getValueType();
+ public String getName();
/**
- * If this option is defined as an enumeration, this function returns
- * the list of possible values for that enum.
+ * Returns the current value for this option if it is a List of Strings.
*
- * If this option is not defined as an enumeration, it returns null.
* @return
*/
- public String [] getApplicableValues();
+ public String [] getStringListValue() throws BuildException;
/**
* Returns the current value for this option if it is a String
@@ -64,10 +83,16 @@ public interface IOption extends IBuildObject {
public String getStringValue() throws BuildException;
/**
- * Returns the current value for this option if it is a List of Strings.
+ * Returns the tool defining this option.
*
* @return
*/
- public String [] getStringListValue() throws BuildException;
+ public ITool getTool();
+ /**
+ * Get the type for the value of the option.
+ *
+ * @return
+ */
+ public int getValueType();
}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Option.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Option.java
index ecb36ff2cc..37abd958fd 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Option.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Option.java
@@ -11,7 +11,9 @@
package org.eclipse.cdt.internal.core.build.managed;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.eclipse.cdt.core.build.managed.BuildException;
import org.eclipse.cdt.core.build.managed.IConfiguration;
@@ -27,10 +29,12 @@ public class Option extends BuildObject implements IOption {
private ITool tool;
private IOptionCategory category;
- private List enumValues;
private int valueType;
private Object value;
+ private Map enumCommands;
+ private String defaultEnumName;
+ private String command;
private static final String[] emptyStrings = new String[0];
@@ -55,25 +59,53 @@ public class Option extends BuildObject implements IOption {
if (categoryId != null)
setCategory(tool.getOptionCategory(categoryId));
+ // command
+ command = element.getAttribute("command");
+
// valueType
String valueTypeStr = element.getAttribute("valueType");
if (valueTypeStr == null || valueTypeStr.equals("string"))
valueType = IOption.STRING;
else if (valueTypeStr.equals("stringList"))
valueType = IOption.STRING_LIST;
+ else if (valueTypeStr.equals("boolean"))
+ valueType = IOption.BOOLEAN;
+ else
+ valueType = IOption.ENUMERATED;
// value
+ enumCommands = new HashMap();
switch (valueType) {
+ case IOption.BOOLEAN:
+ // Convert the string to a boolean
+ value = new Boolean(element.getAttribute("defaultValue"));
+ break;
case IOption.STRING:
- value = element.getAttribute("value");
+ // Just get the value out of the option directly
+ value = element.getAttribute("defaultValue");
+ break;
+ case IOption.ENUMERATED:
+ List enumList = new ArrayList();
+ IConfigurationElement[] enumElements = element.getChildren("optionEnum");
+ for (int i = 0; i < enumElements.length; ++i) {
+ String optName = enumElements[i].getAttribute("name");
+ String optCommand = enumElements[i].getAttribute("command");
+ enumList.add(optName);
+ enumCommands.put(optName, optCommand);
+ Boolean isDefault = new Boolean(enumElements[i].getAttribute("isDefault"));
+ if (isDefault.booleanValue()) {
+ defaultEnumName = optName;
+ }
+ }
+ value = enumList;
break;
case IOption.STRING_LIST:
List valueList = new ArrayList();
- value = valueList;
IConfigurationElement[] valueElements = element.getChildren("optionValue");
for (int i = 0; i < valueElements.length; ++i) {
valueList.add(valueElements[i].getAttribute("value"));
}
+ value = valueList;
break;
}
}
@@ -82,11 +114,17 @@ public class Option extends BuildObject implements IOption {
* @see org.eclipse.cdt.core.build.managed.IOption#getApplicableValues()
*/
public String[] getApplicableValues() {
+ List enumValues = (List)value;
return enumValues != null
? (String[])enumValues.toArray(new String[enumValues.size()])
: emptyStrings;
}
+ public boolean getBooleanValue() {
+ Boolean bool = (Boolean) value;
+ return bool.booleanValue();
+ }
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getCategory()
*/
@@ -95,6 +133,27 @@ public class Option extends BuildObject implements IOption {
}
/* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#getCommand()
+ */
+ public String getCommand() {
+ return command;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#getDefaultEnumValue()
+ */
+ public String getDefaultEnumName() {
+ return defaultEnumName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#getEnumCommand(java.lang.String)
+ */
+ public String getEnumCommand(String name) {
+ return (String) enumCommands.get(name);
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getStringListValue()
*/
public String[] getStringListValue() {
@@ -126,6 +185,13 @@ public class Option extends BuildObject implements IOption {
}
/* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#setCategory(org.eclipse.cdt.core.build.managed.IOptionCategory)
+ */
+ public void setCategory(IOptionCategory category) {
+ this.category = category;
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#setStringValue(org.eclipse.cdt.core.build.managed.IConfiguration, java.lang.String)
*/
public IOption setValue(IConfiguration config, String value)
@@ -163,11 +229,4 @@ public class Option extends BuildObject implements IOption {
}
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#setCategory(org.eclipse.cdt.core.build.managed.IOptionCategory)
- */
- public void setCategory(IOptionCategory category) {
- this.category = category;
- }
-
}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java
index d02eb34e68..5c8b744311 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java
@@ -11,7 +11,10 @@
package org.eclipse.cdt.internal.core.build.managed;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+
import org.eclipse.cdt.core.build.managed.BuildException;
import org.eclipse.cdt.core.build.managed.IOption;
@@ -30,6 +33,9 @@ public class OptionReference implements IOption {
private IOption option;
private ToolReference owner;
private Object value;
+ private String defaultEnumName;
+ private String command;
+ private Map enumCommands;
/**
* Created internally.
@@ -57,9 +63,28 @@ public class OptionReference implements IOption {
owner.addOptionReference(this);
// value
+ enumCommands = new HashMap();
switch (option.getValueType()) {
+ case IOption.BOOLEAN:
+ value = new Boolean(element.getAttribute("defaultValue"));
+ break;
case IOption.STRING:
- value = element.getAttribute("value");
+ value = element.getAttribute("defaultValue");
+ break;
+ case IOption.ENUMERATED:
+ List enumList = new ArrayList();
+ IConfigurationElement[] enumElements = element.getChildren("optionEnum");
+ for (int i = 0; i < enumElements.length; ++i) {
+ String optName = enumElements[i].getAttribute("name");
+ String optCommand = enumElements[i].getAttribute("command");
+ enumList.add(optName);
+ enumCommands.put(optName, optCommand);
+ Boolean isDefault = new Boolean(enumElements[i].getAttribute("isDefault"));
+ if (isDefault.booleanValue()) {
+ defaultEnumName = optName;
+ }
+ }
+ value = enumList;
break;
case IOption.STRING_LIST:
List valueList = new ArrayList();
@@ -67,6 +92,7 @@ public class OptionReference implements IOption {
for (int i = 0; i < valueElements.length; ++i) {
valueList.add(valueElements[i].getAttribute("value"));
}
+ value = valueList;
break;
}
}
@@ -85,6 +111,7 @@ public class OptionReference implements IOption {
// value
switch (option.getValueType()) {
+ case IOption.BOOLEAN:
case IOption.STRING:
value = element.getAttribute("value");
break;
@@ -94,6 +121,7 @@ public class OptionReference implements IOption {
for (int i = 0; i < nodes.getLength(); ++i) {
valueList.add(((Element)nodes.item(i)).getAttribute("value"));
}
+ value = valueList;
break;
}
@@ -110,16 +138,26 @@ public class OptionReference implements IOption {
// value
switch (option.getValueType()) {
+ case IOption.BOOLEAN:
case IOption.STRING:
element.setAttribute("value", (String)value);
break;
case IOption.STRING_LIST:
- List valueList = (List)value;
- for (int i = 0; i < valueList.size(); ++i) {
+ List stringList = (List)value;
+ for (int i = 0; i < stringList.size(); ++i) {
Element valueElement = doc.createElement("optionValue");
- valueElement.setAttribute("value", (String)valueList.get(i));
+ valueElement.setAttribute("value", (String)stringList.get(i));
element.appendChild(valueElement);
}
+ break;
+ case IOption.ENUMERATED:
+ List enumList = (List)value;
+ for (int i = 0; i < enumList.size(); ++i) {
+ Element valueElement = doc.createElement("optionEnum");
+ valueElement.setAttribute("value", (String)enumList.get(i));
+ element.appendChild(valueElement);
+ }
+ break;
}
}
@@ -138,6 +176,42 @@ public class OptionReference implements IOption {
}
/* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#getCommand()
+ */
+ public String getCommand() {
+ return option.getCommand();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#getDefaultEnumValue()
+ */
+ public String getDefaultEnumName() {
+ if (value == null) {
+ return option.getDefaultEnumName();
+ } else {
+ return defaultEnumName;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#getEnumCommand(java.lang.String)
+ */
+ public String getEnumCommand(String name) {
+ if (value == null) {
+ return option.getEnumCommand(name);
+ } else {
+ return (String)enumCommands.get(name);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IBuildObject#getId()
+ */
+ public String getId() {
+ return option.getId();
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IBuildObject#getName()
*/
public String getName() {
@@ -145,6 +219,21 @@ public class OptionReference implements IOption {
}
/* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#getBooleanValue()
+ */
+ public boolean getBooleanValue() throws BuildException {
+ if (value == null){
+ return option.getBooleanValue();
+ }
+ else if (getValueType() == IOption.BOOLEAN) {
+ Boolean bool = (Boolean) value;
+ return bool.booleanValue();
+ } else {
+ throw new BuildException("bad value type");
+ }
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getStringListValue()
*/
public String[] getStringListValue() throws BuildException {
@@ -186,13 +275,6 @@ public class OptionReference implements IOption {
return option.getValueType();
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IBuildObject#getId()
- */
- public String getId() {
- return option.getId();
- }
-
public boolean references(IOption target) {
if (equals(target))
// we are the target

Back to the top