https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
e

Edoardo Luppi

12/03/2023, 7:51 AM
Forked https://github.com/Strumenta/antlr-kotlin yesterday and began modernizing the codebase. So far so good. What I'm missing is a CLI to convert Java files to Kotlin, so that I can also update the ANTLR runtime sources, and maybe automate it. Couldn't find anything that seemed actually worth spending time on tho, any ideas?
h

hfhbd

12/03/2023, 8:33 AM
I did start porting the j2k converter of the Kotlin plugin as a cli app but it is still in progress because it is deeply wired into IntelliJ. https://github.com/hfhbd/j2k
e

Edoardo Luppi

12/03/2023, 8:35 AM
I wonder why they only made it available in the IDE, maybe because of the PSI model?
h

hfhbd

12/03/2023, 8:46 AM
To support a language an IDE needs to read the user-input, parse it and built the AST tree to resolve the references, for features likes auto-completionen. These three requirements, reading input, parsing and building the AST tree are also required by a compiler. To not rebuild this, the Kotlin compiler (and sqldelight too) uses IntelliJ as the frontend of the compiler, that's why the compiler is 60 MB and JVM only. AFAIK, with K2, the usage of IntelliJ in the frontend is minimized now, not used for resolving, but still used for parsing. PSI is "just" a nice api on top of the AST tree. I guess, there are two reason to provide the J2K in the IDE: 1. business, it is a nice feature for IntelliJ, but mostly, 2. you need to check the code for errors, not compile ones but logical too!
e

Edoardo Luppi

12/03/2023, 9:49 AM
Makes sense, thanks!