diff options
author | Paul Phillips <paulp@improving.org> | 2010-02-17 19:01:22 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-02-17 19:01:22 +0000 |
commit | 09816ef0d354e8567c830433f24b2da4a03010a0 (patch) | |
tree | 93232db3e55b9d7deab53b7ed1f842867f2747c2 | |
parent | 84da1b203334c606448886b1f42749931fab7607 (diff) | |
download | scala-09816ef0d354e8567c830433f24b2da4a03010a0.tar.gz scala-09816ef0d354e8567c830433f24b2da4a03010a0.tar.bz2 scala-09816ef0d354e8567c830433f24b2da4a03010a0.zip |
Added a copy() method to Settings. No review.
-rw-r--r-- | src/compiler/scala/tools/nsc/Settings.scala | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/Settings.scala b/src/compiler/scala/tools/nsc/Settings.scala index 3d8e5d7258..9585db7c64 100644 --- a/src/compiler/scala/tools/nsc/Settings.scala +++ b/src/compiler/scala/tools/nsc/Settings.scala @@ -88,6 +88,15 @@ class Settings(errorFn: String => Unit) extends ScalacSettings { case _ => false } + /** Create a new Settings object, copying all user-set values. + */ + def copy(): Settings = { + val s = new Settings() + val xs = userSetSettings flatMap (_.unparse) + s.processArguments(xs.toList, true) + s + } + def checkDependencies: Boolean = { def hasValue(s: Setting, value: String): Boolean = s match { case bs: BooleanSetting => bs.value @@ -253,7 +262,7 @@ class Settings(errorFn: String => Unit) extends ScalacSettings { lazy val OutputSetting = untupled((output _).tupled andThen add[OutputSetting]) override def toString() = - "Settings(\n%s)" format (settingSet filter (s => !s.isDefault) map (" " + _ + "\n") mkString) + "Settings(\n%s)" format (userSetSettings map (" " + _ + "\n") mkString) } object Settings { @@ -777,10 +786,15 @@ trait ScalacSettings { import PathResolver.{ Defaults, Environment } - /** A list of all settings */ + /** Sorted set of settings */ protected var allsettings: Set[Setting] = TreeSet[Setting]() + + /** All settings */ def settingSet: Set[Setting] = allsettings + /** Set settings */ + def userSetSettings: Set[Setting] = settingSet filterNot (_.isDefault) + /** Disable a setting */ def disable(s: Setting) = allsettings -= s |