Interface KSPropertyDeclaration

  • 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.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      abstract Boolean isDelegated() Indicates whether this is a delegated property.
      abstract KSPropertyDeclaration findOverridee() Find the closest overridee of this property, if overriding.
      abstract KSType asMemberOf(KSType containing) Returns the type of the property when it is viewed as member of the containing type.
      abstract KSPropertyGetter getGetter() Getter of the property.
      abstract KSPropertySetter getSetter() Setter of the property.
      abstract KSTypeReference getExtensionReceiver() Extension receiver if this declaration is an https://kotlinlang.org/docs/reference/extensions.
      abstract KSTypeReference getType() The type of this declaration.
      abstract Boolean isMutable() True if this property is mutable.
      abstract Boolean getHasBackingField() 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
    • Constructor Detail

    • 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 findOverridee on C.x will return B.x. Calling findOverridee on C.y will return A.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.

        Returns:

        KSPropertyDeclaration for the overridden property, if overriding, otherwise null. Calling findOverridee is expensive and should be avoided if possible.

      • 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 x is viewed as member of foo, this method will return the KSType for Int whereas when x is viewed as member of bar, this method will return the KSType representing String.

        If the substitution fails (e.g. if containing is an error type, a KSType with KSType.isError true is 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.

      • 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