@@ -8,9 +8,10 @@ import ast.tpd._
8
8
import core ._
9
9
import Decorators ._ , printing .SyntaxHighlighting
10
10
import Types ._ , Symbols ._ , Contexts ._
11
- import util .{ SimpleIdentityMap , SourcePosition }
11
+ import util .{ SimpleIdentityMap , SourcePosition , NoSourcePosition }
12
12
13
13
import reporting .MessageRendering
14
+ import printing .Highlighting
14
15
15
16
import Effects ._ , Potentials ._
16
17
@@ -56,31 +57,33 @@ object Errors {
56
57
val padding = pos.startColumnPadding + (" " * offset)
57
58
val marker = padding + carets
58
59
val textline = padding + msg
59
- " \n " + marker + " \n " + textline
60
+ marker + " \n " + textline + " \n "
60
61
61
62
def stacktrace (using Context ): String = if (trace.isEmpty) " " else stacktracePrefix + {
62
63
var indentCount = 0
63
- var last : String = " "
64
+ var last : SourcePosition = NoSourcePosition
64
65
val sb = new StringBuilder
65
66
trace.foreach { tree =>
66
67
indentCount += 1
67
68
val pos = tree.sourcePos
68
- val prefix = s " ${ " " * indentCount }-> "
69
+ val prefix = (" " * indentCount) + " -> "
70
+ var pinpoint = " "
69
71
val line =
70
72
if pos.source.exists then
71
- val loc = " [ " + pos.source.file.name + " :" + (pos.line + 1 ) + " ]"
72
- val code = SyntaxHighlighting .highlight(pos.lineContent.stripLineEnd )
73
- val pinpoint =
74
- if ! pinpoints.contains(tree) then " "
75
- else pinpointText(pos, pinpoints(tree), indentCount + 3 )
73
+ val locText = " [ " + pos.source.file.name + " :" + (pos.line + 1 ) + " ]"
74
+ val loc = Highlighting . Blue (locText )
75
+ val code = SyntaxHighlighting .highlight(pos.lineContent)
76
+ if pinpoints.contains(tree) then
77
+ pinpoint = pinpointText(pos, pinpoints(tree), locText.length + prefix.length )
76
78
77
- i " $code \t $ loc" + pinpoint
79
+ i " $loc$prefix$code "
78
80
else
79
81
tree.show
80
82
81
- if (last != line) sb.append(prefix + line + " \n " )
83
+ if (last.source != pos.source || last.line != pos.line)
84
+ sb.append(line + pinpoint)
82
85
83
- last = line
86
+ last = pos
84
87
}
85
88
sb.toString
86
89
}
@@ -161,7 +164,7 @@ object Errors {
161
164
162
165
def show (using Context ): String = {
163
166
var index = 0
164
- " Promoting the value to fully-initialized is unsafe.\n " + stacktrace +
167
+ " Promoting the value to fully-initialized is unsafe. " + stacktrace +
165
168
" \n The unsafe promotion may cause the following problem(s):\n " +
166
169
(errors.flatMap(_.flatten).map { error =>
167
170
index += 1
0 commit comments