-
- 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 BooleanisMutable()True if this property is mutable. abstract BooleangetHasBackingField()True if this property has a backing field. -
Methods inherited from class com.google.devtools.ksp.symbol.KSNode
accept, getLocation, getOrigin, getParent -
Methods inherited from class com.google.devtools.ksp.symbol.KSExpectActual
findActuals, findExpects, isActual, isExpect -
Methods inherited from class com.google.devtools.ksp.symbol.KSDeclaration
getContainingFile, getDocString, getPackageName, getParentDeclaration, getQualifiedName, getSimpleName, getTypeParameters -
Methods inherited from class com.google.devtools.ksp.symbol.KSModifierListOwner
getModifiers -
Methods inherited from class com.google.devtools.ksp.symbol.KSAnnotated
getAnnotations -
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.
-
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
-
-
-
-