sublimelsp / LSP-jdtls

Convenience package for the Eclipse JDT language server
https://packagecontrol.io/packages/LSP-jdtls
MIT License
30 stars 4 forks source link

Enable uri schemes #15

Closed rwols closed 3 years ago

rwols commented 3 years ago

This attaches jdtls to views with a jdt: URI scheme. Depends on https://github.com/sublimelsp/LSP/pull/1758

rwols commented 3 years ago

... and 1ccb871 defines on_open_uri_async to handle jdt: with the custom java/classFileContents request.

rwols commented 3 years ago

Not sure if it actually works. Just went ahead with this given the code in LSP-Deno. Someone with access to a debugger would have to verify this working.

LDAP commented 3 years ago

Something does not work as expected (have a look at the path): grafik

This seems like a Debugger issue. Maybe @daveleroy can help with this as the path looks good in the Debugger protocol:

⟹ response/stackTrace(22) :: {'stackFrames': [{'id': 3, 'source': {'name': 'Thread.java', 'path': 'jdt://contents/java.base/java.lang/Thread.class?=jdt.ls-java-project/D:%5C/Local_Repositories%5C/windows-dev-tools%5C/bins%5C/jdk%5C/lib%5C/jrt-fs.jar%60java.base=/javadoc_location=/https:%5C/%5C/docs.oracle.com%5C/en%5C/java%5C/javase%5C/15%5C/docs%5C/api%5C/=/%3Cjava.lang(Thread.class', 'sourceReference': 0}, 'line': 841, 'column': 1, 'name': 'Thread.exit()'}], 'totalFrames': 1}
rwols commented 3 years ago

I guess if you only have an URI in the debugger, you can't actually open it via the session.open_location_async machinery. We would need a window command for that.

rwols commented 3 years ago

Given a path in the stackTrace response:

'path': 'jdt://contents/java.base/java.lang/Thread.class?=jdt.ls-java-project/D:%5C/Local_Repositories%5C/windows-dev-tools%5C/bins%5C/jdk%5C/lib%5C/jrt-fs.jar%60java.base=/javadoc_location=/https:%5C/%5C/docs.oracle.com%5C/en%5C/java%5C/javase%5C/15%5C/docs%5C/api%5C/=/%3Cjava.lang(Thread.class'

you then need to invoke the ST view command

lsp_open_location

with arguments

{
    "location":
    {
        "uri": "jdt://contents/...",
        "range":
        {
            "start":
            {
                "line": 841,  // not sure if DAP is 1-based or 0-based; LSP is 0-based.
                "character": 1 // not sure if DAP is 1-based or 0-based; LSP is 0-based.
            },
            "end":
            {
                "line": 841, // not sure if DAP is 1-based or 0-based; LSP is 0-based.
                "character": 1 // not sure if DAP is 1-based or 0-based; LSP is 0-based.
            }
        }
    },
    "session_name": "jdtls"
}

This invocation should be done from within the DAP package.