summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorGilles Dubochet <gilles.dubochet@epfl.ch>2005-10-10 15:50:07 +0000
committerGilles Dubochet <gilles.dubochet@epfl.ch>2005-10-10 15:50:07 +0000
commit1da91ff38fc3e4a9fc6fc9552d9a844b6cb0f381 (patch)
treeb72f9973a1b2e5e20fa7758cb534c27e45effa0d /sources
parent60b24c0671d01cd3dad2da5914d92105912d969c (diff)
downloadscala-1da91ff38fc3e4a9fc6fc9552d9a844b6cb0f381.tar.gz
scala-1da91ff38fc3e4a9fc6fc9552d9a844b6cb0f381.tar.bz2
scala-1da91ff38fc3e4a9fc6fc9552d9a844b6cb0f381.zip
Updated the attributes setter with limited inpu...
Updated the attributes setter with limited inputs as they did not work before (because Ant want input-limiters to be subclasses of some class and Scala when told to subclass something actually doesn't do that).
Diffstat (limited to 'sources')
-rw-r--r--sources/scala/tools/nsc/ant/NSC.scala40
1 files changed, 23 insertions, 17 deletions
diff --git a/sources/scala/tools/nsc/ant/NSC.scala b/sources/scala/tools/nsc/ant/NSC.scala
index a8545adc8a..8dbac4fa5c 100644
--- a/sources/scala/tools/nsc/ant/NSC.scala
+++ b/sources/scala/tools/nsc/ant/NSC.scala
@@ -77,14 +77,19 @@ package scala.tools.nsc.ant {
// ##### Ant Properties #####
// ###################################################################
+ abstract class PermissibleValue {
+ val values: List[String];
+ def isPermissible (value: String): Boolean = (value == "") || values.exists(v:String=>(v.compareToIgnoreCase(value) == 0));
+ }
+
/** Defines valid values for the logging property. */
- class LoggingLevel extends EnumeratedAttribute {
- def getValues () = Predef.Array("", "none", "verbose", "debug");
+ object LoggingLevel extends PermissibleValue {
+ val values = List("none", "verbose", "debug");
}
/** Defines valid values for properties that refer to compiler phases. */
- class CompilerPhase extends EnumeratedAttribute {
- def getValues () = Predef.Array("", "namer", "typer", "pickler", "uncurry", "tailcalls", "transmatch", "explicitouter", "erasure", "lambdalift", "flatten", "constructors", "mixin", "icode", "jvm");
+ object CompilerPhase extends PermissibleValue {
+ val values = List("namer", "typer", "pickler", "uncurry", "tailcalls", "transmatch", "explicitouter", "erasure", "lambdalift", "flatten", "constructors", "mixin", "icode", "jvm");
}
/** The directories that contain source files to compile. */
@@ -358,8 +363,10 @@ package scala.tools.nsc.ant {
* Sets the logging level attribute. Used by Ant.
* @param input The value for <code>logging</code>.
*/
- def setLogging (input: LoggingLevel) = {
- logging = Some(input.getValue());
+ def setLogging (input: String) = {
+ if (LoggingLevel.isPermissible(input))
+ logging = Some(input);
+ else error("Logging level '" + input + "' does not exist.");
}
/**
@@ -390,9 +397,10 @@ package scala.tools.nsc.ant {
* Sets the force attribute. Used by Ant.
* @param input The value for <code>force</code>.
*/
- def setStop (input: CompilerPhase) = {
- if (input != "")
- stop = Some(input.getValue());
+ def setStop (input: String) = {
+ if (CompilerPhase.isPermissible(input))
+ stop = Some(input);
+ else error("Phase '" + input + "' in stop does not exist.");
}
/**
@@ -400,11 +408,10 @@ package scala.tools.nsc.ant {
* @param input The value for <code>force</code>.
*/
def setSkip (input: String) = {
- val cp = new CompilerPhase();
- skip = List.fromArray(input.split(",")).flatMap(s:String=>{
+ skip = List.fromArray(input.split(",")).map(s:String=>{
val st = s.trim();
- if (cp.containsValue(st)) (if (st != "") List(st) else Nil)
- else {error("Phase " + st + " in skip does not exist."); Nil}
+ if (CompilerPhase.isPermissible(st)) st
+ else {error("Phase '" + st + "' in skip does not exist."); ""}
});
}
@@ -413,11 +420,10 @@ package scala.tools.nsc.ant {
* @param input The value for <code>force</code>.
*/
def setCheck (input: String) = {
- val cp = new CompilerPhase();
- check = List.fromArray(input.split(",")).flatMap(s:String=>{
+ check = List.fromArray(input.split(",")).map(s:String=>{
val st = s.trim();
- if (cp.containsValue(st)) (if (st != "") List(st) else Nil)
- else {error("Phase " + st + " in check does not exist."); Nil}
+ if (CompilerPhase.isPermissible(st)) st
+ else {error("Phase " + st + " in check does not exist."); ""}
});
}