Commit graph

20 commits

Author SHA1 Message Date
Anton Sorokin
8c4ca80411
[#20] Handle messages with null value for "params" field
Problem:
If an LSP client sends a request with "params":null instead
of omitting the params field or smth like "params":{},
decoding error appears.

Solution:
Replace `null` value for "params" to `{}`
2023-07-10 15:54:36 +03:00
Simon Cruanes
35e89143c4
basic docstrings 2023-04-01 21:48:40 -04:00
Heitor Toledo Lassarote de Paula
8857d5e7c5
Add a comment to send_server_req
Problem: There is an invariant that must be satisfied to call that
function.

Solution: Describe it to warn users of jsonrpc2.
2023-03-15 12:02:02 -03:00
Heitor Toledo Lassarote de Paula
431f3ea126
Disable batch processing
Problem: There was a misunderstanding when implementing this: batch
processing should not return responses individually, but rather return a
list with batch responses. This will require some further logic to group
such responses in order to process them in sequence.

Solution: We return those methods to being unhandled.
2023-03-14 15:27:32 -03:00
Heitor Toledo Lassarote de Paula
5388f58530
Handle server requests
Problem: Linol can only send notifications from the server to the
client, but not requests.

Solution: The solution was inspired by Haskell's `lsp` package. We first
maintain a `server_request_handler_pair` data structure which represents
some server request and its associated response handler. Now
`notify_back` may take these fields and use it to actually handle a
request and its response. Changes to `notify_back` are propagated
throughout `server.ml`.

On `jsonrpc2.ml`, we refactor the notification and request handlers so
that we may handle the response and batch response handlers and batch
call as a courtesy. For a response, we keep a hash table that tracks an
ID to the `server_request_handler_pair` in other to be able to call the
handler that was associated with the response. After we get such
response (indexed by the server request's ID), we remove it from the
hash table to prevent a memory leak.

Since the server needs to keep track of the server request IDs, I added
a mutable `id_counter` in order to generate a fresh LSP ID (using
`fresh_lsp_id`) for every outgoing request.

For debugging, if we error while decoding a JSON, I now print the
exception too.
2023-03-14 14:46:46 -03:00
Simon Cruanes
8cbe2b3519
move to lsp 1.14 2023-03-10 23:12:13 -05:00
Xavier Denis
fe5fdb8a79 Update linol to latest lsp 2022-04-13 13:02:46 +02:00
Simon Cruanes
8ec409dda0 fix compilation 2021-06-01 18:37:54 -04:00
Simon Cruanes
754ecac307 some logging 2021-06-01 18:36:49 -04:00
Simon Cruanes
ec6d0412b7 remove containers as a dep; fix opam 2021-06-01 18:36:49 -04:00
Simon Cruanes
1668e9938a feat: add ~id param to all queries 2021-04-23 16:21:48 -04:00
Simon Cruanes
c417204f1e fix: debug message was making lsp crash 2021-04-08 20:30:36 -04:00
Simon Cruanes
11c4f36d02 more debug info 2021-04-08 20:21:45 -04:00
Simon Cruanes
1710df0e7e use logs to log stuff 2021-04-08 19:52:35 -04:00
Simon Cruanes
b7e89f67e4 try to print backtraces when handlers fail 2021-04-08 19:28:49 -04:00
Simon Cruanes
6d9d2e51e3 refactor: give notify_back to requests, too 2021-04-07 18:01:37 -04:00
Simon Cruanes
78bb184117 add some basic logging 2021-04-05 11:56:40 -04:00
Simon Cruanes
fc17e1e59b big refactor: jsonrpc2 is now part of linol; provide blocking IO 2021-03-25 17:09:03 -04:00
Simon Cruanes
8dff582612 refactor: split into lwt server and abstract interface 2021-02-09 19:40:31 -05:00
Simon Cruanes
a89e7dbb3b initial import 2021-02-09 10:40:37 -05:00