@@ -13,36 +13,47 @@ import java.lang.System.currentTimeMillis
13
13
import core .Mode
14
14
import interfaces .Diagnostic .{ERROR , WARNING , INFO }
15
15
import dotty .tools .dotc .core .Symbols .Symbol
16
+ import diagnostic .Message
16
17
import ErrorMessages ._
17
18
18
19
object Reporter {
19
- class Error (msgFn : => String , pos : SourcePosition , kind : String = " Error" ) extends Diagnostic (msgFn, pos, ERROR , kind)
20
- class Warning (msgFn : => String , pos : SourcePosition , kind : String = " Warning" ) extends Diagnostic (msgFn, pos, WARNING , kind)
21
- class Info (msgFn : => String , pos : SourcePosition , kind : String = " Info" ) extends Diagnostic (msgFn, pos, INFO , kind)
20
+ class Error (msgFn : => String , pos : SourcePosition , kind : String = " Error" )
21
+ extends Message (msgFn, pos, ERROR , kind)
22
22
23
- abstract class ConditionalWarning (msgFn : => String , pos : SourcePosition , kind : String ) extends Warning (msgFn, pos, kind) {
23
+ class Warning (msgFn : => String , pos : SourcePosition , kind : String = " Warning" )
24
+ extends Message (msgFn, pos, WARNING , kind)
25
+
26
+ class Info (msgFn : => String , pos : SourcePosition , kind : String = " Info" )
27
+ extends Message (msgFn, pos, INFO , kind)
28
+
29
+ abstract class ConditionalWarning (msgFn : => String , pos : SourcePosition , kind : String )
30
+ extends Warning (msgFn, pos, kind) {
24
31
def enablingOption (implicit ctx : Context ): Setting [Boolean ]
25
32
}
26
- class FeatureWarning (msgFn : => String , pos : SourcePosition , kind : String = " Feature Warning" ) extends ConditionalWarning (msgFn, pos, kind) {
33
+ class FeatureWarning (msgFn : => String , pos : SourcePosition , kind : String = " Feature Warning" )
34
+ extends ConditionalWarning (msgFn, pos, kind) {
27
35
def enablingOption (implicit ctx : Context ) = ctx.settings.feature
28
36
}
29
- class UncheckedWarning (msgFn : => String , pos : SourcePosition , kind : String = " Unchecked Warning" ) extends ConditionalWarning (msgFn, pos, kind) {
37
+ class UncheckedWarning (msgFn : => String , pos : SourcePosition , kind : String = " Unchecked Warning" )
38
+ extends ConditionalWarning (msgFn, pos, kind) {
30
39
def enablingOption (implicit ctx : Context ) = ctx.settings.unchecked
31
40
}
32
- class DeprecationWarning (msgFn : => String , pos : SourcePosition , kind : String = " Deprecation Warning" ) extends ConditionalWarning (msgFn, pos, kind) {
41
+ class DeprecationWarning (msgFn : => String , pos : SourcePosition , kind : String = " Deprecation Warning" )
42
+ extends ConditionalWarning (msgFn, pos, kind) {
33
43
def enablingOption (implicit ctx : Context ) = ctx.settings.deprecation
34
44
}
35
- class MigrationWarning (msgFn : => String , pos : SourcePosition , kind : String = " Migration Warning" ) extends ConditionalWarning (msgFn, pos, kind) {
45
+ class MigrationWarning (msgFn : => String , pos : SourcePosition , kind : String = " Migration Warning" ) extends
46
+ ConditionalWarning (msgFn, pos, kind) {
36
47
def enablingOption (implicit ctx : Context ) = ctx.settings.migration
37
48
}
38
49
39
50
/** Convert a SimpleReporter into a real Reporter */
40
51
def fromSimpleReporter (simple : interfaces.SimpleReporter ): Reporter =
41
52
new Reporter with UniqueMessagePositions with HideNonSensicalMessages {
42
- override def doReport (d : Diagnostic )(implicit ctx : Context ): Unit = d match {
43
- case d : ConditionalWarning if ! d .enablingOption.value =>
53
+ override def doReport (m : Message )(implicit ctx : Context ): Unit = m match {
54
+ case m : ConditionalWarning if ! m .enablingOption.value =>
44
55
case _ =>
45
- simple.report(d )
56
+ simple.report(m )
46
57
}
47
58
}
48
59
}
@@ -207,7 +218,7 @@ trait Reporting { this: Context =>
207
218
abstract class Reporter extends interfaces.ReporterResult {
208
219
209
220
/** Report a diagnostic */
210
- def doReport (d : Diagnostic )(implicit ctx : Context ): Unit
221
+ def doReport (d : Message )(implicit ctx : Context ): Unit
211
222
212
223
/** Whether very long lines can be truncated. This exists so important
213
224
* debugging information (like printing the classpath) is not rendered
@@ -222,7 +233,7 @@ abstract class Reporter extends interfaces.ReporterResult {
222
233
finally _truncationOK = saved
223
234
}
224
235
225
- type ErrorHandler = Diagnostic => Context => Unit
236
+ type ErrorHandler = Message => Context => Unit
226
237
private var incompleteHandler : ErrorHandler = d => c => report(d)(c)
227
238
def withIncompleteHandler [T ](handler : ErrorHandler )(op : => T ): T = {
228
239
val saved = incompleteHandler
@@ -251,7 +262,7 @@ abstract class Reporter extends interfaces.ReporterResult {
251
262
override def default (key : String ) = 0
252
263
}
253
264
254
- def report (d : Diagnostic )(implicit ctx : Context ): Unit =
265
+ def report (d : Message )(implicit ctx : Context ): Unit =
255
266
if (! isHidden(d)) {
256
267
doReport(d)(ctx.addMode(Mode .Printing ))
257
268
d match {
@@ -265,7 +276,7 @@ abstract class Reporter extends interfaces.ReporterResult {
265
276
}
266
277
}
267
278
268
- def incomplete (d : Diagnostic )(implicit ctx : Context ): Unit =
279
+ def incomplete (d : Message )(implicit ctx : Context ): Unit =
269
280
incompleteHandler(d)(ctx)
270
281
271
282
@@ -298,7 +309,7 @@ abstract class Reporter extends interfaces.ReporterResult {
298
309
}
299
310
300
311
/** Should this diagnostic not be reported at all? */
301
- def isHidden (d : Diagnostic )(implicit ctx : Context ): Boolean = ctx.mode.is(Mode .Printing )
312
+ def isHidden (m : Message )(implicit ctx : Context ): Boolean = ctx.mode.is(Mode .Printing )
302
313
303
314
/** Does this reporter contain not yet reported errors or warnings? */
304
315
def hasPending : Boolean = false
0 commit comments