Skip to content

Commit

Permalink
Merge pull request scala#5714 from dragos/issue/usage-sterr-SI-10178
Browse files Browse the repository at this point in the history
SI-10178 Route reporter.echo to stdout
  • Loading branch information
lrytz committed Feb 20, 2017
2 parents 2fec08b + 640c85e commit 144f7e0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala
Expand Up @@ -14,8 +14,10 @@ import StringOps.{countElementsAsString => countAs, trimAllTrailingSpace => trim

/** This class implements a Reporter that displays messages on a text console.
*/
class ConsoleReporter(val settings: Settings, reader: BufferedReader, writer: PrintWriter) extends AbstractReporter {
def this(settings: Settings) = this(settings, Console.in, new PrintWriter(Console.err, true))
class ConsoleReporter(val settings: Settings, reader: BufferedReader, writer: PrintWriter, echoWriter: PrintWriter) extends AbstractReporter {
def this(settings: Settings) = this(settings, Console.in, new PrintWriter(Console.err, true), new PrintWriter(Console.out, true))
def this(settings: Settings, reader: BufferedReader, writer: PrintWriter) =
this(settings, reader, writer, writer)

/** Whether a short file name should be displayed before errors */
var shortname: Boolean = false
Expand All @@ -41,6 +43,12 @@ class ConsoleReporter(val settings: Settings, reader: BufferedReader, writer: Pr
writer.flush()
}

/** Prints the message to the echoWriter, which is usually stdout. */
override def echo(msg: String): Unit = {
echoWriter.println(trimTrailing(msg))
echoWriter.flush()
}

/** Prints the message with the given position indication. */
def printMessage(posIn: Position, msg: String): Unit = printMessage(formatMessage(posIn, msg, shortname))

Expand Down

0 comments on commit 144f7e0

Please sign in to comment.