mirror of
https://github.com/c-cube/linol.git
synced 2025-12-06 11:15:46 -05:00
fix: debug message was making lsp crash
This commit is contained in:
parent
11c4f36d02
commit
c417204f1e
2 changed files with 19 additions and 6 deletions
|
|
@ -144,10 +144,11 @@ module Make(IO : IO)
|
||||||
try_ @@ fun () ->
|
try_ @@ fun () ->
|
||||||
IO.return @@ J.from_string (Bytes.unsafe_to_string buf)
|
IO.return @@ J.from_string (Bytes.unsafe_to_string buf)
|
||||||
in
|
in
|
||||||
Log.debug (fun k->k "got json %a" J.pp j);
|
Log.debug (fun k->k "got json %s" (J.to_string j));
|
||||||
begin match Jsonrpc.Message.either_of_yojson j with
|
begin match Jsonrpc.Message.either_of_yojson j with
|
||||||
| m -> IO.return @@ Ok m
|
| m -> IO.return @@ Ok m
|
||||||
| exception _ ->
|
| exception _ ->
|
||||||
|
Log.err (fun k->k "cannot decode json message");
|
||||||
IO.return (Error (E(ErrorCode.ParseError, "cannot decode json")))
|
IO.return (Error (E(ErrorCode.ParseError, "cannot decode json")))
|
||||||
end
|
end
|
||||||
| exception _ ->
|
| exception _ ->
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,7 @@ module Make(IO : IO) = struct
|
||||||
method on_request_unhandled
|
method on_request_unhandled
|
||||||
: type r. notify_back:notify_back -> r Lsp.Client_request.t -> r IO.t
|
: type r. notify_back:notify_back -> r Lsp.Client_request.t -> r IO.t
|
||||||
= fun ~notify_back:_ _r ->
|
= fun ~notify_back:_ _r ->
|
||||||
|
Log.debug (fun k->k "req: unhandled request");
|
||||||
IO.failwith "TODO: handle this request"
|
IO.failwith "TODO: handle this request"
|
||||||
|
|
||||||
(** Parameter for how to synchronize content with the editor *)
|
(** Parameter for how to synchronize content with the editor *)
|
||||||
|
|
@ -164,11 +165,7 @@ module Make(IO : IO) = struct
|
||||||
method on_request
|
method on_request
|
||||||
: type r. notify_back:_ -> r Lsp.Client_request.t -> r IO.t
|
: type r. notify_back:_ -> r Lsp.Client_request.t -> r IO.t
|
||||||
= fun ~notify_back (r:_ Lsp.Client_request.t) ->
|
= fun ~notify_back (r:_ Lsp.Client_request.t) ->
|
||||||
|
Log.debug (fun k->k "handle request <opaque>");
|
||||||
Log.debug
|
|
||||||
(fun k->k "handle request : %a" Yojson.Safe.pp
|
|
||||||
(Lsp.Client_request.to_jsonrpc_request ~id:(Jsonrpc.Id.t_of_yojson `Null) r
|
|
||||||
|> Jsonrpc.Message.yojson_of_request));
|
|
||||||
|
|
||||||
begin match r with
|
begin match r with
|
||||||
| Lsp.Client_request.Shutdown ->
|
| Lsp.Client_request.Shutdown ->
|
||||||
|
|
@ -176,18 +173,24 @@ module Make(IO : IO) = struct
|
||||||
_quit <- true; IO.return ()
|
_quit <- true; IO.return ()
|
||||||
|
|
||||||
| Lsp.Client_request.Initialize i ->
|
| Lsp.Client_request.Initialize i ->
|
||||||
|
Log.debug (fun k->k "req: initialize");
|
||||||
let notify_back = new notify_back ~notify_back () in
|
let notify_back = new notify_back ~notify_back () in
|
||||||
self#on_req_initialize ~notify_back i
|
self#on_req_initialize ~notify_back i
|
||||||
|
|
||||||
| Lsp.Client_request.TextDocumentHover { textDocument; position } ->
|
| Lsp.Client_request.TextDocumentHover { textDocument; position } ->
|
||||||
let uri = textDocument.uri in
|
let uri = textDocument.uri in
|
||||||
|
Log.debug (fun k->k "req: hover '%s'" uri);
|
||||||
|
|
||||||
begin match Hashtbl.find_opt docs uri with
|
begin match Hashtbl.find_opt docs uri with
|
||||||
| None -> IO.return None
|
| None -> IO.return None
|
||||||
| Some doc_st ->
|
| Some doc_st ->
|
||||||
let notify_back = new notify_back ~uri ~notify_back () in
|
let notify_back = new notify_back ~uri ~notify_back () in
|
||||||
self#on_req_hover ~notify_back ~uri ~pos:position doc_st
|
self#on_req_hover ~notify_back ~uri ~pos:position doc_st
|
||||||
end
|
end
|
||||||
|
|
||||||
| Lsp.Client_request.TextDocumentCompletion { textDocument; position; context } ->
|
| Lsp.Client_request.TextDocumentCompletion { textDocument; position; context } ->
|
||||||
let uri = textDocument.uri in
|
let uri = textDocument.uri in
|
||||||
|
Log.debug (fun k->k "req: complete '%s'" uri);
|
||||||
begin match Hashtbl.find_opt docs uri with
|
begin match Hashtbl.find_opt docs uri with
|
||||||
| None -> IO.return None
|
| None -> IO.return None
|
||||||
| Some doc_st ->
|
| Some doc_st ->
|
||||||
|
|
@ -197,25 +200,34 @@ module Make(IO : IO) = struct
|
||||||
end
|
end
|
||||||
| Lsp.Client_request.TextDocumentDefinition { textDocument; position } ->
|
| Lsp.Client_request.TextDocumentDefinition { textDocument; position } ->
|
||||||
let uri = textDocument.uri in
|
let uri = textDocument.uri in
|
||||||
|
Log.debug (fun k->k "req: definition '%s'" uri);
|
||||||
let notify_back = new notify_back ~uri ~notify_back () in
|
let notify_back = new notify_back ~uri ~notify_back () in
|
||||||
|
|
||||||
begin match Hashtbl.find_opt docs uri with
|
begin match Hashtbl.find_opt docs uri with
|
||||||
| None -> IO.return None
|
| None -> IO.return None
|
||||||
| Some doc_st ->
|
| Some doc_st ->
|
||||||
self#on_req_definition ~notify_back
|
self#on_req_definition ~notify_back
|
||||||
~uri ~pos:position doc_st
|
~uri ~pos:position doc_st
|
||||||
end
|
end
|
||||||
|
|
||||||
| Lsp.Client_request.TextDocumentCodeLens {textDocument} ->
|
| Lsp.Client_request.TextDocumentCodeLens {textDocument} ->
|
||||||
let uri = textDocument.uri in
|
let uri = textDocument.uri in
|
||||||
|
Log.debug (fun k->k "req: codelens '%s'" uri);
|
||||||
let notify_back = new notify_back ~uri ~notify_back () in
|
let notify_back = new notify_back ~uri ~notify_back () in
|
||||||
|
|
||||||
begin match Hashtbl.find_opt docs uri with
|
begin match Hashtbl.find_opt docs uri with
|
||||||
| None -> IO.return []
|
| None -> IO.return []
|
||||||
| Some doc_st ->
|
| Some doc_st ->
|
||||||
self#on_req_code_lens ~notify_back ~uri doc_st
|
self#on_req_code_lens ~notify_back ~uri doc_st
|
||||||
end
|
end
|
||||||
|
|
||||||
| Lsp.Client_request.TextDocumentCodeLensResolve cl ->
|
| Lsp.Client_request.TextDocumentCodeLensResolve cl ->
|
||||||
|
Log.debug (fun k->k "req: codelens resolve");
|
||||||
let notify_back = new notify_back ~notify_back () in
|
let notify_back = new notify_back ~notify_back () in
|
||||||
self#on_req_code_lens_resolve ~notify_back cl
|
self#on_req_code_lens_resolve ~notify_back cl
|
||||||
|
|
||||||
| Lsp.Client_request.ExecuteCommand { command; arguments } ->
|
| Lsp.Client_request.ExecuteCommand { command; arguments } ->
|
||||||
|
Log.debug (fun k->k "req: execute command '%s'" command);
|
||||||
let notify_back = new notify_back ~notify_back () in
|
let notify_back = new notify_back ~notify_back () in
|
||||||
self#on_req_execute_command ~notify_back command arguments
|
self#on_req_execute_command ~notify_back command arguments
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue