Open nemethf opened 2 months ago
It seems the documentation is not correct. Sending a DocumentUri as a parm of ocamllsp/switchImplIntf fails, but sending the DocumentUri in a list does work. Like this:
{"jsonrpc":"2.0","id":6,"method":"ocamllsp/switchImplIntf","params":["file:///tmp/hello/bin/main.ml"]}
.
This is with "serverInfo":{"name":"ocamllsp","version":"1.10.5"}
. Has something changed in this area recently, or was the documentation incorrect all along?
Indeed, it looks like the query expects an (json) array with a single uri: https://github.com/ocaml/ocaml-lsp/blob/master/ocaml-lsp-server/src/custom_requests/req_switch_impl_intf.ml#L13-L14
This is explained by the base protocol LSP relies on: JSON-RPC
If present, parameters for the rpc call MUST be provided as a Structured value. Either by-position through an Array or by-name through an Object.
Do you want to open a PR to make it clearer in the documentation ?
Do you want to open a PR to make it clearer in the documentation ?
I'm not really good at this, but I think it would be better to extend the error message to this: The input parameter for ocamllsp/switchImplIntf is invalid. See https://www.jsonrpc.org/specification#parameter_structures
.
So, I know nothing about ocaml, but wanted to support ocaml-lsp extensions in an LSP client. I installed ocaml-lsp with these commands:
Then I created a project with
opam exec -- dune init proj hello
and connected to the server and sent anocamllsp/switchImplIntf
request, which made the server die with an uncaught exception. Probably, the client sent something invalid, but (I think) the server should handle the situation more gracefully.This is the quest the client sends:
{"jsonrpc":"2.0","id":5,"method":"ocamllsp/switchImplIntf","params":"file:///tmp/hello/bin/main.ml"}
On the other hand, I'm guessing there's nothing wrong with the request itself, because if I change it to some other format, I get a jsonrpc-error: "The input parameter for ocamllsp/switchImplIntf is invalid".
At any rate, the communication log is below.
Thanks!
communication log
(I get similar logs even if I start "dune build @check -w" beforehand.)