@@ -5,15 +5,18 @@ package reporting
5
5
import core .Contexts .*
6
6
import java .io .{ BufferedReader , PrintWriter }
7
7
import Diagnostic .*
8
+ import dotty .tools .dotc .interfaces .Diagnostic .INFO
8
9
9
10
/**
10
11
* This class implements a Reporter that displays messages on a text console
11
12
*/
12
13
class ConsoleReporter (
13
14
reader : BufferedReader = Console .in,
14
- writer : PrintWriter = new PrintWriter (Console .err, true )
15
+ writer : PrintWriter = new PrintWriter (Console .err, true ),
16
+ echoer : PrintWriter = new PrintWriter (Console .out, true )
15
17
) extends ConsoleReporter .AbstractConsoleReporter {
16
- override def printMessage (msg : String ): Unit = { writer.print(msg + " \n " ); writer.flush() }
18
+ override def printMessage (msg : String ): Unit = { writer.println(msg); writer.flush() }
19
+ override def echoMessage (msg : String ): Unit = { echoer.println(msg); echoer.flush() }
17
20
override def flush ()(using Context ): Unit = writer.flush()
18
21
19
22
override def doReport (dia : Diagnostic )(using Context ): Unit = {
@@ -22,18 +25,21 @@ class ConsoleReporter(
22
25
dia match
23
26
case _ : Error => Reporter .displayPrompt(reader, writer)
24
27
case _ : Warning if ctx.settings.XfatalWarnings .value => Reporter .displayPrompt(reader, writer)
25
- case _ =>
28
+ case _ =>
26
29
}
27
30
}
28
31
29
32
object ConsoleReporter {
30
33
abstract class AbstractConsoleReporter extends AbstractReporter {
31
- /** Prints the message. */
34
+ /** Print the diagnostic message. */
32
35
def printMessage (msg : String ): Unit
33
36
34
- /** Prints the message with the given position indication. */
35
- def doReport (dia : Diagnostic )(using Context ): Unit = {
36
- printMessage(messageAndPos(dia))
37
- }
37
+ /** Print the informative message. */
38
+ def echoMessage (msg : String ): Unit
39
+
40
+ /** Print the message with the given position indication. */
41
+ def doReport (dia : Diagnostic )(using Context ): Unit =
42
+ if dia.level == INFO then echoMessage(messageAndPos(dia))
43
+ else printMessage(messageAndPos(dia))
38
44
}
39
45
}
0 commit comments