@@ -2,11 +2,10 @@ package dotty.tools
2
2
package dotc
3
3
package reporting
4
4
5
- import util .SourcePosition
6
5
import core .Contexts ._
7
6
import java .io .{ BufferedReader , PrintWriter }
8
7
import diagnostic .{ Message , MessageContainer }
9
- import diagnostic .messages ._
8
+ import diagnostic .messages .{ Error , Warning , ConditionalWarning }
10
9
11
10
/**
12
11
* This class implements a Reporter that displays messages on a text console
@@ -25,48 +24,40 @@ class ConsoleReporter(
25
24
def printMessage (msg : String ): Unit = { writer.print(msg + " \n " ); writer.flush() }
26
25
27
26
/** Prints the message with the given position indication. */
28
- def printMessageAndPos (msg : Message , pos : SourcePosition , diagnosticLevel : String )(implicit ctx : Context ): Boolean = {
29
- printMessage(messageAndPos(msg, pos, diagnosticLevel))
30
- true
31
- }
32
-
33
- def printExplanation (m : Message )(implicit ctx : Context ): Unit = {
34
- printMessage(explanation(m))
35
- }
36
-
37
- override def doReport (m : MessageContainer )(implicit ctx : Context ): Unit = {
27
+ def doReport (m : MessageContainer )(implicit ctx : Context ): Unit = {
38
28
val didPrint = m match {
39
29
case m : Error =>
40
- val didPrint = printMessageAndPos( m.contained, m.pos, diagnosticLevel(m))
30
+ printMessage(messageAndPos( m.contained, m.pos, diagnosticLevel(m) ))
41
31
if (ctx.settings.prompt.value) displayPrompt()
42
- didPrint
32
+ true
43
33
case m : ConditionalWarning if ! m.enablingOption.value =>
44
34
false
45
35
case m =>
46
- printMessageAndPos(m.contained, m.pos, diagnosticLevel(m))
36
+ printMessage(messageAndPos(m.contained, m.pos, diagnosticLevel(m)))
37
+ true
47
38
}
48
39
49
40
if (didPrint && ctx.shouldExplain(m))
50
- printExplanation( m.contained)
41
+ printMessage(explanation( m.contained) )
51
42
else if (didPrint && m.contained.explanation.nonEmpty)
52
43
printMessage(" \n longer explanation available when compiling with `-explain`" )
53
44
}
54
45
55
- def displayPrompt (): Unit = {
56
- writer.print(" \n a)bort, s)tack, r)esume: " )
57
- writer.flush()
46
+ /** Show prompt if `-Xprompt` is passed as a flag to the compiler */
47
+ def displayPrompt ()(implicit ctx : Context ): Unit = {
48
+ printMessage(" \n a)bort, s)tack, r)esume: " )
49
+ flush()
58
50
if (reader != null ) {
59
51
val response = reader.read().asInstanceOf [Char ].toLower
60
52
if (response == 'a' || response == 's' ) {
61
53
Thread .dumpStack()
62
54
if (response == 'a' )
63
55
sys.exit(1 )
64
56
}
65
- writer. print(" \n " )
66
- writer. flush()
57
+ print(" \n " )
58
+ flush()
67
59
}
68
60
}
69
61
70
62
override def flush ()(implicit ctx : Context ): Unit = { writer.flush() }
71
63
}
72
-
0 commit comments