diff options
author | Som Snytt <som.snytt@gmail.com> | 2014-07-18 00:19:01 -0700 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2014-07-18 00:19:01 -0700 |
commit | 68560dd80d99f031bdf419f08463abeb83e47b3c (patch) | |
tree | 73f874bb7fc7d85f098c9d08e9085decad154b76 /src/compiler/scala/tools/nsc/settings/Warnings.scala | |
parent | bde623925d011841f222891050c5fdb08f3bb251 (diff) | |
download | scala-68560dd80d99f031bdf419f08463abeb83e47b3c.tar.gz scala-68560dd80d99f031bdf419f08463abeb83e47b3c.tar.bz2 scala-68560dd80d99f031bdf419f08463abeb83e47b3c.zip |
SI-8525 MultiChoice takes a helper function
Clean-up code review comments.
MultiChoice takes a helper function for outputting help text.
Diffstat (limited to 'src/compiler/scala/tools/nsc/settings/Warnings.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/settings/Warnings.scala | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/compiler/scala/tools/nsc/settings/Warnings.scala b/src/compiler/scala/tools/nsc/settings/Warnings.scala index 3accd9fdaa..9989d1d188 100644 --- a/src/compiler/scala/tools/nsc/settings/Warnings.scala +++ b/src/compiler/scala/tools/nsc/settings/Warnings.scala @@ -109,18 +109,18 @@ trait Warnings { private val xlint = new BooleanSetting("-Zunused", "True if -Xlint or -Xlint:_") // On -Xlint or -Xlint:_, set xlint, otherwise set the lint warning unless already set true val lint = { - val d = "Enable or disable specific warnings" - val s = new MultiChoiceSetting( + val description = "Enable or disable specific warnings" + val choices = (lintWarnings map (_.name)).sorted + MultiChoiceSetting( name = "-Xlint", - arg = "warning", - descr = d, - choices = (lintWarnings map (_.name)).sorted, + helpArg = "warning", + descr = description, + choices = choices, default = () => xlint.value = true - ) { + ) { s => def helpline(n: String) = lintWarnings.find(_.name == n).map(w => f" ${w.name}%-25s ${w.helpDescription}%n") - override def help = s"$d${ choices flatMap (helpline(_)) mkString (":\n", "", "\n") }" - } - val t = s withPostSetHook { x => + choices flatMap (helpline(_)) mkString (f"$description:%n", "", f"%n") + } withPostSetHook { x => val Neg = "-" def setPolitely(b: BooleanSetting, v: Boolean) = if (!b.isSetByUser || !b) b.value = v def set(w: String, v: Boolean) = lintWarnings find (_.name == w) foreach (setPolitely(_, v)) @@ -130,8 +130,6 @@ trait Warnings { } propagate(x.value) } - add(t) - t } // Lint warnings that are currently -Y, but deprecated in that usage |