@@ -2,7 +2,7 @@ package dotty.tools
2
2
package dotc
3
3
package reporting
4
4
5
- import java .io .{ PrintStream , PrintWriter , File => JFile , FileOutputStream }
5
+ import java .io .{ PrintStream , PrintWriter , File => JFile , FileOutputStream , StringWriter }
6
6
import java .text .SimpleDateFormat
7
7
import java .util .Date
8
8
import core .Decorators ._
@@ -20,14 +20,16 @@ class TestReporter protected (outWriter: PrintWriter, filePrintln: String => Uni
20
20
extends Reporter with UniqueMessagePositions with HideNonSensicalMessages with MessageRendering {
21
21
import MessageContainer ._
22
22
23
- protected final val _errorBuf = mutable.ArrayBuffer .empty[(MessageContainer , String )]
24
- final def errors : Iterator [(MessageContainer , String )] = _errorBuf.iterator
25
- def logError (err : Error )(implicit ctx : Context ) =
26
- _errorBuf.append(err -> messageAndPos(err.contained(), err.pos, diagnosticLevel(err)))
23
+ protected final val _errorBuf = mutable.ArrayBuffer .empty[MessageContainer ]
24
+ final def errors : Iterator [MessageContainer ] = _errorBuf.iterator
27
25
28
26
protected final val _messageBuf = mutable.ArrayBuffer .empty[String ]
29
27
final def messages : Iterator [String ] = _messageBuf.iterator
30
28
29
+ protected final val _consoleBuf = new StringWriter
30
+ protected final val _consoleReporter = new ConsoleReporter (null , new PrintWriter (_consoleBuf))
31
+ final def consoleOutput : String = _consoleBuf.toString
32
+
31
33
private [this ] var _didCrash = false
32
34
final def compilerCrashed : Boolean = _didCrash
33
35
@@ -65,6 +67,8 @@ extends Reporter with UniqueMessagePositions with HideNonSensicalMessages with M
65
67
}
66
68
67
69
override def doReport (m : MessageContainer )(implicit ctx : Context ): Unit = {
70
+ _consoleReporter.doReport(m)
71
+
68
72
// Here we add extra information that we should know about the error message
69
73
val extra = m.contained() match {
70
74
case pm : PatternMatchExhaustivity => s " : ${pm.uncovered}"
@@ -73,7 +77,7 @@ extends Reporter with UniqueMessagePositions with HideNonSensicalMessages with M
73
77
74
78
m match {
75
79
case m : Error => {
76
- logError (m)
80
+ _errorBuf.append (m)
77
81
printMessageAndPos(m, extra)
78
82
}
79
83
case m =>
0 commit comments