aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/printing/Showable.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-05-17 13:28:02 +0200
committerMartin Odersky <odersky@gmail.com>2013-05-17 13:28:02 +0200
commit94b9a2a0d083cca2ba1358582d8d6fd8143b0b31 (patch)
treee84279f763b7a241bf18c27c7227d66618936719 /src/dotty/tools/dotc/printing/Showable.scala
parentd2261b37cf23ccd04e9029f3556c2dc9e2bdf077 (diff)
downloaddotty-94b9a2a0d083cca2ba1358582d8d6fd8143b0b31.tar.gz
dotty-94b9a2a0d083cca2ba1358582d8d6fd8143b0b31.tar.bz2
dotty-94b9a2a0d083cca2ba1358582d8d6fd8143b0b31.zip
Refactored Printing architecture.
Split printers into several files. Added refined printing of trees. Changed Showable and generalized printing under a precedence.
Diffstat (limited to 'src/dotty/tools/dotc/printing/Showable.scala')
-rw-r--r--src/dotty/tools/dotc/printing/Showable.scala15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/printing/Showable.scala b/src/dotty/tools/dotc/printing/Showable.scala
index 73d320019..cb65193e6 100644
--- a/src/dotty/tools/dotc/printing/Showable.scala
+++ b/src/dotty/tools/dotc/printing/Showable.scala
@@ -5,10 +5,19 @@ import core._
import Contexts._, Texts._, Decorators._
-trait Showable {
+trait Showable extends Any {
- def toText(implicit ctx: Context): Text
+ /** The text representation of this showable element.
+ * This normally dispatches to a pattern matching
+ * method in Printers.
+ */
+ def toText(printer: Printer): Text
- def show(implicit ctx: Context): String = toText.show
+ /** A fallback text representation, if the pattern matching
+ * in Printers does not have a case for this showable element
+ */
+ def fallbackToText(printer: Printer): Text = toString
+ /** The string representation of this showable element. */
+ def show(implicit ctx: Context): String = toText(ctx.printer).show
} \ No newline at end of file