diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2006-07-28 12:18:22 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2006-07-28 12:18:22 +0000 |
commit | 82fddf62e89be7c877538cd98b06669f3a2cb6cf (patch) | |
tree | 719bb28ed55e4c29d3a11db996d2459a4f698c05 | |
parent | 261ff3d0abea28091ce951613f440ccaabdfb7b5 (diff) | |
download | scala-82fddf62e89be7c877538cd98b06669f3a2cb6cf.tar.gz scala-82fddf62e89be7c877538cd98b06669f3a2cb6cf.tar.bz2 scala-82fddf62e89be7c877538cd98b06669f3a2cb6cf.zip |
Made DebugSetting behave correctly when 'value'...
Made DebugSetting behave correctly when 'value' is set from outside.
-rw-r--r-- | src/compiler/scala/tools/nsc/Settings.scala | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/compiler/scala/tools/nsc/Settings.scala b/src/compiler/scala/tools/nsc/Settings.scala index 28b0b2bb1a..1239216e91 100644 --- a/src/compiler/scala/tools/nsc/Settings.scala +++ b/src/compiler/scala/tools/nsc/Settings.scala @@ -209,7 +209,10 @@ class Settings(error: String => unit) { */ case class ChoiceSetting(nme: String, descr: String, choices: List[String], default: String) extends Setting(nme, descr + choices.mkString(" (", ",", ")")) { - var value: String = default + protected var v: String = default; + + def value: String = this.v; + def value_=(s: String): Unit = this.v = s; protected def argument: String = name.substring(1) @@ -236,10 +239,11 @@ class Settings(error: String => unit) { else List(name + ":" + value) } + /** Same as ChoiceSetting but have a 'level' int which tells the index of the selected - * choice. The 'defaultEmpty' is used when this setting is used without specifying any of - * the available choices. - */ + * choice. The 'defaultEmpty' is used when this setting is used without specifying any of + * the available choices. + */ class DebugSetting(nme: String, descr: String, choices: List[String], default: String, defaultEmpty: String) extends ChoiceSetting(nme, descr, choices, default) { @@ -250,7 +254,12 @@ class Settings(error: String => unit) { } case _ => None; } - var level: Int = indexOf(choices, default).get; + var level: Int = indexOf(choices, default).get; + + override def value_=(choice: String): Unit = { + this.v = choice; + this.level = indexOf(choices, choice).get; + } override def tryToSet(args: List[String]): List[String] = args match { case n :: rest if (n startsWith (name + ":")) => @@ -262,13 +271,11 @@ class Settings(error: String => unit) { args } else { value = choice - level = indexOf(choices, choice).get; rest } case n :: rest if (n startsWith name) => value = defaultEmpty; - level = indexOf(choices, defaultEmpty).get; rest case _ => args |