aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/printing/Showable.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-03-26 12:28:12 +0100
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2014-03-29 09:16:41 +0100
commit0a1e969cb09e953d6b3f3b64b63a050588aa3360 (patch)
treefe5bdc5e6d23958a8fdf058dcd6d70798187ceff /src/dotty/tools/dotc/printing/Showable.scala
parent21c92528ca6598a918e096601d49f99cc61b4582 (diff)
downloaddotty-0a1e969cb09e953d6b3f3b64b63a050588aa3360.tar.gz
dotty-0a1e969cb09e953d6b3f3b64b63a050588aa3360.tar.bz2
dotty-0a1e969cb09e953d6b3f3b64b63a050588aa3360.zip
Summary printing
Added general way to produce summaries when shwowing trees or types. Summaries have limited, configrable recusion depth. fix showSummary
Diffstat (limited to 'src/dotty/tools/dotc/printing/Showable.scala')
-rw-r--r--src/dotty/tools/dotc/printing/Showable.scala12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/printing/Showable.scala b/src/dotty/tools/dotc/printing/Showable.scala
index cb65193e6..550d80060 100644
--- a/src/dotty/tools/dotc/printing/Showable.scala
+++ b/src/dotty/tools/dotc/printing/Showable.scala
@@ -4,6 +4,7 @@ package printing
import core._
import Contexts._, Texts._, Decorators._
+import config.Config.summarizeDepth
trait Showable extends Any {
@@ -20,4 +21,13 @@ trait Showable extends Any {
/** The string representation of this showable element. */
def show(implicit ctx: Context): String = toText(ctx.printer).show
-} \ No newline at end of file
+
+ /** The summarized string representation of this showable element.
+ * Recursion depth is limited to some smallish value. Default is
+ * Config.summarizeDepth.
+ */
+ def showSummary(depth: Int)(implicit ctx: Context): String =
+ ctx.printer.summarized(depth)(show)
+
+ def showSummary(implicit ctx: Context): String = showSummary(summarizeDepth)
+}