Skip to content

BuilderByPattern

A builder that assembles a createByPattern pattern step by step, appending fixed text, expressions, type references, names, and child ranges in order and tracking their placeholders automatically.

Use it through the KtPsiFactory.build* entry points (such as KtPsiFactory.buildExpression), which create a builder, run the configuration block on it, and parse the result into an element.

Type Parameters

  • TElement: the kind of element the assembled pattern produces

Constructors

BuilderByPattern

constructor()

Type Parameters

  • TElement: the kind of element the assembled pattern produces

Functions

appendChildRange

Appends the given child range as an argument.

appendExpression

Appends expression as an argument, or nothing if it is null.

appendExpressions

fun appendExpressions(expressions: Iterable<KtExpression?>, separator: String = ","): BuilderByPattern<TElement>

Appends the given expressions, placing separator between each pair of iterable positions. A null position emits no expression but still participates in separator placement, so null entries can produce leading, trailing, or repeated separators.

appendFixedText

Appends literal text to the pattern verbatim (no placeholder).

appendName

Appends name as an argument, rendered as text.

appendNonFormattedText

Appends text as an argument spliced in as-is, without reformatting.

appendTypeReference

Appends typeRef as an argument, or nothing if it is null.

create

fun create(factory: (String, Array<out Any>) -> TElement): TElement

Builds the element by passing the assembled pattern and arguments to factory.