Skip to content

Commit

Permalink
refactor: remove dead code
Browse files Browse the repository at this point in the history
ps-id: DC07A002-016D-4922-9749-5224F2A8635A
  • Loading branch information
rgrinberg committed Apr 7, 2022
1 parent 63301cc commit 0d62141
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
27 changes: 26 additions & 1 deletion ocaml-lsp-server/src/document_store.ml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,32 @@ let remove_document store uri =
let+ () = Document.close doc in
Table.remove store uri)

let get_size store = Table.length store
let unregister_promotions t uris =
let* () = Fiber.return () in
List.filter uris ~f:(fun uri ->
match Table.find t.db uri with
| None -> false
| Some doc ->
let doc = { doc with promotions = doc.promotions - 1 } in
let unsubscribe = doc.promotions = 0 in
if unsubscribe && doc.document = None then
Table.remove t.db uri
else
Table.set t.db uri doc;
unsubscribe)
|> unregister_request t

let register_promotions t uris =
let* () = Fiber.return () in
List.filter uris ~f:(fun uri ->
let doc, subscribe =
match Table.find t.db uri with
| None -> ({ document = None; promotions = 0 }, true)
| Some doc -> ({ doc with promotions = doc.promotions + 1 }, false)
in
Table.set t.db uri doc;
subscribe)
|> register_request t

let close t =
Fiber.of_thunk (fun () ->
Expand Down
4 changes: 3 additions & 1 deletion ocaml-lsp-server/src/document_store.mli
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ val get_opt : t -> Uri.t -> Document.t option

val remove_document : t -> Uri.t -> unit Fiber.t

val get_size : t -> int
val unregister_promotions : t -> Uri.t list -> unit Fiber.t

val register_promotions : t -> Uri.t list -> unit Fiber.t

val close : t -> unit Fiber.t

0 comments on commit 0d62141

Please sign in to comment.