summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@gmail.com>2017-02-03 16:43:25 +0100
committerGitHub <noreply@github.com>2017-02-03 16:43:25 +0100
commite7ed71b8d5939bf7c93f77775f62c987111d996a (patch)
tree577f257e9c2c6412175ffb152f5466115f9ab1b6 /src/compiler
parentfff17320448c9691851aa16897e2fa2d75e0f11a (diff)
parent633e6effa306a3a5f10ca4de7b22f0db460a4499 (diff)
downloadscala-e7ed71b8d5939bf7c93f77775f62c987111d996a.tar.gz
scala-e7ed71b8d5939bf7c93f77775f62c987111d996a.tar.bz2
scala-e7ed71b8d5939bf7c93f77775f62c987111d996a.zip
Merge pull request #5667 from som-snytt/issue/maxerrs
SI-9729 -Xmaxerrs to limit messages
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala11
-rw-r--r--src/compiler/scala/tools/nsc/settings/MutableSettings.scala10
-rw-r--r--src/compiler/scala/tools/nsc/settings/ScalaSettings.scala2
3 files changed, 15 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala
index 9b9d94bb0f..342031b601 100644
--- a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala
+++ b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala
@@ -20,6 +20,7 @@ class ConsoleReporter(val settings: Settings, reader: BufferedReader, writer: Pr
var shortname: Boolean = false
/** maximal number of error messages to be printed */
+ @deprecated("configured by settings.maxerrs", since="2.12.2")
final val ERROR_LIMIT = 100
private def label(severity: Severity): String = severity match {
@@ -63,9 +64,13 @@ class ConsoleReporter(val settings: Settings, reader: BufferedReader, writer: Pr
if ( ERROR.count > 0) printMessage(getCountString(ERROR ) + " found")
}
- def display(pos: Position, msg: String, severity: Severity) {
- if (severity != ERROR || severity.count <= ERROR_LIMIT)
- print(pos, msg, severity)
+ def display(pos: Position, msg: String, severity: Severity): Unit = {
+ val ok = severity match {
+ case ERROR => ERROR.count <= settings.maxerrs.value
+ case WARNING => WARNING.count <= settings.maxwarns.value
+ case _ => true
+ }
+ if (ok) print(pos, msg, severity)
}
def displayPrompt(): Unit = {
diff --git a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala
index 822e0f16bf..92a5cbdd73 100644
--- a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala
+++ b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala
@@ -416,9 +416,9 @@ class MutableSettings(val errorFn: String => Unit)
// Helper to generate a textual explanation of valid inputs
private def getValidText: String = (min, max) match {
case (IntMin, IntMax) => "can be any integer"
- case (IntMin, x) => "must be less than or equal to "+x
- case (x, IntMax) => "must be greater than or equal to "+x
- case _ => "must be between %d and %d".format(min, max)
+ case (IntMin, x) => f"must be less than or equal to $x%d"
+ case (x, IntMax) => f"must be greater than or equal to $x%d"
+ case _ => f"must be between $min%d and $max%d"
}
// Ensure that the default value is actually valid
@@ -431,7 +431,7 @@ class MutableSettings(val errorFn: String => Unit)
}
}
- def errorMsg() = errorFn("invalid setting for -"+name+" "+getValidText)
+ def errorMsg() = errorFn(s"invalid setting for $name $getValidText")
def tryToSet(args: List[String]) =
if (args.isEmpty) errorAndValue("missing argument", None)
@@ -444,7 +444,7 @@ class MutableSettings(val errorFn: String => Unit)
if (value == default) Nil
else List(name, value.toString)
- withHelpSyntax(name + " <n>")
+ withHelpSyntax(s"$name <n>")
}
/** A setting represented by a boolean flag (false, unless set) */
diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
index 7be65431db..cce9a5b3a8 100644
--- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
+++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
@@ -107,6 +107,8 @@ trait ScalaSettings extends AbsScalaSettings
val logFreeTerms = BooleanSetting ("-Xlog-free-terms", "Print a message when reification creates a free term.")
val logFreeTypes = BooleanSetting ("-Xlog-free-types", "Print a message when reification resorts to generating a free type.")
val maxClassfileName = IntSetting ("-Xmax-classfile-name", "Maximum filename length for generated classes", 255, Some((72, 255)), _ => None)
+ val maxerrs = IntSetting ("-Xmaxerrs", "Maximum errors to print", 100, None, _ => None)
+ val maxwarns = IntSetting ("-Xmaxwarns", "Maximum warnings to print", 100, None, _ => None)
val Xmigration = ScalaVersionSetting ("-Xmigration", "version", "Warn about constructs whose behavior may have changed since version.", initial = NoScalaVersion, default = Some(AnyScalaVersion))
val nouescape = BooleanSetting ("-Xno-uescape", "Disable handling of \\u unicode escapes.")
val Xnojline = BooleanSetting ("-Xnojline", "Do not use JLine for editing.")