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

Added getDocumentSymbols call to extension API #1151

Merged
merged 3 commits into from
Nov 22, 2019

Conversation

omusil24
Copy link
Contributor

Hello everyone,

at Qore Technologies we are working on a VSCode extension and in it we need support for finding symbols in Java files. Adding a whole language server in it and supporting it would be way too much work, especially since your extension already has everything we need. There just wasn't a way to call the language server you are using from outside the extension.

This PR adds function getDocumentSymbols to the extension API, which can then be called by other extensions. This function performs textDocument/documentSymbol call to the language server and returns a promise with the result.

If you have any questions just ask, or if this PR has incorrect style etc. then I can fix that, no problem.

Signed-off-by: Ondřej Musil [email protected]

src/protocol.ts Outdated Show resolved Hide resolved
src/documentSymbols.ts Outdated Show resolved Hide resolved
src/documentSymbols.ts Outdated Show resolved Hide resolved
@omusil24
Copy link
Contributor Author

@testforstephen I fixed the issues that you pointed out but suddenly the calls started to fail with the following response error:

ResponseError: Message could not be parsed.

code: -32700

Object {message: "java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 74 path $.params"}

"Error: Message could not be parsed.
	at handleResponse (/home/omusil/.vscode/extensions/redhat.java-0.54.0/node_modules/vscode-languageserver-protocol/node_modules/vscode-jsonrpc/lib/main.js:448:48)
	at processMessageQueue (/home/omusil/.vscode/extensions/redhat.java-0.54.0/node_modules/vscode-languageserver-protocol/node_modules/vscode-jsonrpc/lib/main.js:275:17)
	at Immediate.setImmediate (/home/omusil/.vscode/extensions/redhat.java-0.54.0/node_modules/vscode-languageserver-protocol/node_modules/vscode-jsonrpc/lib/main.js:259:13)
	at runCallback (timers.js:694:18)
	at tryOnImmediate (timers.js:665:5)
	at processImmediate (timers.js:647:5)"

vscode_java_error

Any idea what could be causing this? Is it maybe a bug in the language server? Cause I'm calling the function exactly the same way like before with same parameters, but now with the DocumentSymbolRequest from vscode-languageclient and the token added.

…ationToken to sendRequest call

Signed-off-by: Ondřej Musil <[email protected]>
@omusil24 omusil24 force-pushed the document-symbols-api branch from eca853b to 3ed4670 Compare November 21, 2019 03:38
@omusil24
Copy link
Contributor Author

Actually, now it's working fine. Just had to put in a check for undefined CancellationToken. After that it started working.

src/protocol.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@testforstephen testforstephen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@omusil24
Copy link
Contributor Author

@testforstephen is there anything else that I need to do? Or when will this get merged?

@fbricon fbricon merged commit 84f4522 into redhat-developer:master Nov 22, 2019
@fbricon fbricon added this to the End November 2019 milestone Nov 22, 2019
@fbricon
Copy link
Collaborator

fbricon commented Nov 22, 2019

@omusil24 thanks for your contribution, keep 'em coming!

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

Successfully merging this pull request may close these issues.

3 participants