Skip to content

symbol

A KaDeclarationSymbol for the given KtDeclaration.

There are more specific symbol endpoints, such as KtNamedFunction.symbol and KtClassOrObject.classSymbol, which can be used when more specific PSI elements are available.

context(session: KaSession)
val KtParameter.symbol: KaVariableSymbol

A KaVariableSymbol for the given KtParameter.

Unfortunately, KtParameter in PSI stands for many things, and not all of them are represented by a single type of symbol, so this function does not work for all possible KtParameters.

If KtParameter.isFunctionTypeParameter is true, i.e. if the given KtParameter is used as a function type parameter, it is not possible to create KaValueParameterSymbol, hence an error will be raised.

If KtParameter.isLoopParameter is true, i.e. if the given KtParameter is a loop variable in for expression, then the symbol is KaLocalVariableSymbol.

If KtParameter.isContextParameter is true, i.e. if the given KtParameter is used as a context parameter, then the symbol is KaContextParameterSymbol.

Otherwise, the symbol is KaValueParameterSymbol.

context(session: KaSession)
val KtProperty.symbol: KaVariableSymbol

A KaVariableSymbol for the given KtProperty.

The symbol is a KaKotlinPropertySymbol for non-local properties, and a KaLocalVariableSymbol for local ones.

A KaClassSymbol for the given KtObjectDeclaration.

The symbol may either be a KaAnonymousObjectSymbol if the given declaration is an object expression, or a KaNamedClassSymbol if it is a named object declaration.

A KaVariableSymbol that corresponds to the local variable introduced by the given KtDestructuringDeclarationEntry.

The symbol is usually a KaLocalVariableSymbol. However, for a top-level destructuring declaration in a script, the symbol is a KaKotlinPropertySymbol.

Example

val (x, y) = p

The destructuring declaration above has two entries, one corresponding to x and another to y. For both of these entries, we can retrieve a KaVariableSymbol which describes the entry.

context(session: KaSession)
val KtFile.symbol: KaFileSymbol

A KaFileSymbol for a KtFile.

Represents KtContextReceiver as a KaContextParameterSymbol.

This is a temporary API for simplicity during the transition from context receivers to context parameters.

Note: context receivers inside KtFunctionType are not supported.