feat: have class URIs use their original source name#3666
feat: have class URIs use their original source name#3666fbricon merged 1 commit intoeclipse-jdtls:mainfrom
Conversation
f98f6f7 to
49b59ba
Compare
|
@datho7561 could you test this PR on non-vscode clients pretty please? Hopefully it should work everywhere |
49b59ba to
6d2a8ff
Compare
|
It doesn't seem to be working for me outside of VS Code, here's what I tried:
I'll double check that it works for me in VS Code as well, though |
|
okhttp3 is a different problem I was looking at this morning. Eclipse fails to open the kotlin sources because the jar file doesn't contain any .java file. This is due to JDT's SourceMapper.computeAllRootPaths() calling isJavaLikeFileName. Java-like extensions are loaded by getJavaLikeExtensions via an extension point. I tried registering kotlin via : <extension point="org.eclipse.core.contenttype.contentTypes">
<file-association
content-type="org.eclipse.jdt.core.javaSource"
file-extensions="kt,scala"/>
</extension>And then it works! But with a big caveat: any .kt file found in a source folder is now compiled as a java file and then you get plenty of compilation errors. Sooo. This is an issue that needs to be handled in a separate ticket. For now presto-jdbc sources work |
Okay, I'll check that and get back to you |
|
You can try <dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-jdbc</artifactId>
<version>0.296</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor_2.13</artifactId>
<version>2.8.8</version>
</dependency> |
|
Okay, I get Kotlin sources now, but the file extension is still listed as .class (Maybe that's just how it works for this neovim setup though) so I have to change the language over to Kotlin manually. update: yeah works fine in VS Code, so I'm guessing it's something to do with the client code in neovim. update: specifically something in https://codeberg.org/mfussenegger/nvim-jdtls, since go-to-definition doesn't work without it |
|
That's weird. jdt.ls used to send the kotlin content before as well, the only difference is now the URI path ends with .kt instead of .class |
|
Here's the client code where the classfile loading is being handled I think: https://codeberg.org/mfussenegger/nvim-jdtls/src/commit/f73731b543f5971e0da9665eb1d7ceffe1fde71f/lua/jdtls.lua#L1214 Notably, it sets the filetype to Java. This might cause problems? |
|
@mfussenegger any idea why nvim-jdtls would still list the source content as .class instead of .kt? @datho7561 we need eclipse-jdt/eclipse.jdt.core#4738 to be fixed in order to see .kt files from source jars not containing .java files. |
nvim-jdtls should show the But looks like I'll need to adapt the logic in nvim-jdtls that calls -- Other question: Can eclipse.jdt.ls then handle if the LSP client attaches to those kotlin sources (didOpen, etc.) loaded via |
|
@mfussenegger yes you'll need to parse the url path, the actual file extension will be sent back. If for some reason you receive .class, it should be treated as .java "java/classFileContents" should just be used to display source content. You're not supposed to call jdt.ls didOpen on it. |
Is there an issue doing it? So far I never noticed any problem. And it is currently required due to how the neovim lsp client works. To use other |
|
OK so I double checked in vscode-java, didOpen is not called when opening a .kt source via "java/classFileContents", but .java content does it, so I guess you don't need to change anything there. |
6d2a8ff to
c08ac84
Compare
|
We need eclipse-jdt/eclipse.jdt.core#4769 to be merged upstream to be able to get kotlin sources from kotlin-only jars |
|
Upstream fix has been merged and is available for jt.ls to consume, tested with any class from @mfussenegger any chance you can test this PR? |
|
On a quick test it seems to work. Can eclipse.jdt.ls also provide sources for other JVM languages - like scalar or clojure or is it only kotlin for now? |
|
I've added groovy, kotlin and scala for now, just need to update the extension point in plugin.xml to add more languages. Do you know any lib written in clojure? |
c08ac84 to
266a5ba
Compare
|
I added clojure as well. |
Signed-off-by: Fred Bricon <[email protected]> Co-authored-by: Cursor <[email protected]>
266a5ba to
f30d8cb
Compare

Fixes redhat-developer/vscode-java#4297
Draft until I go over all failing tests