Skip to content

Commit ed1838c

Browse files
authored
Merge pull request #350 from tmattio/new-languageclient
Support new languageclient format
2 parents fdb4abd + d37d855 commit ed1838c

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

ocaml-lsp-server/src/custom_requests/req_infer_intf.ml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ let meth = "ocamllsp/inferIntf"
66

77
let on_request ~(params : Json.t option) (state : State.t) =
88
match params with
9-
| Some (`String (_ : DocumentUri.t) as json_uri) -> (
9+
| Some (`String (_ : DocumentUri.t) as json_uri)
10+
| Some (`List [ `String (_ : DocumentUri.t) ] as json_uri) -> (
1011
let open Fiber.O in
1112
match Document_store.get_opt state.store (Uri.t_of_yojson json_uri) with
1213
| None ->
@@ -22,9 +23,15 @@ let on_request ~(params : Json.t option) (state : State.t) =
2223
match intf with
2324
| Error e -> Error (Jsonrpc.Response.Error.of_exn e)
2425
| Ok intf -> Ok (Json.t_of_yojson (`String intf)) ) )
25-
| Some _
26+
| Some json ->
27+
Fiber.return
28+
@@ Error
29+
(Jsonrpc.Response.Error.make ~code:InvalidRequest
30+
~message:"The input parameter for ocamllsp/inferIntf is invalid"
31+
~data:(`Assoc [ ("param", json) ])
32+
())
2633
| None ->
2734
Fiber.return
2835
@@ Error
2936
(Jsonrpc.Response.Error.make ~code:InvalidRequest
30-
~message:"ocamllsp/inferIntf must receive param : DocumentUri.t" ())
37+
~message:"ocamllsp/inferIntf must receive param: DocumentUri.t" ())

ocaml-lsp-server/src/custom_requests/req_switch_impl_intf.ml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,17 @@ let switch (param : DocumentUri.t) : (Json.t, Jsonrpc.Response.Error.t) result =
1717
let on_request ~(params : Json.t option) _ =
1818
Fiber.return
1919
( match params with
20-
| Some (`String (file_uri : DocumentUri.t)) -> switch file_uri
21-
| Some _
20+
| Some (`String (file_uri : DocumentUri.t))
21+
| Some (`List [ `String (file_uri : DocumentUri.t) ]) ->
22+
switch file_uri
23+
| Some json ->
24+
Error
25+
(Jsonrpc.Response.Error.make ~code:InvalidRequest
26+
~message:"The input parameter for ocamllsp/switchImplIntf is invalid"
27+
~data:(`Assoc [ ("param", json) ])
28+
())
2229
| None ->
2330
Error
2431
(Jsonrpc.Response.Error.make ~code:InvalidRequest
25-
~message:"ocamllsp/switchImplIntf must receive param : DocumentUri.t"
32+
~message:"ocamllsp/switchImplIntf must receive param: DocumentUri.t"
2633
()) )

0 commit comments

Comments
 (0)