@@ -182,7 +182,7 @@ class DefaultReporter(debugSections: Set[DebugSection]) extends Reporter(debugSe
182
182
183
183
def emit (msg : Message ) = synchronized {
184
184
println(reline(severityToPrefix(msg.severity), smartPos(msg.position) + msg.msg.toString))
185
- printLineContent(msg.position)
185
+ printLineContent(msg.position, false )
186
186
}
187
187
188
188
def getLine (pos : Position ): Option [String ] = {
@@ -201,10 +201,12 @@ class DefaultReporter(debugSections: Set[DebugSection]) extends Reporter(debugSe
201
201
202
202
val blankPrefix = " " * prefixSize
203
203
204
- def printLineContent (pos : Position ): Unit = {
204
+ def printLineContent (pos : Position , asciiOnly : Boolean ): Unit = {
205
205
getLine(pos) match {
206
206
case Some (line) =>
207
- println(blankPrefix+ line)
207
+ // Scala positions probably assume 1 tab = 8 spaces, so we replaces tabs
208
+ // for the carret (^) computed below to be aligned
209
+ println(blankPrefix+ line.replace(" \t " , " " * 8 ))
208
210
pos match {
209
211
case rp : RangePosition =>
210
212
val bp = rp.focusBegin
@@ -218,10 +220,16 @@ class DefaultReporter(debugSections: Set[DebugSection]) extends Reporter(debugSe
218
220
(" ^" * width)+ " ..."
219
221
}
220
222
221
- println(blankPrefix+ (" " * (bp.col - 1 ) + Console .RED + carret+ Console .RESET ))
223
+ if (asciiOnly)
224
+ println(blankPrefix+ (" " * (bp.col - 1 ) + carret))
225
+ else
226
+ println(blankPrefix+ (" " * (bp.col - 1 ) + Console .RED + carret+ Console .RESET ))
222
227
223
228
case op : OffsetPosition =>
224
- println(blankPrefix+ (" " * (op.col - 1 ) + Console .RED + " ^" + Console .RESET ))
229
+ if (asciiOnly)
230
+ println(blankPrefix+ (" " * (op.col - 1 ) + " ^" ))
231
+ else
232
+ println(blankPrefix+ (" " * (op.col - 1 ) + Console .RED + " ^" + Console .RESET ))
225
233
}
226
234
case None =>
227
235
}
@@ -234,12 +242,26 @@ class DefaultReporter(debugSections: Set[DebugSection]) extends Reporter(debugSe
234
242
}
235
243
236
244
class PlainTextReporter (debugSections : Set [DebugSection ]) extends DefaultReporter (debugSections) {
237
- override protected def severityToPrefix (sev : Severity ): String = sev match {
238
- case ERROR => " [ Error ]"
239
- case WARNING => " [Warning ]"
240
- case INFO => " [ Info ]"
241
- case FATAL => " [ Fatal ]"
242
- case INTERNAL => " [Internal]"
243
- case DEBUG (_) => " [ Debug ]"
245
+ override protected def severityToPrefix (sev : Severity ): String = " "
246
+
247
+ protected def severityToString (sev : Severity ): String = sev match {
248
+ case ERROR => " error"
249
+ case WARNING => " warning"
250
+ case INFO => " info"
251
+ case FATAL => " fatal"
252
+ case INTERNAL => " internal"
253
+ case DEBUG (_) => " debug"
254
+ }
255
+
256
+ override def emit (msg : Message ) = synchronized {
257
+ if (msg.severity == ERROR || msg.severity == FATAL || msg.severity == INTERNAL )
258
+ println(smartPos(msg.position) + " error: " + msg.msg.toString)
259
+ else if (msg.severity == WARNING )
260
+ println(smartPos(msg.position) + " warning: " + msg.msg.toString)
261
+ else if (msg.severity.isInstanceOf [DEBUG ])
262
+ println(smartPos(msg.position) + " debug: " + msg.msg.toString)
263
+ else
264
+ println(smartPos(msg.position) + msg.msg.toString)
265
+ printLineContent(msg.position, true )
244
266
}
245
267
}
0 commit comments