summaryrefslogtreecommitdiff
path: root/src/reflect/scala/reflect/api/Printers.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2014-01-15 08:02:35 -0800
committerJason Zaugg <jzaugg@gmail.com>2014-01-15 08:02:35 -0800
commit07e823ad9710734092c81fa7734e38bbd4fe2efa (patch)
treee86f67f9406604a8613bb01a93a3f5809076f97c /src/reflect/scala/reflect/api/Printers.scala
parentdb8b599fc6f9c66f37a653e65fd31c9b0cd344ce (diff)
parentd680d23947778a963ec23580efccbf2527f3a97c (diff)
downloadscala-07e823ad9710734092c81fa7734e38bbd4fe2efa.tar.gz
scala-07e823ad9710734092c81fa7734e38bbd4fe2efa.tar.bz2
scala-07e823ad9710734092c81fa7734e38bbd4fe2efa.zip
Merge pull request #3321 from VladimirNik/sprinter
Add tree-based code generation
Diffstat (limited to 'src/reflect/scala/reflect/api/Printers.scala')
-rw-r--r--src/reflect/scala/reflect/api/Printers.scala19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/reflect/scala/reflect/api/Printers.scala b/src/reflect/scala/reflect/api/Printers.scala
index 1e0854d171..5bc92d3893 100644
--- a/src/reflect/scala/reflect/api/Printers.scala
+++ b/src/reflect/scala/reflect/api/Printers.scala
@@ -201,6 +201,25 @@ trait Printers { self: Universe =>
*/
protected def newTreePrinter(out: PrintWriter): TreePrinter
+ /**
+ * Renders the code of the passed tree, so that:
+ * 1) it can be later compiled by scalac retaining the same meaning,
+ * 2) it looks pretty.
+ * At the moment we have handled #1 for unattributed trees and
+ * later on plan to account for typical idiosyncrasies of the typechecker.
+ * #2 is more or less okay indentation-wise, but at the moment there's a lot of desugaring
+ * left in place, and that's what we also plan to improve in the future.
+ *
+ * @group Printers
+ */
+ def showCode(tree: Tree) = render(tree, newCodePrinter)
+
+ /**
+ * Hook to define what `showCode(...)` means.
+ * @group Printers
+ */
+ protected def newCodePrinter(out: PrintWriter): TreePrinter
+
/** Renders internal structure of a reflection artifact as the
* visualization of a Scala syntax tree.
*