Are there any resources to read about the new fron...
# compiler
r
Are there any resources to read about the new frontend IR? I’m mostly interested in knowing if certain compiler extensions stop working. Does the new frontend still work with Psi?
👀 2
Oh, I just saw the thread above, which is gold https://kotlinlang.slack.com/archives/C7L3JB43G/p1615453039009500?thread_ts=1615394755.006000&cid=C7L3JB43G So it seems like PSI will still work. Because of that I don’t see a reason why
AnalysisHandlerExtension
should no longer work.
d
In new frontend PSI is used only for building FIR (and there is a mode which not using PSI at all), so old frontend extensions (including
AnalysisHandlerExtension
) won't work anymore
We plan to implement brand new API for compiler plugins (and already have a prototype of it), and there will be announcement when it will be done and ready as alpha preview
If you interested in existing prototype you can check its sources here: https://github.com/JetBrains/kotlin/tree/master/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/extensions
r
Does that mean existing tools that use
AnalysisHandlerExtension
such as KSP and Arrow Meta's Quotes API will need to be rewritten?
d
Yes. And developers of those tools are aware of it cc @raulraja, @Jiaxiang
👍 3
r
Interesting. What I liked about the
AnalysisHandlerExtension
was that you could generate new Kotlin files and even let the IDE index these generated files. It seems like it’s no longer possible with the current prototype. Also, generating new source code in any arbitrary format or data structures is a lot harder than relying on frameworks like KotlinPoet.
d
AFAIK there are a lot of tough places with integration of compiler plugins with IDE, and we design new plugin API to support plugins in IDE out of box (so if someone enables some compiler plugin it just works in IDE without any additional IDE plugins). Part of providing new declarations in existed prototype doesn't fit to this design and will be reworked in future (and IDE support of plugins too). Way of generating bodies of new declarations is an opened question, and we didn't think too much about it. There are at least four possible ways for it: - generating raw source code (as strings) - generating PSI using tools like arrow-meta has - generating FIR - generating IR And believe me, design of code of bodies generation is the easiest part of whole plugin API
😍 4
r
That sounds very exciting. I appreciate the detailed explanation 🙏
1
r
Thanks @dmitriy.novozhilov for clarifying ! Very exciting indeed!