@@ -11,7 +11,6 @@ import typer.ImportInfo
1111import Variances .varianceSign
1212import util .SourcePosition
1313import java .lang .Integer .toOctalString
14- import config .Config .summarizeDepth
1514import scala .util .control .NonFatal
1615import scala .annotation .switch
1716
@@ -23,24 +22,15 @@ class PlainPrinter(_ctx: Context) extends Printer {
2322
2423 protected def maxToTextRecursions : Int = 100
2524
26- protected final def controlled (op : => Text ): Text =
27- if (ctx.base.toTextRecursions < maxToTextRecursions && ctx.base.toTextRecursions < maxSummarized)
28- try {
29- ctx.base.toTextRecursions += 1
30- op
31- }
32- finally
33- ctx.base.toTextRecursions -= 1
34- else {
35- if (ctx.base.toTextRecursions >= maxToTextRecursions)
36- recursionLimitExceeded()
37- " ..."
38- }
25+ protected final def limiter : MessageLimiter = ctx.property(MessageLimiter ).get
3926
40- protected def recursionLimitExceeded (): Unit = {
41- ctx.warning(" Exceeded recursion depth attempting to print." )
42- if (ctx.debug) Thread .dumpStack()
43- }
27+ protected def controlled (op : => Text ): Text = limiter.controlled(op)
28+
29+ def Str (str : String , lineRange : LineRange = EmptyLineRange ): Str =
30+ limiter.register(str)
31+ Texts .Str (str, lineRange)
32+
33+ given stringToText as Conversion [String , Text ] = Str (_)
4434
4535 /** If true, tweak output so it is the same before and after pickling */
4636 protected def homogenizedView : Boolean = ctx.settings.YtestPickler .value
@@ -112,7 +102,8 @@ class PlainPrinter(_ctx: Context) extends Printer {
112102 /** Pretty-print comma-separated type arguments for a constructor to be inserted among parentheses or brackets
113103 * (hence with `GlobalPrec` precedence).
114104 */
115- protected def argsText (args : List [Type ]): Text = atPrec(GlobalPrec ) { Text (args.map(arg => argText(arg) ), " , " ) }
105+ protected def argsText (args : List [Type ]): Text =
106+ atPrec(GlobalPrec ) { Text (args.map(arg => argText(arg) ), " , " ) }
116107
117108 /** The longest sequence of refinement types, starting at given type
118109 * and following parents.
@@ -573,17 +564,6 @@ class PlainPrinter(_ctx: Context) extends Printer {
573564 case _ => " {...}"
574565 s " import $exprStr. $selectorStr"
575566
576- private var maxSummarized = Int .MaxValue
577-
578- def summarized [T ](depth : Int )(op : => T ): T = {
579- val saved = maxSummarized
580- maxSummarized = ctx.base.toTextRecursions + depth
581- try op
582- finally maxSummarized = saved
583- }
584-
585- def summarized [T ](op : => T ): T = summarized(summarizeDepth)(op)
586-
587567 def plain : PlainPrinter = this
588568
589569 protected def keywordStr (text : String ): String = coloredStr(text, SyntaxHighlighting .KeywordColor )
0 commit comments