File tree 1 file changed +14
-11
lines changed
compiler/src/dotty/tools/dotc/transform/init
1 file changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -5,9 +5,9 @@ package init
5
5
import ast .tpd ._
6
6
7
7
import core ._
8
- import Decorators ._
8
+ import Decorators ._ , printing . SyntaxHighlighting
9
9
import Types ._ , Symbols ._ , Contexts ._
10
- import util .NoSourcePosition
10
+ import util .SourcePosition
11
11
12
12
import Effects ._ , Potentials ._
13
13
@@ -30,19 +30,22 @@ object Errors {
30
30
31
31
def stacktrace (implicit ctx : Context ): String = if (trace.isEmpty) " " else " Calling trace:\n " + {
32
32
var indentCount = 0
33
- var last = " "
33
+ var last : String = " "
34
34
val sb = new StringBuilder
35
35
trace.foreach { tree =>
36
36
indentCount += 1
37
37
val pos = tree.sourcePos
38
- val line = " [ " + pos.source.file.name + " :" + (pos.line + 1 ) + " ]"
39
- if (last != line)
40
- sb.append(
41
- if (pos.source.exists)
42
- i " ${ " " * indentCount }-> ${pos.lineContent.trim}\t $line\n "
43
- else
44
- i " ${tree.show}\n "
45
- )
38
+ val prefix = s " ${ " " * indentCount }-> "
39
+ val line =
40
+ if pos.source.exists then
41
+ val loc = " [ " + pos.source.file.name + " :" + (pos.line + 1 ) + " ]"
42
+ val code = SyntaxHighlighting .highlight(pos.lineContent.trim)
43
+ i " $code\t $loc"
44
+ else
45
+ tree.show
46
+
47
+ if (last != line) sb.append(prefix + line + " \n " )
48
+
46
49
last = line
47
50
}
48
51
sb.toString
You can’t perform that action at this time.
0 commit comments