diff options
author | Martin Odersky <odersky@gmail.com> | 2014-07-10 14:54:21 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-07-17 11:02:01 +0200 |
commit | 1ac95a7209439116750592931e43981127950ad4 (patch) | |
tree | f2ecde2c2a2fc9687220ace3f6cdd216c485e665 | |
parent | 34202eb4e13921190bf4992ab33d9d69975f4940 (diff) | |
download | dotty-1ac95a7209439116750592931e43981127950ad4.tar.gz dotty-1ac95a7209439116750592931e43981127950ad4.tar.bz2 dotty-1ac95a7209439116750592931e43981127950ad4.zip |
Add unique ids for definitions
If -uniqid is on, RefinedPrinter now prints unique ids in definitions.
-rw-r--r-- | src/dotty/tools/dotc/printing/RefinedPrinter.scala | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/src/dotty/tools/dotc/printing/RefinedPrinter.scala index a327b4e3e..017434aa4 100644 --- a/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -194,6 +194,8 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { case _ => toTextGlobal(arg) } + def idText = if (ctx.settings.uniqid.value) "#" + tree.symbol.id else "" + import untpd._ var txt: Text = tree match { @@ -283,18 +285,18 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { "(" ~ toTextGlobal(patterns, ", ") ~ ")" ~ ("(" ~ toTextGlobal(implicits, ", ") ~ ")" provided implicits.nonEmpty) case ValDef(mods, name, tpt, rhs) => - modText(mods, if (mods is Mutable) "var" else "val") ~~ toText(name) ~ + modText(mods, if (mods is Mutable) "var" else "val") ~~ toText(name) ~ idText ~ optAscription(tpt) ~ optText(rhs)(" = " ~ _) case DefDef(mods, name, tparams, vparamss, tpt, rhs) => atOwner(tree) { - val first = modText(mods, "def") ~~ toText(name) ~ tparamsText(tparams) + val first = modText(mods, "def") ~~ toText(name) ~ idText ~ tparamsText(tparams) addVparamssText(first, vparamss) ~ optAscription(tpt) ~ optText(rhs)(" = " ~ _) } case tree @ TypeDef(mods, name, rhs) => atOwner(tree) { def typeDefText(rhsText: Text) = { val rhsText1 = if (tree.hasType) toText(tree.symbol.info) else rhsText - modText(mods, "type") ~~ toText(name) ~ tparamsText(tree.tparams) ~ rhsText1 + modText(mods, "type") ~~ toText(name) ~ idText ~ tparamsText(tree.tparams) ~ rhsText1 } rhs match { case impl: Template => |