@@ -12,13 +12,13 @@ import core.Mode
12
12
import dotty .tools .dotc .core .Symbols .Symbol
13
13
import diagnostic .messages ._
14
14
import diagnostic ._
15
- import MessageCreator ._
15
+ import Message ._
16
16
17
17
object Reporter {
18
18
/** Convert a SimpleReporter into a real Reporter */
19
19
def fromSimpleReporter (simple : interfaces.SimpleReporter ): Reporter =
20
20
new Reporter with UniqueMessagePositions with HideNonSensicalMessages {
21
- override def doReport (m : Message )(implicit ctx : Context ): Unit = m match {
21
+ override def doReport (m : MessageContainer )(implicit ctx : Context ): Unit = m match {
22
22
case m : ConditionalWarning if ! m.enablingOption.value =>
23
23
case _ =>
24
24
simple.report(m)
@@ -37,17 +37,17 @@ trait Reporting { this: Context =>
37
37
def echo (msg : => String , pos : SourcePosition = NoSourcePosition ): Unit =
38
38
reporter.report(new Info (msg, pos, " Info" ))
39
39
40
- def deprecationWarning (msg : => String , pos : SourcePosition = NoSourcePosition ): Unit =
41
- reporter.report(new DeprecationWarning ( msg, pos, " Deprecation Warning " ))
40
+ def deprecationWarning (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
41
+ reporter.report(msg.deprecationWarning( pos))
42
42
43
- def migrationWarning (msg : => String , pos : SourcePosition = NoSourcePosition ): Unit =
44
- reporter.report(new MigrationWarning ( msg, pos, " Migration Warning " ))
43
+ def migrationWarning (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
44
+ reporter.report(msg.migrationWarning( pos))
45
45
46
- def uncheckedWarning (msg : => String , pos : SourcePosition = NoSourcePosition ): Unit =
47
- reporter.report(new UncheckedWarning ( msg, pos, " Unchecked Warning " ))
46
+ def uncheckedWarning (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
47
+ reporter.report(msg.uncheckedWarning( pos))
48
48
49
- def featureWarning (msg : => String , pos : SourcePosition = NoSourcePosition ): Unit =
50
- reporter.report(new FeatureWarning ( msg, pos, " Feature Warning " ))
49
+ def featureWarning (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
50
+ reporter.report(msg.featureWarning( pos))
51
51
52
52
def featureWarning (feature : String , featureDescription : String , isScala2Feature : Boolean ,
53
53
featureUseSite : Symbol , required : Boolean , pos : SourcePosition ): Unit = {
@@ -72,32 +72,24 @@ trait Reporting { this: Context =>
72
72
else reporter.report(new FeatureWarning (msg, pos))
73
73
}
74
74
75
- def warning (msg : => String , pos : SourcePosition = NoSourcePosition ): Unit =
76
- reporter.report(new Warning (msg, pos))
77
-
78
- def explainWarning (msg : => MessageCreator , pos : SourcePosition = NoSourcePosition ): Unit =
75
+ def warning (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
79
76
reporter.report(msg.warning(pos))
80
77
81
- def strictWarning (msg : => String , pos : SourcePosition = NoSourcePosition ): Unit =
78
+ def strictWarning (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
82
79
if (this .settings.strict.value) error(msg, pos)
83
- else warning(msg + " \n (This would be an error under strict mode)" , pos)
84
-
85
- def error (msg : => String , pos : SourcePosition = NoSourcePosition ): Unit = {
86
- // println("*** ERROR: " + msg) // !!! DEBUG
87
- reporter.report(new Error (msg, pos))
88
- }
80
+ else warning(msg.mapMsg(_ + " \n (This would be an error under strict mode)" ), pos)
89
81
90
- def explainError (msg : => MessageCreator , pos : SourcePosition = NoSourcePosition ): Unit =
82
+ def error (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
91
83
reporter.report(msg.error(pos))
92
84
93
- def errorOrMigrationWarning (msg : => String , pos : SourcePosition = NoSourcePosition ): Unit =
85
+ def errorOrMigrationWarning (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
94
86
if (ctx.scala2Mode) migrationWarning(msg, pos) else error(msg, pos)
95
87
96
- def restrictionError (msg : => String , pos : SourcePosition = NoSourcePosition ): Unit =
97
- error(s " Implementation restriction: $msg " , pos)
88
+ def restrictionError (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
89
+ error(msg.mapMsg(m => s " Implementation restriction: $m " ) , pos)
98
90
99
- def incompleteInputError (msg : String , pos : SourcePosition = NoSourcePosition )(implicit ctx : Context ): Unit =
100
- reporter.incomplete(new Error ( msg, pos))(ctx)
91
+ def incompleteInputError (msg : Message , pos : SourcePosition = NoSourcePosition )(implicit ctx : Context ): Unit =
92
+ reporter.incomplete(msg.error( pos))(ctx)
101
93
102
94
/** Log msg if settings.log contains the current phase.
103
95
* See [[config.CompilerCommand#explainAdvanced ]] for the exact meaning of
@@ -180,7 +172,7 @@ trait Reporting { this: Context =>
180
172
abstract class Reporter extends interfaces.ReporterResult {
181
173
182
174
/** Report a diagnostic */
183
- def doReport (d : Message )(implicit ctx : Context ): Unit
175
+ def doReport (d : MessageContainer )(implicit ctx : Context ): Unit
184
176
185
177
/** Whether very long lines can be truncated. This exists so important
186
178
* debugging information (like printing the classpath) is not rendered
@@ -195,7 +187,7 @@ abstract class Reporter extends interfaces.ReporterResult {
195
187
finally _truncationOK = saved
196
188
}
197
189
198
- type ErrorHandler = Message => Context => Unit
190
+ type ErrorHandler = MessageContainer => Context => Unit
199
191
private var incompleteHandler : ErrorHandler = d => c => report(d)(c)
200
192
def withIncompleteHandler [T ](handler : ErrorHandler )(op : => T ): T = {
201
193
val saved = incompleteHandler
@@ -224,7 +216,7 @@ abstract class Reporter extends interfaces.ReporterResult {
224
216
override def default (key : String ) = 0
225
217
}
226
218
227
- def report (d : Message )(implicit ctx : Context ): Unit =
219
+ def report (d : MessageContainer )(implicit ctx : Context ): Unit =
228
220
if (! isHidden(d)) {
229
221
doReport(d)(ctx.addMode(Mode .Printing ))
230
222
d match {
@@ -238,12 +230,11 @@ abstract class Reporter extends interfaces.ReporterResult {
238
230
}
239
231
}
240
232
241
- def incomplete (d : Message )(implicit ctx : Context ): Unit =
233
+ def incomplete (d : MessageContainer )(implicit ctx : Context ): Unit =
242
234
incompleteHandler(d)(ctx)
243
235
244
-
245
236
/** Summary of warnings and errors */
246
- def summary /* (implicit ctx: Context) */ : String = {
237
+ def summary : String = {
247
238
val b = new mutable.ListBuffer [String ]
248
239
if (warningCount > 0 )
249
240
b += countString(warningCount, " warning" ) + " found"
@@ -271,7 +262,7 @@ abstract class Reporter extends interfaces.ReporterResult {
271
262
}
272
263
273
264
/** Should this diagnostic not be reported at all? */
274
- def isHidden (m : Message )(implicit ctx : Context ): Boolean = ctx.mode.is(Mode .Printing )
265
+ def isHidden (m : MessageContainer )(implicit ctx : Context ): Boolean = ctx.mode.is(Mode .Printing )
275
266
276
267
/** Does this reporter contain not yet reported errors or warnings? */
277
268
def hasPending : Boolean = false
0 commit comments