intellij-community
intellij-community copied to clipboard
[kotlin][rfc] J2K: Add preprocessing extension point
Based on testing this extension point with two dummy preprocessors (see draft PR), this works as expected (i.e. it runs the preprocessors on a background thread, and successfully applies their changes before conversion) with one major caveat: changes due to conversion and changes due to preprocessing require two undo actions (i.e. Ctl + z).
I've tried a couple things to fix this problem, but so far none has worked:
- Running the custom preprocessors under a transparent global command (code). Maybe I was supposed to enable merging of global commands somehow?
- Using the same command group id to run the custom preprocessors and the committing new kotlin files + external code processing command (code)
You can see the example preprocessors in action (plus the suboptimal undo behavior) in the attached video zip. Screen Recording 2024-06-24 at 11.08.57 AM.zip
Once the issues with the preprocessing extension point are resolved, I'll add a postprocessing extension point by more or less copying this one.
@abelkov @darthorimar @jocelynluizzi13
Also, please add some tests
Tests added and coroutines funkiness resolved! I probably need to clean up some k1/k2 test duplicates, but other than that I think this is ready for review again. If it looks good to you, @darthorimar, I'll expand upon these changes to handle postprocessing as well.
@ermattt Awesome! Now tests behave more like production in JavaToKotlinAction.
The formatting changes in test data are definitely magic, but they seem to simulate the behavior in the real IntelliJ IDEA, so they are totally okay.
I'm ready to merge this PR as is, or do you want to have some modifications here?
If it looks good to you, @darthorimar, I'll expand upon these changes to handle postprocessing as well.
Definitely, thanks!
Also, if it will be easier for you, you can also both of pre/post-processing reviews into a single one
I'll add my postprocessing changes to this PR today, test 'em, and then re-request review from you 🥳
@abelkov & @darthorimar, addressed comments and tested the example pre- and post-processor extensions together (see screen recording) preAndPostTogether.mov.zip
@abelkov just addressed the last round of comments