Can we run ksp plugin on raw input string of sourc...
# ksp
k
Can we run ksp plugin on raw input string of source code?
y
You mean Android raw resources or just some const string in code?
k
Just some constant string. Imagine there will be some IDE plugin or desktop app getting some source code and we want to generate something by parsing this code. I’m trying to utilize tokenization from ksp, a string of source code should give me something like this which I could use to write generation code
y
You will need some annotation somewhere that references the class/file and then you should be able to find it. And i "think" we had an API to get the value of a property if it is constant but I'm not 100% sure
j
we can only do this on annotation argument values, or returns true/false about if a property declares default value.
k
Yes, the input string of source code will have target annotation, just want to understand if I could invoke code generator on demand at runtime or execute as java command
j
what do you mean by at runtime or as java command? We do have a command line artifact.
k
To give one example, let’s say I have some tool, could be desktop app / web app which will take Kotlin Annotated Code as input from some textbox, and I want to generate json file out of it. To be able write json properly, I need kotlin code parser, which when provided with source code string, will give me something like this.
I think I’m looking for something like this