Package 

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.

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

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

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

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