From 19b6784ef1cae9cd0af278c0c3afcee47c0a00ea Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 4 Nov 2013 11:27:15 +0100 Subject: Added capability to print tree positions Controlled by option -Yprintpos --- src/dotty/tools/dotc/config/ScalaSettings.scala | 1 + src/dotty/tools/dotc/printing/RefinedPrinter.scala | 2 ++ 2 files changed, 3 insertions(+) (limited to 'src') diff --git a/src/dotty/tools/dotc/config/ScalaSettings.scala b/src/dotty/tools/dotc/config/ScalaSettings.scala index f1ca5bd6c..ef926c664 100644 --- a/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -142,6 +142,7 @@ class ScalaSettings extends Settings.SettingGroup { val noSelfCheck = BooleanSetting("-Yno-self-type-checks", "Suppress check for self-type conformance among inherited members.") val YshowSuppressedErrors = BooleanSetting("-Yshow-suppressed-errors", "Also show follow-on errors and warnings that are normally supressed.") val Yheartbeat = BooleanSetting("-Yheartbeat", "show heartbeat stack trace of compiler operations.") + val Yprintpos = BooleanSetting("-Yprintpos", "show tree positions") def stop = stopAfter /** Area-specific debug output. diff --git a/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/src/dotty/tools/dotc/printing/RefinedPrinter.scala index 0e2eb77f2..a62eb5acd 100644 --- a/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -372,6 +372,8 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { if (tree.isType) txt = toText(tp) else if (!tree.isDef) txt = "<" ~ txt ~ ":" ~ toText(tp) ~ ">" } + if (ctx.settings.Yprintpos.value && !tree.isInstanceOf[WithoutTypeOrPos[_]]) + txt = txt ~ "@" ~ tree.pos.toString tree match { case Block(_, _) | Template(_, _, _, _) => txt case _ => txt.close -- cgit v1.2.3