Is there an official library/api to manipularte A...
# compiler
a
Is there an official library/api to manipularte ASTs of Kotlin source, in a similar fashion as JavaParser does? (javaparser.org)
e
Kotlin supports compiler plugins that gives you access to FIR, which is similar to the AST. You can generate more FIR with
FirDeclarationGenerationExtension
, but I’m not sure about manipulating existing FIR. However, you can manipulate IR, which is the representation built from FIR.
What exactly are you trying to achieve?
a
thanks. one of the goals is to perform analysis of kotlin code using a reasonably high-level abstraction (like JavaParser)
e
For analysis only, I think you’re better off with PSI. You may check how detekt does it.
🙏 1
Check this video for more info:

https://youtu.be/db19VFLZqJM?t=431

a
apparently FIR is something close to what I was looking for