-
- All Implemented Interfaces:
-
com.google.devtools.ksp.symbol.KSAnnotated,com.google.devtools.ksp.symbol.KSDeclaration,com.google.devtools.ksp.symbol.KSExpectActual,com.google.devtools.ksp.symbol.KSModifierListOwner,com.google.devtools.ksp.symbol.KSNode
public interface KSPropertyDeclaration implements KSDeclaration
A property declaration, can also be used to denote a variable declaration.
-
-
Method Summary
Modifier and Type Method Description abstract BooleanisDelegated()Indicates whether this is a delegated property. abstract KSPropertyDeclarationfindOverridee()Find the closest overridee of this property, if overriding. abstract KSTypeasMemberOf(KSType containing)Returns the type of the property when it is viewed as member of the containing type. abstract KSPropertyGettergetGetter()Getter of the property. abstract KSPropertySettergetSetter()Setter of the property. abstract KSTypeReferencegetExtensionReceiver()Extension receiver if this declaration is an https://kotlinlang.org/docs/reference/extensions. abstract KSTypeReferencegetType()The type of this declaration. abstract BooleangetIsMutable()True if this property is mutable. abstract BooleangetHasBackingField()True if this property has a backing field. abstract KSNamegetSimpleName()Simple name of this declaration, usually the name identifier at the declaration site. abstract KSNamegetQualifiedName()Fully qualified name of this declaration, might not exist for some declarations like local declarations. abstract List<KSTypeParameter>getTypeParameters()List of type parameters of the declaration. abstract KSNamegetPackageName()The name of the package at which this declaration is declared. abstract KSDeclarationgetParentDeclaration()Parent declaration of this declaration, i.e. abstract KSFilegetContainingFile()The containing source file of this declaration, can be null if symbol does not come from a source file, i.e. abstract StringgetDocString()The doc string enclosed by \/\*\* and \*\/ abstract Set<Modifier>getModifiers()The set of modifiers on this element. abstract OrigingetOrigin()abstract LocationgetLocation()abstract KSNodegetParent()abstract Sequence<KSAnnotation>getAnnotations()All annotations on this symbol. abstract BooleangetIsActual()True if this is an actualimplementation.abstract BooleangetIsExpect()True if this is an expectdeclaration.-
Methods inherited from class com.google.devtools.ksp.symbol.KSModifierListOwner
accept -
Methods inherited from class com.google.devtools.ksp.symbol.KSDeclaration
findActuals, findExpects -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
isDelegated
abstract Boolean isDelegated()
Indicates whether this is a delegated property.
-
findOverridee
abstract KSPropertyDeclaration findOverridee()
Find the closest overridee of this property, if overriding.
For the following input:
abstract class A { open val x:Int open val y:Int } abstract class B : A() { override val x:Int } abstract class C : B() { override val x:Int override val y:Int }Calling
findOverrideeonC.xwill returnB.x. CallingfindOverrideeonC.ywill returnA.y.When there are multiple super classes / interfaces with the property, the closest declaration to the current containing declaration is selected. If they are in the same level, the property of the first specified interface (in source) will be returned.
-
asMemberOf
abstract KSType asMemberOf(KSType containing)
Returns the type of the property when it is viewed as member of the containing type.
For instance, for the following input:
class Base<T>(val x:T) val foo: Base<Int> val bar: Base<String>When
xis viewed as member offoo, this method will return the KSType forIntwhereas whenxis viewed as member ofbar, this method will return the KSType representingString.If the substitution fails (e.g. if containing is an error type, a KSType with KSType.isError
trueis returned.- Parameters:
containing- The type that contains property
-
getGetter
abstract KSPropertyGetter getGetter()
Getter of the property. Note that when KSPropertyDeclaration is used to model a variable, getter is always null, as a variable can't have a getter.
-
getSetter
abstract KSPropertySetter getSetter()
Setter of the property. Note that when KSPropertyDeclaration is used to model a variable, setter is always null, as a variable can't have a setter. If a property is immutable, setter is always null as well, as an immutable property can't have a setter.
-
getExtensionReceiver
abstract KSTypeReference getExtensionReceiver()
Extension receiver if this declaration is an https://kotlinlang.org/docs/reference/extensions.html#extension-properties. Dispatch receiver is parentDeclaration, if any.
-
getType
abstract KSTypeReference getType()
The type of this declaration.
-
getIsMutable
abstract Boolean getIsMutable()
True if this property is mutable.
-
getHasBackingField
abstract Boolean getHasBackingField()
True if this property has a backing field.
Note that, this is specific to the current property and does not check for properties that are overridden by this property.
https://kotlinlang.org/docs/properties.html#backing-fields
-
getSimpleName
abstract KSName getSimpleName()
Simple name of this declaration, usually the name identifier at the declaration site.
-
getQualifiedName
abstract KSName getQualifiedName()
Fully qualified name of this declaration, might not exist for some declarations like local declarations.
-
getTypeParameters
abstract List<KSTypeParameter> getTypeParameters()
List of type parameters of the declaration.
-
getPackageName
abstract KSName getPackageName()
The name of the package at which this declaration is declared.
-
getParentDeclaration
abstract KSDeclaration getParentDeclaration()
Parent declaration of this declaration, i.e. the declaration that directly contains this declaration. File is not a declaration, so this property will be null for top level declarations.
-
getContainingFile
abstract KSFile getContainingFile()
The containing source file of this declaration, can be null if symbol does not come from a source file, i.e. from a class file.
-
getDocString
abstract String getDocString()
The doc string enclosed by \/\*\* and \*\/
-
getModifiers
abstract Set<Modifier> getModifiers()
The set of modifiers on this element.
-
getLocation
abstract Location getLocation()
-
getAnnotations
abstract Sequence<KSAnnotation> getAnnotations()
All annotations on this symbol.
-
getIsActual
abstract Boolean getIsActual()
True if this is an
actualimplementation.
-
getIsExpect
abstract Boolean getIsExpect()
True if this is an
expectdeclaration.
-
-
-
-