File tree Expand file tree Collapse file tree 1 file changed +14
-11
lines changed
compiler/src/dotty/tools/dotc/transform/init Expand file tree Collapse file tree 1 file changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -5,9 +5,9 @@ package init
55import ast .tpd ._
66
77import core ._
8- import Decorators ._
8+ import Decorators ._ , printing . SyntaxHighlighting
99import Types ._ , Symbols ._ , Contexts ._
10- import util .NoSourcePosition
10+ import util .SourcePosition
1111
1212import Effects ._ , Potentials ._
1313
@@ -30,19 +30,22 @@ object Errors {
3030
3131 def stacktrace (implicit ctx : Context ): String = if (trace.isEmpty) " " else " Calling trace:\n " + {
3232 var indentCount = 0
33- var last = " "
33+ var last : String = " "
3434 val sb = new StringBuilder
3535 trace.foreach { tree =>
3636 indentCount += 1
3737 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+
4649 last = line
4750 }
4851 sb.toString
You can’t perform that action at this time.
0 commit comments