palantir/language-servers

Make groovyc wrapper uses joint compilation

jiahuijiang opened this issue · 3 comments

Currently the groovy language server only works with .groovy files, but we should set the jointCompilation configuration in compilationConfiguration to make it work with Java too.
https://github.com/apache/groovy/blob/master/src/main/org/codehaus/groovy/control/CompilerConfiguration.java#L155

I'm not sure what the distinction is, but the compilation unit is capable of compiling java files without joint compilation:
http://groovy-lang.org/groovyc.html#section-jointcompilation

It is important to know that if you don’t enable joint compilation and try to compile Java source files with the Groovy compiler, the Java source files will be compiled as if they were Groovy sources. In some situations, this might work since most of the Java syntax is compatible with Groovy, but semantics would be different.

Should we still enable joint compilation?

So I couldn't get a different result with joint compilation than without so I did some more investigation. We would probably need to use a JavaAwareCompilationUnit: https://github.com/apache/groovy/blob/4c829ca397aae8f86c993c000d5ab8445c2a0189/src/main/org/codehaus/groovy/tools/javac/JavaAwareCompilationUnit.java
I don't know if this is useful.

We could just allow java extensions and compile them like groovy files, I think its probably sufficient for our use case.