diff options
author | Martin Odersky <odersky@gmail.com> | 2014-01-16 22:00:16 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-01-16 22:00:40 +0100 |
commit | bf59937182b66d12d01c11ff5dd27346ee4a9db4 (patch) | |
tree | da1aa5ce95b86aa9b17cd3911ef97698c5fa5f40 /src/dotty/tools/dotc/reporting/Reporter.scala | |
parent | d00c3f5e7925cd246fb10916f6a2d26111ac2689 (diff) | |
download | dotty-bf59937182b66d12d01c11ff5dd27346ee4a9db4.tar.gz dotty-bf59937182b66d12d01c11ff5dd27346ee4a9db4.tar.bz2 dotty-bf59937182b66d12d01c11ff5dd27346ee4a9db4.zip |
Refactoring to avoid multiple overloaded traceIndent methods.
Diffstat (limited to 'src/dotty/tools/dotc/reporting/Reporter.scala')
-rw-r--r-- | src/dotty/tools/dotc/reporting/Reporter.scala | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/dotty/tools/dotc/reporting/Reporter.scala b/src/dotty/tools/dotc/reporting/Reporter.scala index 913290a00..e2b320588 100644 --- a/src/dotty/tools/dotc/reporting/Reporter.scala +++ b/src/dotty/tools/dotc/reporting/Reporter.scala @@ -8,6 +8,7 @@ import util.{SourceFile, NoSource} import core.Decorators.PhaseListDecorator import collection.mutable import config.Settings.Setting +import config.Printers import java.lang.System.currentTimeMillis object Reporter { @@ -128,23 +129,20 @@ trait Reporting { this: Context => def debugwarn(msg: => String, pos: SourcePosition = NoSourcePosition): Unit = if (this.settings.debug.value) warning(msg, pos) - def debugTraceIndented[T](question: => String, show: Boolean = false)(op: => T): T = - conditionalTraceIndented(this.settings.debugTrace.value, question, show)(op) + def debugTraceIndented[T](question: => String, printer: Printers.Printer = Printers.default, show: Boolean = false)(op: => T): T = + conditionalTraceIndented(this.settings.debugTrace.value, question, printer, show)(op) - def conditionalTraceIndented[T](cond: Boolean, question: => String, show: Boolean = false)(op: => T): T = - if (cond) traceIndented(question, show)(op) + def conditionalTraceIndented[T](cond: Boolean, question: => String, printer: Printers.Printer = Printers.default, show: Boolean = false)(op: => T): T = + if (cond) traceIndented(question, printer, show)(op) else op - def traceIndented[T](printer: config.Printers.Printer, question: => String, show: Boolean = false)(op: => T): T = - if (printer ne config.Printers.noPrinter) traceIndented(question, show)(op) - else op - - def traceIndented[T](question: => String, show: Boolean = false)(op: => T): T = { + def traceIndented[T](question: => String, printer: Printers.Printer = Printers.default, show: Boolean = false)(op: => T): T = { def resStr(res: Any): String = res match { case res: printing.Showable if show => res.show case _ => String.valueOf(res) } - traceIndented[T](s"==> $question?", (res: Any) => s"<== $question = ${resStr(res)}")(op) + if (printer eq config.Printers.noPrinter) op + else traceIndented[T](s"==> $question?", (res: Any) => s"<== $question = ${resStr(res)}")(op) } def traceIndented[T](leading: => String, trailing: Any => String)(op: => T): T = { @@ -258,7 +256,7 @@ abstract class Reporter { countElementsAsString(count(severity.level), label(severity).dropRight(2)) } - def printSummary(implicit ctx: Context) { + def printSummary(implicit ctx: Context): Unit = { if (count(WARNING.level) > 0) ctx.echo(countString(WARNING) + " found") if ( count(ERROR.level) > 0) ctx.echo(countString(ERROR ) + " found") for (cwarning <- conditionalWarnings) { |