https://kotlinlang.org logo
#k2-early-adopters
Title
# k2-early-adopters
j

Johann Pardanaud

10/23/2023, 3:27 PM
I have another question, about code generation. • With KSP, you can only create new top-level declarations, and it happens only on compilation. • With K2, you can alter the IR to add/remove/edit all declarations. If I create a new declaration inside a K2 plugin compiler, would it be available for IntelliJ's autocompletion without triggering any compilation?
j

jvmusin

10/23/2023, 3:31 PM
I doubt this info will be available for IJ even after compilation, as your sources will not be altered, only the compiled bytecode will. You will need your own IJ plugin to support this stuff.
j

Johann Pardanaud

10/23/2023, 3:32 PM
OK, I was wondering if the altered IR was given back to IntelliJ for further analysis.
nono 1
j

Javier

10/23/2023, 3:39 PM
You need to use FIR for that
j

Johann Pardanaud

10/23/2023, 3:42 PM
Oh! So it is possible?
j

Javier

10/23/2023, 3:43 PM
Not with only IR, first you need to add those new members with FIR, later fill the body of those new members in IR
j

Johann Pardanaud

10/23/2023, 3:43 PM
that would be perfect 🙂
j

Javier

10/23/2023, 3:44 PM
And FIR is not still stable and usable on normal IDEs, you need to compile IDEA in order to try it and so on.
But if your project is not for right now, then give it a try
j

Johann Pardanaud

10/23/2023, 3:45 PM
wow, I was not ready for that haha which version of IntelliJ do you have to compile? Is there a dedicated branch?
I know documentation is scarce ATM, but do you have any resources to provide?
j

Javier

10/23/2023, 3:45 PM
master branch running the k2 configuration
There are messages about this in the #compiler channel
j

Johann Pardanaud

10/23/2023, 3:46 PM
perfect
thank you so much 🙇‍♂️
🤟 1
(and yes, at the moment I'm only looking to experiment things)
j

Javier

10/23/2023, 3:47 PM
if you don’t need to check results in the IDE, you can use the test framework as it is an easier setup
j

Johann Pardanaud

10/23/2023, 3:48 PM
interesting, thanks