RefinedPrinter

class RefinedPrinter(_ctx: Context) extends PlainPrinter
class Printer
class Object
trait Matchable
class Any

Value members

Concrete methods

def addParamssText[T >: Untyped](leading: Text, paramss: List[ParamClause[T]]): Text
override def annotText(annot: Annotation): Text

Usual target for Annotation#toText, overridden in RefinedPrinter

Usual target for Annotation#toText, overridden in RefinedPrinter

Definition Classes
override def fullNameString(sym: Symbol): String

The fully qualified name of the symbol

The fully qualified name of the symbol

Definition Classes
def inPattern(op: => Text): Text
override def kindString(sym: Symbol): String

String representation of symbol's kind.

String representation of symbol's kind.

Definition Classes
override def nameString(name: Name): String

The name, possibly with with namespace suffix if debugNames is set: /L for local names, /V for other term names, /T for type names

The name, possibly with with namespace suffix if debugNames is set: /L for local names, /V for other term names, /T for type names

Definition Classes
def optText(name: Name)(encl: Text => Text): Text
def optText[T >: Untyped](tree: Tree[T])(encl: Text => Text): Text
def optText[T >: Untyped](tree: List[Tree[T]])(encl: Text => Text): Text
def paramsText[T >: Untyped](params: ParamClause[T]): Text
override def plain: PlainPrinter

A plain printer without any embellishments

A plain printer without any embellishments

Definition Classes
override def toText(tp: Type): Text

Textual representation of type

Textual representation of type

Definition Classes
override def toText[T >: Untyped](tree: Tree[T]): Text

Textual representation of tree

Textual representation of tree

Definition Classes
override def toText(sym: Symbol): Text

Textual representation, including symbol's kind e.g., "class Foo", "method Bar". If hasMeaninglessName is true, uses the owner's name to disambiguate identity.

Textual representation, including symbol's kind e.g., "class Foo", "method Bar". If hasMeaninglessName is true, uses the owner's name to disambiguate identity.

Definition Classes
override def toText(denot: Denotation): Text

Textual representation of denotation

Textual representation of denotation

Definition Classes
override def toTextFlags(sym: Symbol): Text

String representation of symbol's flags

String representation of symbol's flags

Definition Classes
override def toTextPrefix(tp: Type): Text

The string representation of this type used as a prefix, including separator

The string representation of this type used as a prefix, including separator

Definition Classes
override def toTextRef(tp: SingletonType): Text

The string representation of this type used as a prefix

The string representation of this type used as a prefix

Definition Classes
def withEnclosingDef(enclDef: Tree[_ >: Untyped])(op: => Text): Text
def withoutPos(op: => Text): Text

Inherited methods

def Str(str: String, lineRange: LineRange): Str
Inherited from:
PlainPrinter
Inherited from:
PlainPrinter
def atPrec(prec: Precedence)(op: => Text): Text

Generate text using op, assuming a given precedence level prec.

Generate text using op, assuming a given precedence level prec.

atPrec vs changePrec

