Skip to content

Commit d6a52ee

Browse files
committed
Reporter: make summary available without a Context
1 parent cf1413b commit d6a52ee

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/dotty/tools/dotc/reporting/Reporter.scala

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,23 @@ abstract class Reporter {
247247
incompleteHandler(d)(ctx)
248248

249249

250-
/** Print a summary */
251-
def printSummary(implicit ctx: Context): Unit = {
252-
if (warningCount > 0) ctx.println(countString(warningCount, "warning") + " found")
253-
if (errorCount > 0) ctx.println(countString(errorCount, "error") + " found")
250+
/** Summary of warnings and errors */
251+
def summary: String = {
252+
val b = new mutable.ListBuffer[String]
253+
if (warningCount > 0)
254+
b += countString(warningCount, "warning") + " found"
255+
if (errorCount > 0)
256+
b += countString(errorCount, "error") + " found"
254257
for ((settingName, count) <- unreportedWarnings)
255-
ctx.println(s"there were $count ${settingName.tail} warning(s); re-run with $settingName for details")
258+
b += s"there were $count ${settingName.tail} warning(s); re-run with $settingName for details"
259+
b.mkString("\n")
260+
}
261+
262+
/** Print the summary of warnings and errors */
263+
def printSummary(implicit ctx: Context): Unit = {
264+
val s = summary
265+
if (s != "")
266+
ctx.println(s)
256267
}
257268

258269
/** Returns a string meaning "n elements". */

0 commit comments

Comments
 (0)