-
- 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 BooleangetIsAbstract()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. abstract KSNamegetSimpleName()Simple name of this declaration, usually the name identifier at the declaration site. abstract KSNamegetQualifiedName()Fully qualified name of this declaration, might not exist for some declarations like local declarations. abstract List<KSTypeParameter>getTypeParameters()List of type parameters of the declaration. abstract KSNamegetPackageName()The name of the package at which this declaration is declared. abstract KSDeclarationgetParentDeclaration()Parent declaration of this declaration, i.e. abstract KSFilegetContainingFile()The containing source file of this declaration, can be null if symbol does not come from a source file, i.e. abstract StringgetDocString()The doc string enclosed by \/\*\* and \*\/ abstract Set<Modifier>getModifiers()The set of modifiers on this element. abstract OrigingetOrigin()abstract LocationgetLocation()abstract KSNodegetParent()abstract Sequence<KSAnnotation>getAnnotations()All annotations on this symbol. abstract BooleangetIsActual()True if this is an actualimplementation.abstract BooleangetIsExpect()True if this is an expectdeclaration.abstract Sequence<KSDeclaration>getDeclarations()Declarations that are lexically declared inside the current container. -
Methods inherited from class com.google.devtools.ksp.symbol.KSModifierListOwner
accept -
Methods inherited from class com.google.devtools.ksp.symbol.KSDeclaration
findActuals, findExpects -
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.
-
getIsAbstract
abstract Boolean getIsAbstract()
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.
-
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.
-
getTypeParameters
abstract List<KSTypeParameter> getTypeParameters()
List of type parameters of the declaration.
-
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.
-
getDocString
abstract String getDocString()
The doc string enclosed by \/\*\* and \*\/
-
getModifiers
abstract Set<Modifier> getModifiers()
The set of modifiers on this element.
-
getLocation
abstract Location getLocation()
-
getAnnotations
abstract Sequence<KSAnnotation> getAnnotations()
All annotations on this symbol.
-
getIsActual
abstract Boolean getIsActual()
True if this is an
actualimplementation.
-
getIsExpect
abstract Boolean getIsExpect()
True if this is an
expectdeclaration.
-
getDeclarations
abstract Sequence<KSDeclaration> getDeclarations()
Declarations that are lexically declared inside the current container.
-
-
-
-