Package 

Interface KSFunctionDeclaration

  • All Implemented Interfaces:
    com.google.devtools.ksp.symbol.KSAnnotated , com.google.devtools.ksp.symbol.KSDeclaration , com.google.devtools.ksp.symbol.KSDeclarationContainer , com.google.devtools.ksp.symbol.KSExpectActual , com.google.devtools.ksp.symbol.KSModifierListOwner , com.google.devtools.ksp.symbol.KSNode

    
    public interface KSFunctionDeclaration
     implements KSDeclaration, KSDeclarationContainer
                        

    A function definition

    Dispatch receiver can be obtained through parentDeclaration.

    To obtain the function signature where type arguments are resolved as member of a given KSType, use Resolver.asMemberOf.

    • 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 KSDeclaration findOverridee() Find the closest overridee of this function, if overriding.
      abstract KSFunction asMemberOf(KSType containing) Returns the type of the function when it is viewed as member of the containing type.
      abstract FunctionKind getFunctionKind() Kind of this function.
      abstract Boolean isAbstract() Whether this function is abstract.
      abstract KSTypeReference getExtensionReceiver() Extension receiver of this function
      abstract KSTypeReference getReturnType() Return type of this function.
      abstract List<KSValueParameter> getParameters() value parameters of this function.
      • 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 com.google.devtools.ksp.symbol.KSDeclarationContainer

        getDeclarations
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • findOverridee

         abstract KSDeclaration findOverridee()

        Find the closest overridee of this function, if overriding.

        For the following input:

        abstract class A {
          open fun x() {}
          open fun y() {}
        }
        abstract class B : A() {
          override open fun x() {}
        }
        abstract class C : B() {
          override open fun x() {}
          override open fun y() {}
        }

        Calling findOverridee on C.x will return B.x. Calling findOverridee on C.y will return A.y.

        When there are multiple super interfaces implementing the function, the closest declaration to the current containing declaration is selected. If they are in the same level, the function of the first specified interface (in source) will be returned.

      • asMemberOf

         abstract KSFunction asMemberOf(KSType containing)

        Returns the type of the function when it is viewed as member of the containing type.

        For instance, for the following input:

        interface Base<T> {
          fun f(t:T?):T
        }
        val foo: Base<Int>
        val bar: Base<String>

        When f() is viewed as member of foo, this method will return a KSFunction where the KSFunction.returnType is Int and the parameter t is of type Int?. When f() is viewed as member of bar, this method will return a KSFunction where the KSFunction.returnType is String and the parameter t is of type String?.

        If the function has type parameters, they'll not be resolved and can be read from KSFunction.typeParameters.

        If the substitution fails (e.g. if containing is an error type, a KSFunction with KSFunction.isError true is returned.

        Parameters:
        containing - The type that contains function.