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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
/* NSC -- new Scala compiler
* Copyright 2005-2014 LAMP/EPFL, Typesafe Inc.
* @author Adriaan Moors
*/
package scala
package reflect
package internal
/** Provides delegates to the reporter doing the actual work.
* All forwarding methods should be marked final,
* but some subclasses out of our reach stil override them.
*/
trait Reporting { self : Positions =>
def reporter: Reporter
@deprecatedOverriding("This forwards to the corresponding method in reporter -- override reporter instead", "2.11.2")
def inform(msg: String): Unit = inform(NoPosition, msg)
@deprecatedOverriding("This forwards to the corresponding method in reporter -- override reporter instead", "2.11.2")
def warning(msg: String): Unit = warning(NoPosition, msg)
// globalError(msg: String) used to abort -- not sure that was a good idea, so I made it more regular
// (couldn't find any uses that relied on old behavior)
@deprecatedOverriding("This forwards to the corresponding method in reporter -- override reporter instead", "2.11.2")
def globalError(msg: String): Unit = globalError(NoPosition, msg)
def abort(msg: String): Nothing = {
val augmented = supplementErrorMessage(msg)
// Needs to call error to make sure the compile fails.
globalError(augmented)
throw new FatalError(augmented)
}
@deprecatedOverriding("This forwards to the corresponding method in reporter -- override reporter instead", "2.11.2")
def inform(pos: Position, msg: String) = reporter.echo(pos, msg)
@deprecatedOverriding("This forwards to the corresponding method in reporter -- override reporter instead", "2.11.2")
def warning(pos: Position, msg: String) = reporter.warning(pos, msg)
@deprecatedOverriding("This forwards to the corresponding method in reporter -- override reporter instead", "2.11.2")
def globalError(pos: Position, msg: String) = reporter.error(pos, msg)
def deprecationWarning(pos: Position, msg: String): Unit = warning(msg)
/** Overridden when we know more about what was happening during a failure. */
def supplementErrorMessage(msg: String): String = msg
}
import util.Position
/** Report information, warnings and errors.
*
* This describes the (future) external interface for issuing information, warnings and errors.
* Currently, scala.tools.nsc.Reporter is used by sbt/ide/partest.
*/
abstract class Reporter {
protected def info0(pos: Position, msg: String, severity: Severity, force: Boolean): Unit
def echo(pos: Position, msg: String): Unit = info0(pos, msg, INFO, force = true)
def warning(pos: Position, msg: String): Unit = info0(pos, msg, WARNING, force = false)
def error(pos: Position, msg: String): Unit = info0(pos, msg, ERROR, force = false)
type Severity
val INFO: Severity
val WARNING: Severity
val ERROR: Severity
def count(severity: Severity): Int
def resetCount(severity: Severity): Unit
def hasErrors: Boolean = count(ERROR) > 0
def hasWarnings: Boolean = count(WARNING) > 0
def reset(): Unit = {
resetCount(INFO)
resetCount(WARNING)
resetCount(ERROR)
}
def flush(): Unit = { }
}
// TODO: move into superclass once partest cuts tie on Severity
abstract class ReporterImpl extends Reporter {
class Severity(val id: Int)(name: String) { var count: Int = 0 ; override def toString = name}
object INFO extends Severity(0)("INFO")
object WARNING extends Severity(1)("WARNING")
object ERROR extends Severity(2)("ERROR")
def count(severity: Severity): Int = severity.count
def resetCount(severity: Severity): Unit = severity.count = 0
}
|