BuilderByPattern¶
class BuilderByPattern<TElement>
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¶
fun appendChildRange(range: PsiChildRange): BuilderByPattern<TElement>
Appends the given child range as an argument.
appendExpression¶
fun appendExpression(expression: KtExpression?): BuilderByPattern<TElement>
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¶
fun appendFixedText(text: String): BuilderByPattern<TElement>
Appends literal text to the pattern verbatim (no placeholder).
appendName¶
fun appendName(name: Name): BuilderByPattern<TElement>
Appends name as an argument, rendered as text.
appendNonFormattedText¶
fun appendNonFormattedText(text: String): BuilderByPattern<TElement>
Appends text as an argument spliced in as-is, without reformatting.
appendTypeReference¶
fun appendTypeReference(typeRef: KtTypeReference?): BuilderByPattern<TElement>
Appends typeRef as an argument, or nothing if it is null.
create¶
Builds the element by passing the assembled pattern and arguments to factory.