Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typeDefinition returns null instead of an empty list #3112

Open
Bnaya opened this issue Mar 26, 2024 · 3 comments
Open

typeDefinition returns null instead of an empty list #3112

Bnaya opened this issue Mar 26, 2024 · 3 comments

Comments

@Bnaya
Copy link

Bnaya commented Mar 26, 2024

Hey

See
https://github.com/eclipse-jdtls/eclipse.jdt.ls/blob/master/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/NavigateToTypeDefinitionHandler.java#L58

return location == null ? null : Arrays.asList(location);

Other handles returns Collections.emptyList(), but NavigateToTypeDefinitionHandler retures null

When using vscode-jsonrpc on the client side, you will see these errors: The received response has neither a result nor an error property.

@rgrunber
Copy link
Contributor

What any given handle returns depends on the protocol. If the protocol allows it, then it should be expected. According to https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_typeDefinition :

Response:

result: Location | Location[] | LocationLink[] | null
partial result: Location[] | LocationLink[]
error: code and message set in case an exception happens during the definition request.

Seems similar to microsoft/vscode-languageserver-node#311 (comment) except in that case it was determined the response was not correct. Maybe it's a bug in the vscode-jsonrpc library unless there's something I'm missing here.

@Bnaya
Copy link
Author

Bnaya commented Mar 29, 2024

I've done some more debugging, and the LS is not sending result: null, but not sending the result prop at all,
Which is against the spec

@rgrunber
Copy link
Contributor

rgrunber commented Apr 1, 2024

What client are you using to run the language server ? There should be a folder created by jdt-ls either in the system's temporary directory or somewhere else (depending on how you run the actual language server). It should contain a file at some path like .metadata/.log. That might contain more information on why there is no response.

Note that prior to calling something like typeDefinition, you need to have called initialize on the project & probably didOpen on a particular document.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants