Hi! I'm trying to build my first annotation processor, is there a way to get a `KClass` from a `KSCl...
t
Hi! I'm trying to build my first annotation processor, is there a way to get a
KClass
from a
KSClassDeclaration
?
In context, I'm using KotlinPoet to build my file, but I need to add a type param to the class I'm generating based on the annotated class
Copy code
TypeSpec.objectBuilder(className)
    .addSuperinterface(CommandAction::class.parameterizedBy(classDeclaration.getKClass())) // how do i do this?
    .build()
e
KotlinPoet does not “need” a KClass, its API is
ClassName
or the more general
TypeName
, it just turns out one of the ways to get a class name is via the short cut on KClass. A ClassName is just a class package + its name, both of those info you can get from KSClassDeclaration
t
alright, thank you!