Hello all, I’m currently playing with KotlinPoet o...
# squarelibraries
a
Hello all, I’m currently playing with KotlinPoet on a jvm desktop app and I’m wondering if its possible to actually edit a existent class with it. usecase: I’m attempting to build an app to bootstrap code for one of our features and it involves editing some classes
z
It doesn’t do any parsing, it just writes. You could use something like KSP to do some high-level parsing and then use kotlin poet to spit out auxiliary source code, or use a full-fledged compiler plugin to rewrite bytecode.
a
The problem with those alternatives is that it would change the way we code our feature. It is an option indeed. Another option would be to call
toString()
from i.e. a TypeSpec and place it inside some file through IO apis, right?
w
Maybe something like what KtLint does would help? It has apis to modify the source, although they're pretty low-level Edit: just read Jake's comment, it's basically PSI so the same thing
👍 1