KaRenderingOutput¶
interface KaRenderingOutput
A destination for rendered output. A KaRenderer writes text fragments, each tagged with KaTextAttributes that describe its semantic role, so an output may add syntax highlighting, produce plain text, or ignore the attributes entirely.
All methods return this to allow chaining.
Types¶
Companion¶
object Companion
Functions¶
append¶
abstract fun append(text: String, attributes: Set<KaTextAttribute>): KaRenderingOutput
Appends text tagged with the given attributes.
append¶
fun KaRenderingOutput.append(text: String, vararg attributes: KaTextAttribute): KaRenderingOutput
Appends text tagged with the given attributes.
enter¶
group¶
Renders a region which groups a sequence of child pieces of the children kind, such as a value parameter list grouping its KaPiece.ValueParameters.
block renders the entire content of the group, including the enclosing brackets and the separators between the children. The hook lets an output lay the group out as a whole, e.g. to fold it.
An output which needs no special treatment of groups invokes block as it is.
identifier¶
context(session: KaSession, context: KaRenderingContext)
fun KaRenderingOutput.identifier(name: String, symbol: KaSymbol): KaRenderingOutput
context(session: KaSession, context: KaRenderingContext)
fun KaRenderingOutput.identifier(name: Name, symbol: KaSymbol): KaRenderingOutput
Renders name as an identifier, linked to symbol when KaRenderingOption.LinkSymbols is enabled.
keyword¶
context(session: KaSession, context: KaRenderingContext)
fun KaRenderingOutput.keyword(token: KtKeywordToken, trailingSpace: Boolean = true): KaRenderingOutput
Renders token unless it is filtered out by KaRenderingOption.AllowedKeywords.
Parameters
- trailingSpace: whether a space is appended after the keyword. Pass
falsewhen the keyword is directly followed by punctuation, as inconstructor(.
leave¶
newLine¶
abstract fun newLine(): KaRenderingOutput
Starts a new line at the current indentation level.
popIndent¶
abstract fun popIndent(): KaRenderingOutput
Decreases the indentation level. Must be balanced with a preceding pushIndent.
punctuation¶
context(session: KaSession, context: KaRenderingContext)
fun KaRenderingOutput.punctuation(text: String): KaRenderingOutput
Appends text as a KaTextAttribute.Punctuation fragment, such as ( or ..
pushIndent¶
abstract fun pushIndent(): KaRenderingOutput
Increases the indentation level applied at the start of subsequent lines.
space¶
abstract fun space(): KaRenderingOutput
Append a single space unless the last rendered character was a whitespace.
withIndent¶
inline fun KaRenderingOutput.withIndent(block: () -> Unit)
Runs block with the indentation level increased, balancing pushIndent with popIndent.