-
Notifications
You must be signed in to change notification settings - Fork 148
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
jsonrpc should de-structure byPosition array parameter of requests and notifications #553
Comments
For the record, the change in |
@testforstephen Is this an issue you are going to be able to provide the fix? |
@jonahgraham sure, i can take a look. |
@testforstephen is it still in your plan to provide a fix? |
@jonahgraham |
Thanks @dhuebner - I have added it to my review queue and will get to it soon-ish. BTW there are a few typos of JsonRPC throughout the PR, if that is the only issues I see I can correct on the way to a merge, but if you got to them first I would be grateful. |
@jonahgraham |
@jonahgraham |
@jonahgraham |
Thank @dhuebner - I will have a look at it next week. |
I think this is done - but I think needs an entry in the Changelog as this behaviour change could be unexpected. |
Done in #731 |
When i installed vscode-languageclient 7.0.0 to adopt LSP 3.16, i found there was a breaking change in [email protected] about adopting Parameter Structures concept of [email protected], see language client 7.0.0 changelog.
In summary, if the request/notification parameter is not an object parameter, jsonrpc will wrap it into an array. See JSON_RPC implementation of language client.
Here are some samples of how to handle parameters in a language client jsonrpc.
client.sendRequest(type, true)
jsonrpc:
{
...
Params: [ true ]
}
client.sendRequest(type, [true])
jsonrpc:
{
...
Params: [ [ true ] ]
}
client.sendRequest(type, { value: true })
jsonrpc:
{
...
Params: {
value: true
}
}
To avoid breaking in language server, jsonrpc in lsp4j should de-structure the outermost array wrapper if it‘s a single array parameter.
The code change is parseParams of MessageTypeAdapter.java. If the message parameter is an array, then flatten the array first and map each child item to the parameter type.
https://github.com/eclipse/lsp4j/blob/00447d0a44d75b03b6cebf3d2720a311411efdca/org.eclipse.lsp4j.jsonrpc/src/main/java/org/eclipse/lsp4j/jsonrpc/json/adapters/MessageTypeAdapter.java#L241-L251
The text was updated successfully, but these errors were encountered: