Skip to content

Commit

Permalink
refactor: remove stdune deps from lsp-fiber
Browse files Browse the repository at this point in the history
though not all are completely removed yet

ps-id: 73AB2922-D2AC-4555-8549-B1DB80E5F197
  • Loading branch information
rgrinberg committed Jan 29, 2022
1 parent edf6695 commit dfa7aa6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
20 changes: 3 additions & 17 deletions lsp-fiber/src/import.ml
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
open Stdune
module List = Stdune.List
module Result = Stdune.Result
module Hashtbl = Stdune.Hashtbl
module Option = Stdune.Option
module Int = Stdune.Int
module Ordering = Stdune.Ordering
module Exn = Stdune.Exn
module Unix_env = Stdune.Env
module Fpath = Stdune.Path
module Code_error = Code_error
module Or_exn = Or_exn
module Table = Table
module Id = Id
module Exn_with_backtrace = Exn_with_backtrace
module Fdecl = Fdecl
module Queue = Queue
module List = Stdlib.ListLabels
module Code_error = Stdune.Code_error
module Fdecl = Stdune.Fdecl
module Header = Lsp.Header
module Io = Lsp.Io

Expand Down
12 changes: 7 additions & 5 deletions lsp-fiber/src/rpc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ module type Notification_intf = sig
val to_jsonrpc : t -> Jsonrpc.Message.notification
end

module Table = Stdlib.Hashtbl.Make (Jsonrpc.Id)

module Make (Initialize : sig
type t
end)
Expand All @@ -161,7 +163,7 @@ struct
; (* Filled when the server is initialied *)
initialized : Initialize.t Fiber.Ivar.t
; mutable req_id : int
; pending : (Jsonrpc.Id.t, Cancel.t) Table.t
; pending : Cancel.t Table.t
; detached : Fiber.Pool.t
}

Expand Down Expand Up @@ -213,7 +215,7 @@ struct
(Jsonrpc_fiber.Reply.now (Jsonrpc.Response.error req.id error), state)
| Ok (In_request.E r) ->
let cancel = Cancel.create () in
Table.set t.pending req.id cancel;
Table.replace t.pending req.id cancel;
let+ response, state =
Fiber.finalize
(fun () ->
Expand Down Expand Up @@ -248,7 +250,7 @@ struct
; session = Fdecl.create Dyn.opaque
; initialized = Fiber.Ivar.create ()
; req_id = 1
; pending = Table.create (module Jrpc_id) 32
; pending = Table.create 32
; detached = Fiber.Pool.create ()
}
in
Expand All @@ -268,7 +270,7 @@ struct
Out_request.to_jsonrpc_request req ~id
in
let+ (resp : Jsonrpc.Response.t) = k jsonrpc_request in
match resp.result |> Result.map ~f:(Out_request.response_of_json req) with
match resp.result |> Result.map (Out_request.response_of_json req) with
| Ok s -> s
| Error e -> raise (Jsonrpc.Response.Error.E e)

Expand Down Expand Up @@ -318,7 +320,7 @@ struct

let handle_cancel_req t id =
let+ () =
match Table.find t.pending id with
match Table.find_opt t.pending id with
| None -> Fiber.return ()
| Some id -> Fiber.Pool.task t.detached ~f:(fun () -> Cancel.cancel id)
in
Expand Down

0 comments on commit dfa7aa6

Please sign in to comment.