Skip to content

KaRenderer

Renders Analysis API entities such as KaSymbols or KaTypes into a KaRenderingOutput as human-readable, Kotlin-like text.

A renderer is an immutable bundle of KaPieceRenderers (a stack per KaPiece) together with KaRenderingOption values. You can obtain the standard renderer via default and derive customized variants with copy.

Types

Companion

object Companion

Functions

copy

abstract fun copy(block: KaRendererBuilder.() -> Unit): KaRenderer

Returns a copy of this renderer with the customizations applied by block (overriding KaRenderingOptions or pushing additional KaPieceRenderers). This renderer is left unchanged.

The resulting renderer may call the block on-demand. Never rely on exact timing of its call, and keep the block free of side effects.

render

context(session: KaSession)
abstract fun <T> render(
    value: T, 
    piece: KaPiece<T>, 
    output: KaRenderingOutput
)

Renders the given piece value into the output.

render

context(session: KaSession)
fun KaRenderer.render(symbol: KaSymbol, output: KaRenderingOutput)

Renders the symbol into output.

context(session: KaSession)
fun KaRenderer.render(type: KaType, output: KaRenderingOutput)

Renders the type into output.

context(session: KaSession, context: KaRenderingContext)
fun <T> render(value: T, piece: KaPiece<T>)

Renders value as the given piece, dispatching to the corresponding renderer stack.

renderToString

context(session: KaSession)
fun KaRenderer.renderToString(symbol: KaSymbol): @NlsSafe String

Renders the symbol into a string.

context(session: KaSession)
fun KaRenderer.renderToString(type: KaType): @NlsSafe String

Renders the type into a string.