blob: 20d4a1d0262bd52099065b86ea6f6a172a2725b0 (
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
package scala.reflect
package internal
trait Reporters { self: SymbolTable =>
import self.{Reporter => ApiReporter}
import scala.tools.nsc.reporters._
import scala.tools.nsc.reporters.{Reporter => NscReporter}
import scala.tools.nsc.Settings
def mkConsoleReporter(minSeverity: Int = 1): ApiReporter = {
val settings = new Settings()
if (minSeverity <= 0) settings.verbose.value = true
if (minSeverity > 1) settings.nowarn.value = true
wrapNscReporter(new ConsoleReporter(settings))
}
abstract class ApiToNscReporterProxy(val apiReporter: ApiReporter) extends AbstractReporter {
import apiReporter.{Severity => ApiSeverity}
val API_INFO = apiReporter.INFO
val API_WARNING = apiReporter.WARNING
val API_ERROR = apiReporter.ERROR
type NscSeverity = Severity
val NSC_INFO = INFO
val NSC_WARNING = WARNING
val NSC_ERROR = ERROR
def display(pos: Position, msg: String, nscSeverity: NscSeverity): Unit =
apiReporter.log(pos, msg, nscSeverity match {
case NSC_INFO => API_INFO
case NSC_WARNING => API_WARNING
case NSC_ERROR => API_ERROR
})
def displayPrompt(): Unit =
apiReporter.interactive()
}
def wrapApiReporter(apiReporter: ApiReporter): NscReporter = new ApiToNscReporterProxy(apiReporter) {
val settings = new Settings()
settings.verbose.value = true
settings.nowarn.value = false
}
class NscToApiReporterProxy(val nscReporter: NscReporter) extends ApiReporter {
val API_INFO = INFO
val API_WARNING = WARNING
val API_ERROR = ERROR
def display(info: Info): Unit = info.severity match {
case API_INFO => nscReporter.info(info.pos, info.msg, false)
case API_WARNING => nscReporter.warning(info.pos, info.msg)
case API_ERROR => nscReporter.error(info.pos, info.msg)
}
def interactive(): Unit = nscReporter match {
case nscReporter: AbstractReporter => nscReporter.displayPrompt()
case _ => // do nothing
}
override def flush(): Unit = {
super.flush()
nscReporter.flush()
}
override def reset(): Unit = {
super.reset()
nscReporter.reset()
}
}
def wrapNscReporter(nscReporter: NscReporter): ApiReporter = new NscToApiReporterProxy(nscReporter)
}
|