Skip to content

ValueArgument

interface ValueArgument

Represents a single argument passed in a call, such as foo(1, message = "hi", *array).

A value argument carries the argument expression, an optional argument name (for named arguments), and an optional spread element (for *-spread arguments). It is not itself a KtElement; use asElement to obtain the underlying PSI element. Besides the regular PSI-backed KtValueArgument, synthetic implementations exist for modeling arguments of callable references.

Inheritors

Properties

isSpread

open val isSpread: Boolean

true if this is a spread argument (*array).

See also

Functions

asElement

abstract fun asElement(): KtElement

Returns the underlying PSI element that this argument corresponds to.

getArgumentExpression

Returns the argument expression, or null if it is missing in incomplete code.

getArgumentName

Returns the argument name for a named argument (name = value), or null if this argument is positional.

getSpreadElement

abstract fun getSpreadElement(): LeafPsiElement?

Returns the * spread token for a spread argument (foo(*array), which passes an array as a series of vararg arguments), or null if this argument is not spread.

isExternal

abstract fun isExternal(): Boolean

Returns true if the argument is located outside of the call element, as with the range in a when condition with a subject: when (a) { in c -> }.

isNamed

abstract fun isNamed(): Boolean

Returns true if this is a named argument (name = value).