This is to be used when changing precedence inside some sort of parentheses: for instance, to print T[A]usetoText(T) ~ '[' ~ atPrec(GlobalPrec) { toText(A) } ~ ']'`.

If the presence of the parentheses depends on precedence, inserting them manually is most certainly a bug. Use changePrec instead to generate them exactly when needed.

Inherited from:
Printer
def changePrec(prec: Precedence)(op: => Text): Text

Generate text using op, assuming a given precedence level prec. If new level prec is lower than previous level, put text in parentheses.

Generate text using op, assuming a given precedence level prec. If new level prec is lower than previous level, put text in parentheses.

atPrec vs changePrec

To pretty-print A op B, you need something like changePrec(parsing.precedence(op, isType)) { toText(a) ~ op ~ toText(b) } // BUGGY that will insert parentheses around A op B if, for instance, the preceding operator has higher precedence.

But that does not handle infix operators with left- or right- associativity.

If op and op' have the same precedence and associativity, A op B op' C parses as (A op B) op' C if op and op' are left-associative, and as A op (B op' C) if they're right-associative, so we need respectively

val isType = ??? // is this a term or type operator?
val prec = parsing.precedence(op, isType)
// either:
changePrec(prec) { toText(a) ~ op ~ atPrec(prec + 1) { toText(b) } } // for left-associative op and op'
// or:
changePrec(prec) { atPrec(prec + 1) { toText(a) } ~ op ~ toText(b) } // for right-associative op and op'
Inherited from:
Printer

The current precedence level. When pretty-printing arguments of operator op, currentPrecedence must equal op's precedence level, so that pretty-printing expressions using lower-precedence operators can insert parentheses automatically by calling changePrec.

The current precedence level. When pretty-printing arguments of operator op, currentPrecedence must equal op's precedence level, so that pretty-printing expressions using lower-precedence operators can insert parentheses automatically by calling changePrec.

Inherited from:
Printer

Textual representation of single denotation's declaration

Textual representation of single denotation's declaration

Inherited from:
PlainPrinter
def dclText(sym: Symbol): Text

Textual representation of symbol's declaration

Textual representation of symbol's declaration

Inherited from:
PlainPrinter
def dclsText(syms: List[Symbol], sep: String): Text

Textual representation of all symbols in given list, using dclText for displaying each.

Textual representation of all symbols in given list, using dclText for displaying each.

Inherited from:
PlainPrinter

A description of sym's location

A description of sym's location

Inherited from:
PlainPrinter
def homogenize(tp: Type): Type
Inherited from:
PlainPrinter

Textual representation of symbol and its location

Textual representation of symbol and its location

Inherited from:
PlainPrinter

If symbol's owner is a printable class C, the text "in C", otherwise ""

If symbol's owner is a printable class C, the text "in C", otherwise ""

Inherited from:
PlainPrinter

The name of the given symbol. If !settings.debug, the original name where expansions of operators are translated back to operator symbol. E.g. $eq => =. If settings.uniqid, adds id.

The name of the given symbol. If !settings.debug, the original name where expansions of operators are translated back to operator symbol. E.g. $eq => =. If settings.uniqid, adds id.

Inherited from:
PlainPrinter

Textual representation of a constraint

Textual representation of a constraint

Inherited from:
PlainPrinter
def toText(importInfo: ImportInfo): Text

Textual representation of info relating to an import clause

Textual representation of info relating to an import clause

Inherited from:
PlainPrinter
def toText(result: SearchResult): Text

Textual representation of implicit search result

Textual representation of implicit search result

Inherited from:
PlainPrinter

Textual representation of source position

Textual representation of source position

Inherited from:
PlainPrinter
def toText(sc: Scope): Text

Textual representation of all definitions in a scope using dclText for each

Textual representation of all definitions in a scope using dclText for each

Inherited from:
PlainPrinter
def toText(param: LambdaParam): Text

Textual representation of lambda param

Textual representation of lambda param

Inherited from:
PlainPrinter
def toText(annot: Annotation): Text

Textual representation of annotation

Textual representation of annotation

Inherited from:
PlainPrinter
def toText(const: Constant): Text

Textual representation of constant

Textual representation of constant

Inherited from:
PlainPrinter
def toText(name: Name): Text

The name as a text

The name as a text

Inherited from:
PlainPrinter
def toText(elems: Iterable[Showable], sep: String): Text

Render elements alternating with sep string

Render elements alternating with sep string

Inherited from:
Printer

Render elements within lowest precedence

Render elements within lowest precedence

Inherited from:
Printer

Render element within lowest precedence

Render element within lowest precedence

Inherited from:
Printer

Render elements within highest precedence

Render elements within highest precedence

Inherited from:
Printer

Render element within highest precedence

Render element within highest precedence

Inherited from:
Printer

Givens

Inherited givens

Extensions

Extensions

extension (mdef: DefTree)

Print modifiers from symbols if tree has type, overriding the behavior in Trees.

Print modifiers from symbols if tree has type, overriding the behavior in Trees.