aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/printing/PlainPrinter.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/PlainPrinter.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/PlainPrinter.scala')
-rw-r--r--src/dotty/tools/dotc/printing/PlainPrinter.scala19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/printing/PlainPrinter.scala b/src/dotty/tools/dotc/printing/PlainPrinter.scala
index 332b7bd21..f10aa7225 100644
--- a/src/dotty/tools/dotc/printing/PlainPrinter.scala
+++ b/src/dotty/tools/dotc/printing/PlainPrinter.scala
@@ -7,6 +7,7 @@ import Contexts.Context, Scopes.Scope, Denotations.Denotation, Annotations.Annot
import StdNames.nme
import ast.Trees._, ast.untpd
import java.lang.Integer.toOctalString
+import config.Config.summarizeDepth
import scala.annotation.switch
class PlainPrinter(_ctx: Context) extends Printer {
@@ -15,7 +16,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
protected def maxToTextRecursions = 100
protected final def controlled(op: => Text): Text =
- if (ctx.toTextRecursions < maxToTextRecursions)
+ if (ctx.toTextRecursions < maxToTextRecursions && ctx.toTextRecursions < maxSummarized)
try {
ctx.toTextRecursions += 1
op
@@ -23,12 +24,13 @@ class PlainPrinter(_ctx: Context) extends Printer {
ctx.toTextRecursions -= 1
}
else {
- recursionLimitExceeded()
+ if (ctx.toTextRecursions >= maxToTextRecursions)
+ recursionLimitExceeded()
"..."
}
protected def recursionLimitExceeded() = {
- ctx.warning("Exceeded recursion depth attempting to print type.")
+ ctx.warning("Exceeded recursion depth attempting to print.")
(new Throwable).printStackTrace
}
@@ -393,6 +395,17 @@ class PlainPrinter(_ctx: Context) extends Printer {
}
}.close // todo: override in refined printer
+ private var maxSummarized = Int.MaxValue
+
+ def summarized[T](depth: Int)(op: => T): T = {
+ val saved = maxSummarized
+ maxSummarized = ctx.toTextRecursions + depth
+ try op
+ finally maxSummarized = depth
+ }
+
+ def summarized[T](op: => T): T = summarized(summarizeDepth)(op)
+
def plain = this
}