symbol¶
context(session: KaSession)
val KtDeclaration.symbol: KaDeclarationSymbol
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 KtNamedFunction.symbol: KaFunctionSymbol
A KaFunctionSymbol for the given KtNamedFunction.
If KtNamedFunction.getName is null, the symbol is a KaAnonymousFunctionSymbol, and otherwise a KaNamedFunctionSymbol.
context(session: KaSession)
val KtConstructor<*>.symbol: KaConstructorSymbol
A KaConstructorSymbol for the given KtConstructor.
context(session: KaSession)
val KtTypeParameter.symbol: KaTypeParameterSymbol
A KaTypeParameterSymbol for the given KtTypeParameter.
context(session: KaSession)
val KtTypeAlias.symbol: KaTypeAliasSymbol
A KaTypeAliasSymbol for the given KtTypeAlias.
context(session: KaSession)
val KtEnumEntry.symbol: KaEnumEntrySymbol
A KaEnumEntrySymbol for the given KtEnumEntry.
context(session: KaSession)
val KtFunctionLiteral.symbol: KaAnonymousFunctionSymbol
A KaAnonymousFunctionSymbol for the given KtFunctionLiteral.
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.
context(session: KaSession)
val KtBackingField.symbol: KaBackingFieldSymbol
A KaBackingFieldSymbol for the given KtBackingField.
context(session: KaSession)
val KtObjectLiteralExpression.symbol: KaAnonymousObjectSymbol
A KaAnonymousObjectSymbol for the given KtObjectLiteralExpression.
context(session: KaSession)
val KtObjectDeclaration.symbol: KaClassSymbol
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.
context(session: KaSession)
val KtPropertyAccessor.symbol: KaPropertyAccessorSymbol
A KaPropertyAccessorSymbol for the given KtPropertyAccessor.
context(session: KaSession)
val KtClassInitializer.symbol: KaClassInitializerSymbol
A KaClassInitializerSymbol for the given KtClassInitializer.
context(session: KaSession)
val KtDestructuringDeclarationEntry.symbol: KaVariableSymbol
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¶
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 KtDestructuringDeclaration.symbol: KaDestructuringDeclarationSymbol
A KaDestructuringDeclarationSymbol for the given KtDestructuringDeclaration.
context(session: KaSession)
val KtFile.symbol: KaFileSymbol
A KaFileSymbol for a KtFile.
context(session: KaSession)
val KtScript.symbol: KaScriptSymbol
A KaScriptSymbol for a KtScript.
context(session: KaSession)
val KtContextReceiver.symbol: KaContextParameterSymbol
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.