The base class of all printers
- Companion:
- object
Value members
Abstract methods
Textual description of regular annotation in terms of its tree
Textual description of regular annotation in terms of its tree
Textual representation of single denotation's declaration
Textual representation of single denotation's declaration
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.
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 ""
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
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.
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.
Textual representation of all definitions in a scope using dclText
for each
Textual representation of all definitions in a scope using dclText
for each
Textual representation of info relating to an import clause
Textual representation of info relating to an import clause
Textual representation of a prefix of some reference, ending in .
or #
Textual representation of a prefix of some reference, ending in .
or #
Concrete methods
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]use
toText(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.
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'
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
.