blob: efddb26f7f13821eed034ef5364dd8096e8590b3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
package dotty.tools.dotc
package printing
import core._
import Contexts._, Texts._, Decorators._
import config.Config.summarizeDepth
import scala.util.control.NonFatal
trait Showable extends Any {
/** The text representation of this showable element.
* This normally dispatches to a pattern matching
* method in Printers.
*/
def toText(printer: Printer): Text
/** 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
/** 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)
}
|