Is it possible to use KSP to fail the build if cal...
# ksp
e
Is it possible to use KSP to fail the build if callers of an annotated function aren't calling it in a specified way, or is a compiler plugin required for something like that?
b
You can always just throw an error and fail the compilation that way
e
There was an issue with it a while back that I think has been fixed? but logging an error with the ksp api should fail the build. It's also nice that you can pass in the target element and the IDE will point you to it.
e
Cool, thanks! Which API do you use to inspect the caller of an annotated function?
e
@eygraber I dont think ksp can give you that information. Thats expression-level and you’ll need a separate compiler plugin
👍 1
e
if you're not generating code but just checking it, you could consider Android Lint (which can be applied to non-Android projects, http://googlesamples.github.io/android-custom-lint-rules/api-guide/example.md.html#:~:text=com.android.lint )
âž• 2
one of the things it provides is a callback
analyzeCallGraph
e
Interesting. I was thinking I would want it to fail the build, but Lint might actually work better for my purposes. Thanks!
g
Lint can also fail the build if you want, given you use a gradle lint plugin with this feature.
e
If you are just checking kotlin code, I've found detekt easier to deal with than android lint