KaSymbol
A base interface of the symbol hierarchy.
Members
val location: KaSymbolLocation
A symbol location kind (e.g., top-level or class member).
val origin: KaSymbolOrigin
A place the symbol comes from (e.g., a source, a library, or a compiler plugin).
val psi: PsiElement?
A PSI element corresponding to the declaration. Might be
null
for certain, usually synthetic, origins.fun createPointer(): KaSymbolPointer<KaSymbol>
Create a declaration pointer which can be used to retrieve the symbol back in another
KaSession
.
Relation utilities
val KaSymbol.containingSymbol: KaSymbol?
A containing symbol:
For top-level declarations, a
KaFileSymbol
, or aKaScriptSymbol
if the file is a script file;For scripts, a
KaFileSymbol
;For class members, a containing class;
For local declarations, a declaration it was declared in.
val KaSymbol.containingDeclaration: KaDeclarationSymbol?
A containing declaration:
For top-level declarations, a containing
KaScriptSymbol
ornull
for non-script declarations;For class members, a containing class;
For local declarations, a declaration it was declared in.
val KaSymbol.containingFile: KaFileSymbol?
The containing file symbol, or
null
if the given file symbol is already aKaFileSymbol
.val KaSymbol.containingModule: KaModule
The containing module.
Other utilities
val KaSymbol.deprecationStatus: DeprecationInfo?
Deprecation status for the given symbol, or
null
if the declaration is not deprecated.Experimental API.
fun KaSymbol.deprecationStatus(annotationUseSiteTarget: AnnotationUseSiteTarget?): DeprecationInfo?
Deprecation status for the given symbol related to the specified annotation use-site target, or
null
if the declaration is not deprecated.Experimental API.
KaSymbolLocation
The location
property indicates the relation between the declaration represented by a symbol and its container (a file, a class, etc.).
Member | Description |
---|---|
| A declaration placed directly in a file, or in a script. |
| A member of some class, object, or interface. |
| A part of some property declaration (e.g., an accessor or a backing field). |
| A declaration inside some callable declaration body. |
KaSymbolOrigin
The origin
property indicates the origin of the symbol. Below you can find a comprehensive list of possible KaSymbolOrigin
values and their descriptions.
Member | Description |
---|---|
| A declaration directly written in Kotlin source code. Examples: Classes, functions, properties, and other declarations defined in Kotlin source files. |
| A declaration automatically generated by the Kotlin compiler as a member of another declaration. Examples:
|
| A declaration from a compiled Kotlin library ( Examples: Classes, functions, properties, and other declarations defined in Kotlin source files. |
| A declaration from Java source code. Examples: Classes, methods, and fields defined in Java source files. |
| A declaration from a compiled Java library. Examples: Classes, methods, and fields from Java libraries, or from the JDK. |
| A synthetic function generated by the SAM (Single Abstract Method) conversion. This occurs when a lambda expression is passed as an argument where a functional interface is expected. Example:
val runnable = Runnable {
println("Hello")
}
In this case, the lambda expression is converted to a synthetic function that implements the |
| A synthetic declaration automatically created by the Kotlin compiler for callable intersections. Example:
interface A { fun x() }
interface B { fun x() }
interface C : A, B
In |
| A synthetic declaration automatically created by the Kotlin compiler for callable type substitutions. Example:
interface A<T> { fun x(): T }
interface B : A<Int>
Interface |
| A member generated by the compiler for interface delegation. This occurs when a class delegates the implementation of an interface to another object. Example:
interface MyInterface {
fun perform()
}
class MyClass(private val delegate: MyInterface) : MyInterface by delegate
The compiler generates a member function |
| A synthetic property generated by the compiler for a Java field with a getter or setter. This allows Java fields to be accessed like Kotlin properties. Example:
public class JavaClass {
private int field;
public int getField() {
return field;
}
public void setField(int field) {
this.field = field;
}
}
The compiler generates a synthetic property |
| A backing field of a property declaration (a field that stores the value of the property). Example:
class MyClass {
var property: Int = 0
get() = field
set(value) { field = value }
}
The |
| A declaration generated by a compiler plugin. |
| A declaration from a dynamic Kotlin/JS scope. |
| A Kotlin/Native forward declaration. See the forward declarations section in the Kotlin documentation. |