KaSymbolProvider¶
@SubclassOptInRequired(markerClass = [KaSessionComponentImplementationDetail::class])
interface KaSymbolProvider : KaSessionComponent
KaSymbolProvider provides KaSymbols for given PSI elements.
Important: Symbols can be created only for elements which are a part of the current KaSession.
See also¶
Inheritors¶
Properties¶
classSymbol¶
abstract val KtClassOrObject.classSymbol: KaClassSymbol?
A KaClassSymbol for the given KtClassOrObject, or null for KtEnumEntry declarations.
To retrieve a KaEnumEntrySymbol, please refer to KtEnumEntry.symbol.
namedClassSymbol¶
abstract val KtClassOrObject.namedClassSymbol: KaNamedClassSymbol?
A KaNamedClassSymbol for the given named KtClassOrObject, or null for KtEnumEntry declarations and object literals.
rootPackageSymbol¶
abstract val rootPackageSymbol: KaPackageSymbol
A KaPackageSymbol for the root package, which is the special package with an empty fully-qualified name.
symbol¶
abstract 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.
abstract 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.
abstract val KtNamedFunction.symbol: KaFunctionSymbol
A KaFunctionSymbol for the given KtNamedFunction.
If KtNamedFunction.getName is null, the symbol is a KaAnonymousFunctionSymbol, and otherwise a KaNamedFunctionSymbol.
abstract val KtConstructor<*>.symbol: KaConstructorSymbol
A KaConstructorSymbol for the given KtConstructor.
abstract val KtTypeParameter.symbol: KaTypeParameterSymbol
A KaTypeParameterSymbol for the given KtTypeParameter.
abstract val KtTypeAlias.symbol: KaTypeAliasSymbol
A KaTypeAliasSymbol for the given KtTypeAlias.
abstract val KtEnumEntry.symbol: KaEnumEntrySymbol
A KaEnumEntrySymbol for the given KtEnumEntry.
abstract val KtFunctionLiteral.symbol: KaAnonymousFunctionSymbol
A KaAnonymousFunctionSymbol for the given KtFunctionLiteral.
abstract 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.
abstract val KtBackingField.symbol: KaBackingFieldSymbol
A KaBackingFieldSymbol for the given KtBackingField.
abstract val KtObjectLiteralExpression.symbol: KaAnonymousObjectSymbol
A KaAnonymousObjectSymbol for the given KtObjectLiteralExpression.
abstract 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.
abstract val KtPropertyAccessor.symbol: KaPropertyAccessorSymbol
A KaPropertyAccessorSymbol for the given KtPropertyAccessor.
abstract val KtClassInitializer.symbol: KaClassInitializerSymbol
A KaClassInitializerSymbol for the given KtClassInitializer.
abstract 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.
abstract val KtDestructuringDeclaration.symbol: KaDestructuringDeclarationSymbol
A KaDestructuringDeclarationSymbol for the given KtDestructuringDeclaration.
abstract val KtFile.symbol: KaFileSymbol
A KaFileSymbol for a KtFile.
abstract val KtScript.symbol: KaScriptSymbol
A KaScriptSymbol for a KtScript.
abstract 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.
token¶
abstract val token: KaLifetimeToken
The KaLifetimeToken which determines the lifetime of the lifetime owner.
Functions¶
assertIsValidAndAccessible¶
inline fun KaLifetimeOwner.assertIsValidAndAccessible()
findClass¶
abstract fun findClass(classId: ClassId): KaClassSymbol?
Returns a KaClassSymbol for the specified ClassId, or null if such a symbol cannot be found.
findClassLike¶
abstract fun findClassLike(classId: ClassId): KaClassLikeSymbol?
Returns a KaClassLikeSymbol for the specified ClassId, or null if such a symbol cannot be found.
The function combines both class search (see findClass) and type alias search (see findTypeAlias).
findPackage¶
abstract fun findPackage(fqName: FqName): KaPackageSymbol?
Returns a KaPackageSymbol corresponding to the given fqName if that package exists and is visible from the current use site, or null otherwise.
findTopLevelCallables¶
abstract fun findTopLevelCallables(packageFqName: FqName, name: Name): Sequence<KaCallableSymbol>
Finds top-level functions and properties called name in the package called packageFqName. Returns only symbols that are visible from the current use-site module.
findTypeAlias¶
abstract fun findTypeAlias(classId: ClassId): KaTypeAliasSymbol?
Returns a KaTypeAliasSymbol for the specified ClassId, or null if such a symbol cannot be found.
isValid¶
fun KaLifetimeOwner.isValid(): Boolean
Whether the lifetime owner is still valid, i.e. we are still in the scope of the lifetime owner's regular lifetime.
withValidityAssertion¶
inline fun <R> KaLifetimeOwner.withValidityAssertion(action: () -> R): R
Executes action only if the KaLifetimeOwner is still valid and accessible. Otherwise, throws a validity exception based on the concrete violation.