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.
-
-
Method Summary
Modifier and Type Method Description abstract KSDeclarationfindOverridee()Find the closest overridee of this function, if overriding. abstract KSFunctionasMemberOf(KSType containing)Returns the type of the function when it is viewed as member of the containing type. abstract FunctionKindgetFunctionKind()Kind of this function. abstract BooleanisAbstract()Whether this function is abstract. abstract KSTypeReferencegetExtensionReceiver()Extension receiver of this function abstract KSTypeReferencegetReturnType()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
-
-
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
findOverrideeonC.xwill returnB.x. CallingfindOverrideeonC.ywill returnA.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 offoo, this method will return a KSFunction where the KSFunction.returnType isIntand the parametertis of typeInt?. Whenf()is viewed as member ofbar, this method will return a KSFunction where the KSFunction.returnType isStringand the parametertis of typeString?.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
trueis returned.- Parameters:
containing- The type that contains function.
-
getFunctionKind
abstract FunctionKind getFunctionKind()
Kind of this function.
-
isAbstract
abstract Boolean isAbstract()
Whether this function is abstract.
-
getExtensionReceiver
abstract KSTypeReference getExtensionReceiver()
Extension receiver of this function
-
getReturnType
abstract KSTypeReference getReturnType()
Return type of this function. Can be null if an error occurred during resolution.
-
getParameters
abstract List<KSValueParameter> getParameters()
value parameters of this function.
-
-
-
-