I have an annotation for data classes that I use t...
# ksp
j
I have an annotation for data classes that I use to generate an enum class of all the property it contains and another annotation class
Copy code
annotation class AnnotationA

@AnnotationA
data class SomeDataClass(
  val a: String,
  val b: String,
)

// generated code
enum class SomeDataClassProperty {
  A, B
}

annotation class GeneratedAnnotation(property: SomeDataClassProperty)
Later on when I use
GeneratedAnnotation
with
resolver.resolve()
I get the error
<ERROR TYPE>
from the
KSPLogger
and
[ksp] java.lang.IllegalStateException: Required value was null.
from the compiler. And I’m sure the custom annotation is already generated when the processor tries to do the
resolve()
. Am I supposed to do anything special to let ksp know where the annotation is?
d
That sounds like a use case for multiple rounds of processing: https://kotlinlang.org/docs/ksp-multi-round.html
j
Thanks! Is it really down to just return a list of deferred symbols or do I need to pay attention to other stuff in my code? Any tips for the implementation?
j
Just defer the unresolvable symbols to the next round, it will be picked up by KSP again in the next round, note that if there is no new file generated in a round, the processing will still terminate.
j
I tried a bit earlier and it worked yes, it was quite simple to fix 🙂