diff options
author | Martin Odersky <odersky@gmail.com> | 2014-08-18 13:18:50 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-08-18 13:18:50 +0200 |
commit | f2d27cf6b57d6d3fd83818ce07d3aeb14263f897 (patch) | |
tree | f727607d1c8a297254947cae887390ae479602c8 /src | |
parent | 1e29d8aca7c041f83ac520f891add8476471c1bd (diff) | |
download | dotty-f2d27cf6b57d6d3fd83818ce07d3aeb14263f897.tar.gz dotty-f2d27cf6b57d6d3fd83818ce07d3aeb14263f897.tar.bz2 dotty-f2d27cf6b57d6d3fd83818ce07d3aeb14263f897.zip |
Add #ids for This trees and ClassDefs
if uniqid is set, print them with their unique ids.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/printing/RefinedPrinter.scala | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/src/dotty/tools/dotc/printing/RefinedPrinter.scala index ab248a4fc..d98c4f95e 100644 --- a/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -200,6 +200,10 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { annotsText(tree.symbol) ~~ dclText(tree.symbol) else treeText + def idText(tree: untpd.Tree): Text = { + if (ctx.settings.uniqid.value && tree.symbol.exists) s"#${tree.symbol.id}" else "" + } + import untpd._ var txt: Text = tree match { @@ -213,7 +217,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { case Select(qual, name) => toTextLocal(qual) ~ ("." ~ toText(name) provided name != nme.CONSTRUCTOR) case This(name) => - optDotPrefix(name) ~ "this" + optDotPrefix(name) ~ "this" ~ idText(tree) case Super(This(name), mix) => optDotPrefix(name) ~ "super" ~ optText(mix)("[" ~ _ ~ "]") case Apply(fun, args) => @@ -309,7 +313,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { } rhs match { case impl: Template => - modText(mods, if (mods is Trait) "trait" else "class") ~~ toText(name) ~ toText(impl) ~ + modText(mods, if (mods is Trait) "trait" else "class") ~~ toText(name) ~~ idText(tree) ~ toText(impl) ~ (if (tree.hasType && ctx.settings.verbose.value) s"[decls = ${tree.symbol.info.decls}]" else "") case rhs: TypeBoundsTree => typeDefText(toText(rhs)) |