I'd like to completely parse a kt file, I can see ...
# ksp
e
I'd like to completely parse a kt file, I can see all the top-level declarations in this way:
Copy code
resolver.getAllFiles().first { it.fileName == "terraform.kt" }.declarations
but for functions, I can't "enter" and see the body, that is all the declarations inside is it a visitor mandatory?
j
you should be able to see top level declarations inside a function body, but no more than that. Function body parsing isn’t supported by KSP.
e
pity, thanks are you aware of some alternative for me?
j
Unfortunately, no.
n
You can write a compiler plugin but probably it's not worth to do...
j
if you are only interested in the text then maybe you can try to get the file location and load it with system API..
e
what do you mean by system API?
j
java.io.File