Skip to content

fix navigation on recent JDTLS: accept both class and java files in jdt uris#68

Open
sideshowcoder wants to merge 1 commit into
yveszoundi:mainfrom
sideshowcoder:sideshowcoder/fix-jdt-uri-handler-regex
Open

fix navigation on recent JDTLS: accept both class and java files in jdt uris#68
sideshowcoder wants to merge 1 commit into
yveszoundi:mainfrom
sideshowcoder:sideshowcoder/fix-jdt-uri-handler-regex

Conversation

@sideshowcoder
Copy link
Copy Markdown

@sideshowcoder sideshowcoder commented Feb 27, 2026

In a recent version of JDTLS the jsonrpc is returing .java files directly instead of the .class files for the navigation query, only including the .class as part of the query string of the URI, to keep the regex compatible this accepts both either .class or .java files, formatting the source file name correctly as PACKAGE/FILENAME.java either way.

The JSON RPC responses are now including the jdt uri with the Java file, with the class file as part of the query string of the URI, which is not matched by the regex.

[jsonrpc] e[15:00:41.429]   <-- textDocument/definition[60] {
  "jsonrpc": "2.0",
  "id": 60,
  "result": [
    {
      "uri": "jdt://contents/slf4j-api-2.0.17.jar/org.slf4j/LoggerFactory.java?=dropwizard-openfeature/%5C/home%5C/pfehre%5C/.m2%5C/repository%5C/org%5C/slf4j%5C/slf4j-api%5C/2.0.17%5C/slf4j-api-2.0.17.jar=/maven.pomderived=/true=/=/javadoc_location=/jar:file:%5C/home%5C/pfehre%5C/.m2%5C/repository%5C/org%5C/slf4j%5C/slf4j-api%5C/2.0.17%5C/slf4j-api-2.0.17-javadoc.jar%5C!%5C/=/=/maven.groupId=/org.slf4j=/=/maven.artifactId=/slf4j-api=/=/maven.version=/2.0.17=/=/maven.scope=/compile=/=/maven.pomderived=/true=/%3Corg.slf4j%28LoggerFactory.class",
      "range": {
        "start": {
          "line": 69,
          "character": 19
        },
        "end": {
          "line": 69,
          "character": 32
        }
      }
    }
  ]
}

This fixes this so both .java and .class are accepted for backwards compatibility to older JDTLS versions.

In a recent version of jdtls the lsp started returing java files directly
instead of the class files for the navigation query, to keep the regex
compatible this accepts both either .class or .java files, formatting the source
file name correctly as PACKAGE/FILENAME.java either way.
@sideshowcoder sideshowcoder changed the title accept both class and java files in jdt uris fix navigation on recent JDTLS: accept both class and java files in jdt uris Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant