summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/settings/Warnings.scala
diff options
context:
space:
mode:
authorSom Snytt <som.snytt@gmail.com>2014-07-17 10:04:20 -0700
committerSom Snytt <som.snytt@gmail.com>2014-07-17 10:04:20 -0700
commitbde623925d011841f222891050c5fdb08f3bb251 (patch)
treed69aa258a538d59d6fddbbd6e87a9b00db8d3121 /src/compiler/scala/tools/nsc/settings/Warnings.scala
parentf81ec8d1f6481ddacfb27e743c6c58961e765f0e (diff)
downloadscala-bde623925d011841f222891050c5fdb08f3bb251.tar.gz
scala-bde623925d011841f222891050c5fdb08f3bb251.tar.bz2
scala-bde623925d011841f222891050c5fdb08f3bb251.zip
SI-8525 Multichoice help
Enables -Xlint:help and -language:help. The Settings API makes it difficult to innovate.
Diffstat (limited to 'src/compiler/scala/tools/nsc/settings/Warnings.scala')
-rw-r--r--src/compiler/scala/tools/nsc/settings/Warnings.scala18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/settings/Warnings.scala b/src/compiler/scala/tools/nsc/settings/Warnings.scala
index 0b9ad80041..3accd9fdaa 100644
--- a/src/compiler/scala/tools/nsc/settings/Warnings.scala
+++ b/src/compiler/scala/tools/nsc/settings/Warnings.scala
@@ -108,14 +108,19 @@ trait Warnings {
// The Xlint warning group.
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 =
- MultiChoiceSetting(
+ val lint = {
+ val d = "Enable or disable specific warnings"
+ val s = new MultiChoiceSetting(
name = "-Xlint",
- helpArg = "warning",
- descr = "Enable recommended additional warnings",
+ arg = "warning",
+ descr = d,
choices = (lintWarnings map (_.name)).sorted,
default = () => xlint.value = true
- ) withPostSetHook { x =>
+ ) {
+ 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 =>
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))
@@ -125,6 +130,9 @@ trait Warnings {
}
propagate(x.value)
}
+ add(t)
+ t
+ }
// Lint warnings that are currently -Y, but deprecated in that usage
@deprecated("Use warnAdaptedArgs", since="2.11.2")