Skip to content

Commit 640c85e

Browse files
committed
SI-10178 Route reporter.echo to stdout
`echo` is currently used only for usage information, and that makes a lot more sense to go to stdout instead of stderr. This allows grepping through the extensive list of compiler options.
1 parent c8b8005 commit 640c85e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ import StringOps.{countElementsAsString => countAs, trimAllTrailingSpace => trim
1414

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

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

46+
/** Prints the message to the echoWriter, which is usually stdout. */
47+
override def echo(msg: String): Unit = {
48+
echoWriter.println(trimTrailing(msg))
49+
echoWriter.flush()
50+
}
51+
4452
/** Prints the message with the given position indication. */
4553
def printMessage(posIn: Position, msg: String): Unit = printMessage(formatMessage(posIn, msg, shortname))
4654

0 commit comments

Comments
 (0)