blob: 88372334d6dba4b8c0b5c0a4830a8642bfe57855 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
/* NSC -- new Scala compiler
* Copyright 2002-2013 LAMP/EPFL
* @author Paul Phillips
*/
package scala.tools.nsc
package interpreter
import reporters._
import IMain._
import scala.reflect.internal.util.Position
/** Like ReplGlobal, a layer for ensuring extra functionality.
*/
class ReplReporter(intp: IMain) extends ConsoleReporter(intp.settings, Console.in, new ReplStrippingWriter(intp)) {
def printUntruncatedMessage(msg: String) = withoutTruncating(printMessage(msg))
/** Whether very long lines can be truncated. This exists so important
* debugging information (like printing the classpath) is not rendered
* invisible due to the max message length.
*/
private var _truncationOK: Boolean = !intp.settings.verbose
def truncationOK = _truncationOK
def withoutTruncating[T](body: => T): T = {
val saved = _truncationOK
_truncationOK = false
try body
finally _truncationOK = saved
}
override def warning(pos: Position, msg: String): Unit = withoutTruncating(super.warning(pos, msg))
override def error(pos: Position, msg: String): Unit = withoutTruncating(super.error(pos, msg))
override def printMessage(msg: String) {
// Avoiding deadlock if the compiler starts logging before
// the lazy val is complete.
if (intp.isInitializeComplete) {
if (intp.totalSilence) {
if (isReplTrace)
super.printMessage("[silent] " + msg)
}
else super.printMessage(msg)
}
else Console.println("[init] " + msg)
}
override def displayPrompt() {
if (intp.totalSilence) ()
else super.displayPrompt()
}
}
|