Skip to content

Commit 4cf45ed

Browse files
committed
feat: log the jsonrpc messages received
This will help debug lsp problems.
1 parent 19ff5cc commit 4cf45ed

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

language-server/vscoqtop/lspManager.ml

+7-5
Original file line numberDiff line numberDiff line change
@@ -452,15 +452,14 @@ let textDocumentCompletion id params =
452452
Error {message; code=None}, []
453453

454454
let documentSymbol id params =
455-
let Lsp.Types.DocumentSymbolParams.{ textDocument = {uri}; partialResultToken; workDoneToken } = params in
456-
begin match workDoneToken with
457-
| Some token -> log "WE HAVE A TOKEN"
458-
| None -> log "No TOKEN :'("
459-
end;
455+
let Lsp.Types.DocumentSymbolParams.{ textDocument = {uri}; partialResultToken; workDoneToken } = params in (*TODO: At some point we might get ssupport for partialResult and workDone*)
460456
match Hashtbl.find_opt states (DocumentUri.to_path uri) with
461457
| None -> log @@ "[documentSymbol] ignoring event on non existent document"; Error({message="Document does not exist"; code=None}), []
462458
| Some tab -> log @@ "[documentSymbol] getting symbols";
463459
if Dm.DocumentManager.is_parsing tab.st then
460+
(* Making use of the error codes: the ServerCancelled error code indicates
461+
that the server is busy and the client should resend the request later.
462+
It doesn't seem to be working for documentSymbol at the moment. *)
464463
Error {code=(Some Jsonrpc.Response.Error.Code.ServerCancelled); message="Parsing not finished"} , []
465464
else
466465
let symbols = Dm.DocumentManager.get_document_symbols tab.st in
@@ -599,6 +598,9 @@ let handle_lsp_event = function
599598
| Receive (Some rpc) ->
600599
lsp :: (* the event is recurrent *)
601600
begin try
601+
let json = Jsonrpc.Packet.yojson_of_t rpc in
602+
let msg = Yojson.Safe.pretty_to_string ~std:true json in
603+
log @@ "recieved: " ^ msg;
602604
begin match rpc with
603605
| Request req ->
604606
log @@ "ui request: " ^ req.method_;

0 commit comments

Comments
 (0)