Add opportunistic support for Java/Kotlin polyglot Android projects by nisargjhaveri · Pull Request #2261 · eclipse-jdtls/eclipse.jdt.ls

@nisargjhaveri

  • Support Android projects even if they apply kotlin plugin
  • Kotlin is not supported by jdt.ls, but it could be supported by an extension to the ls
  • Even if Kotlin is not supported, Java code in project can still benefit from the support

FYI @CsCherrYY, @jdneo

@nisargjhaveri

- Support Android projects even if they apply kotlin plugin
- Kotlin is not supported by jdt.ls, but it could be supported by an extension to the ls
- Even if Kotlin is not supported, Java code in project can still benefit from the support

Signed-off-by: Nisarg Jhaveri <nisargjhaveri@gmail.com>

@jdneo

We disabled it on purpose at first. Because we don't want to introduce any confusion to users.

At least for now, the polyglot (Java + Kotlin) projects are now supported well.

Even if Kotlin is not supported, Java code in project can still benefit from the support

Yes, but when it comes to that, the Java code and Kotlin code reference each other, things will become tricky.

My personal opinion is that the benefit of this change not clear to me.

@nisargjhaveri

More details.

Kotlin is not supported by jdt.ls, but it could be supported by an extension to the ls

There is an experimental extension, which extends jdt.ls by providing Kotlin LS as well to support Java+Kotlin projects. If we don't allow Android support if Kotlin plugin is applied, even if kotlin support is otherwise available, it won't work as expected.

Even if Kotlin is not supported, Java code in project can still benefit from the support

The previous case is the target case where Kotlin is already available from some extension. In case user has not enabled Kotlin support (not installed required extensions), this doesn't hurt much in my opinion. It is very clear that this language server only support Java. I've also seen many projects where the kotlin plugin is applied, but most, if not all of the code is in Java. This might not be an optimal experience, but gives more choice to the user in my opinion.

@jdneo

@CsCherrYY

The propose to disable the android support on projects having kotlin plugin is not to introduce much noise to users, as @jdneo mentioned. Besides, I think this change is acceptable since:

  • JDTLS now reports errors for non-Android Java/Kotlin polyglot projects, it keeps consistent if we do the same thing for Android projects.
  • I'm glad to hear that vscode-java-kotlin provides experimental Java/Kotlin support. JDTLS would be happy to not block the polyglot support to collect more feedback, since the Android support in JDTLS is at the experimental stage as well.

CsCherrYY