diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-01-15 08:02:35 -0800 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-01-15 08:02:35 -0800 |
commit | 07e823ad9710734092c81fa7734e38bbd4fe2efa (patch) | |
tree | e86f67f9406604a8613bb01a93a3f5809076f97c /src/reflect/scala/reflect/api/Printers.scala | |
parent | db8b599fc6f9c66f37a653e65fd31c9b0cd344ce (diff) | |
parent | d680d23947778a963ec23580efccbf2527f3a97c (diff) | |
download | scala-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.scala | 19 |
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. * |