Supporting a new language for the JVM: compiling

Hi, I would like to support a new language which compiles to the JVM.
I would like to add files for this language in Java projects and compile them automatically as it happens for Java file. How can I do so?
How can I make the Java editor aware of these files? I would like it to refer to the produced class files (so that no additional support has to be provided).
I would greatly appreciate even general directions and suggestions

Comment actions Permalink

To support compilation, you need to implement a JPS plugin. Some documentation on JPS plugins is available here:

There's also a bunch of examples in the IDEA source code.

You can add the directory containing the compiled class files as a library, which is the simplest way to make the Java editor aware of these files, but this is relatively unlikely to result in a good user experience: IntelliJ IDEA does not by default compile classes on the fly, and your users will see a lot of red code between compilations.

It's much better to provide a real Java PSI representation of the classes in your plugin. It's fairly involved, but at the minimum you need to provide PsiClass/PsiMethod/PsiField implementations over the PSI of your plugin and to provide an implementation of PsiElementFinder that will allow the Java PSI to find those implementations.

Comment actions Permalink

thanks, I will look into that!


Please sign in to leave a comment.