Hello everyone! Iam receiving an error when callin...
# ksp
a
Hello everyone! Iam receiving an error when calling
KSName.asString()
. What is strange is that I had a working version of my processor but after a few changes in the project structure (moved classes do different packages and so on) this error is now happening. I am basically trying to get the qualified name or the simple name of a Kotlin annotation class. Basically this is the code:
Copy code
annotation as KSAnnotation
val declaration = annotation.annotationType.resolve().declaration
val qualifiedName = (declaration.qualifiedName ?: declaration.simpleName).asString()

val className = ClassName.bestGuess(qualifiedName)
If I print
declaration
I can already see the string “Error type synthetic declaration”
One thing to consider is that now this annotation class lives alone in it’s own file. Before, it was sharing a file with some other annotation classes in another package
y
If the declaration is an error, looks like it is but resolved
So maybe missing imports in the processed app?
a
Indeed. Right on the spot. There was some wrong/missing imports which were not updated with the refactor.
I guess as the KSP errors were happening before the compiler reached the classes without the fixed imports I did not noticed that.
y
Ksp runs before the compilation of the app
a
Thanks for the help @yigit! I was trying to do some annotation processing with kapt and was struggling a lot to get annotations of a property from an interface. With KSP it just works! You guys are doing an awesome job!
By the way, is there a way to log/print inside the SymbolProcessor? Tried with
println()
and the logger provided in the
init()
but no luck. I am throwing exceptions as a form of log
y
I used to use println, was work fine. Did you try running from the command line?
a
No, I am running it by running the gradle build task
through intellij
y
Gradlew console should show the printlns, you might need --info.
a
I’ll try that