Skip to content

Instantly share code, notes, and snippets.

@Morfly
Last active July 18, 2021 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Morfly/dac5f35b7d564c39bd14f3bc3a33aa1b to your computer and use it in GitHub Desktop.
Save Morfly/dac5f35b7d564c39bd14f3bc3a33aa1b to your computer and use it in GitHub Desktop.
override fun visitClassDeclaration(classDeclaration: KSClassDeclaration, data: Unit) {
if (classDeclaration.classKind != ClassKind.INTERFACE) {
logger.error("Only interface can be annotated with @Function", classDeclaration)
return
}
// Getting the @Function annotation object.
val annotation: KSAnnotation = classDeclaration.annotations.first {
it.shortName.asString() == "Function"
}
// Getting the 'name' argument object from the @Function.
val nameArgument: KSValueArgument = annotation.arguments
.first { arg -> arg.name?.asString() == "name" }
// Getting the value of the 'name' argument.
val functionName = nameArgument.value as String
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment