From d6a52eec2221101973c6b28f54aa20319f0e8b6f Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Wed, 3 Feb 2016 21:12:37 +0100 Subject: Reporter: make summary available without a Context --- src/dotty/tools/dotc/reporting/Reporter.scala | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src/dotty/tools/dotc/reporting/Reporter.scala') diff --git a/src/dotty/tools/dotc/reporting/Reporter.scala b/src/dotty/tools/dotc/reporting/Reporter.scala index f98d85ce9..5ed7360da 100644 --- a/src/dotty/tools/dotc/reporting/Reporter.scala +++ b/src/dotty/tools/dotc/reporting/Reporter.scala @@ -247,12 +247,23 @@ abstract class Reporter { incompleteHandler(d)(ctx) - /** Print a summary */ - def printSummary(implicit ctx: Context): Unit = { - if (warningCount > 0) ctx.println(countString(warningCount, "warning") + " found") - if (errorCount > 0) ctx.println(countString(errorCount, "error") + " found") + /** Summary of warnings and errors */ + def summary: String = { + val b = new mutable.ListBuffer[String] + if (warningCount > 0) + b += countString(warningCount, "warning") + " found" + if (errorCount > 0) + b += countString(errorCount, "error") + " found" for ((settingName, count) <- unreportedWarnings) - ctx.println(s"there were $count ${settingName.tail} warning(s); re-run with $settingName for details") + b += s"there were $count ${settingName.tail} warning(s); re-run with $settingName for details" + b.mkString("\n") + } + + /** Print the summary of warnings and errors */ + def printSummary(implicit ctx: Context): Unit = { + val s = summary + if (s != "") + ctx.println(s) } /** Returns a string meaning "n elements". */ -- cgit v1.2.3