CallableBuilder¶
class CallableBuilder(target: KtPsiFactory.CallableBuilder.Target)
A fluent builder for a function, constructor, or read-only property declaration string. The available steps and their order depend on the Target; call asString to obtain the resulting text, then pass it to the matching create* method.
Calls are expected in state order. Order and target violations are checked only when JVM assertions are enabled.
Constructors¶
CallableBuilder¶
constructor(target: KtPsiFactory.CallableBuilder.Target)
Types¶
Companion¶
object Companion
State¶
enum class State : Enum<KtPsiFactory.CallableBuilder.State>
The stages in the expected order for building a callable.
Target¶
enum class Target : Enum<KtPsiFactory.CallableBuilder.Target>
The kind of callable being built.
Functions¶
asString¶
blockBody¶
fun blockBody(@NonNls body: String): KtPsiFactory.CallableBuilder
Appends a block body containing the given body text (a getter block for a property).
getterExpression¶
fun getterExpression(@NonNls expression: String, breakLine: Boolean = true): KtPsiFactory.CallableBuilder
Appends an expression-body getter (get() = expression). Read-only properties only.
initializer¶
fun initializer(@NonNls body: String): KtPsiFactory.CallableBuilder
Appends an initializer (= body). Read-only properties only.
lazyBody¶
fun lazyBody(@NonNls body: String): KtPsiFactory.CallableBuilder
Appends a lazy delegate (by kotlin.lazy { body }). Read-only properties only.
modifier¶
fun modifier(modifier: String): KtPsiFactory.CallableBuilder
Appends modifier verbatim. No separator is added between repeated calls, so callers must include any required whitespace. This is expected to be called before typeParams.
name¶
fun name(@NonNls name: String = CONSTRUCTOR_NAME): KtPsiFactory.CallableBuilder
Appends the callable name (defaulting to the constructor pseudo-name), opening the parameter list for functions and constructors.
noReturnType¶
Closes the parameter list (if any) without appending a return type.
param¶
fun param(
@NonNls name: String,
@NonNls type: String,
@NonNls defaultValue: String? = null
): KtPsiFactory.CallableBuilder
Appends a value parameter with the given name, type, and optional defaultValue. Functions and constructors only.
receiver¶
fun receiver(@NonNls receiverType: String): KtPsiFactory.CallableBuilder
Appends the extension receiver type.
returnType¶
fun returnType(@NonNls type: String): KtPsiFactory.CallableBuilder
Closes the parameter list (if any) and appends the return type.
superDelegation¶
fun superDelegation(@NonNls argumentList: String): KtPsiFactory.CallableBuilder
Appends a : super(...) delegation call with the given argumentList. Constructors only.
transform¶
fun transform(f: StringBuilder.() -> Unit)
Applies an arbitrary transformation to the underlying text buffer.
typeConstraints¶
fun typeConstraints(values: Collection<String>): KtPsiFactory.CallableBuilder
Appends the where clause type constraints, if any. Not allowed for constructors.
typeParams¶
fun typeParams(values: Collection<String> = emptyList()): KtPsiFactory.CallableBuilder
Appends the declaration keyword (fun/val) and the type parameters, if any.