microsoft / language-server-protocol

Defines a common protocol for language servers.
https://microsoft.github.io/language-server-protocol/
Creative Commons Attribution 4.0 International
10.91k stars 764 forks source link

When are params and error data optional? #1883

Open michaelpj opened 5 months ago

michaelpj commented 5 months ago

The JSON-RPC spec says that the params field of a request or notification is optional; and similarly for the data field on a response error.

However, in many cases omitting params is nonsensical: the user can't ask for a hover without telling us where! And conversely, in the few cases where params aren't necessary, they must be omitted (because there isn't even a param type!).

So the approach we have been taking in HLS is:

Is this right? If so, could we say as much in the spec?

There is a similar question for error data: when it is specified in the metamodel that a method has an error data type, does that mean that any errors for that method must include error data, or is it still optional?