From 94b9a2a0d083cca2ba1358582d8d6fd8143b0b31 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 17 May 2013 13:28:02 +0200 Subject: Refactored Printing architecture. Split printers into several files. Added refined printing of trees. Changed Showable and generalized printing under a precedence. --- src/dotty/tools/dotc/printing/Showable.scala | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/dotty/tools/dotc/printing/Showable.scala') 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 -- cgit v1.2.3