Skip to content

Commit 0d62141

Browse files
committed
refactor: remove dead code
ps-id: DC07A002-016D-4922-9749-5224F2A8635A
1 parent 63301cc commit 0d62141

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

ocaml-lsp-server/src/document_store.ml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,32 @@ let remove_document store uri =
2727
let+ () = Document.close doc in
2828
Table.remove store uri)
2929

30-
let get_size store = Table.length store
30+
let unregister_promotions t uris =
31+
let* () = Fiber.return () in
32+
List.filter uris ~f:(fun uri ->
33+
match Table.find t.db uri with
34+
| None -> false
35+
| Some doc ->
36+
let doc = { doc with promotions = doc.promotions - 1 } in
37+
let unsubscribe = doc.promotions = 0 in
38+
if unsubscribe && doc.document = None then
39+
Table.remove t.db uri
40+
else
41+
Table.set t.db uri doc;
42+
unsubscribe)
43+
|> unregister_request t
44+
45+
let register_promotions t uris =
46+
let* () = Fiber.return () in
47+
List.filter uris ~f:(fun uri ->
48+
let doc, subscribe =
49+
match Table.find t.db uri with
50+
| None -> ({ document = None; promotions = 0 }, true)
51+
| Some doc -> ({ doc with promotions = doc.promotions + 1 }, false)
52+
in
53+
Table.set t.db uri doc;
54+
subscribe)
55+
|> register_request t
3156

3257
let close t =
3358
Fiber.of_thunk (fun () ->

ocaml-lsp-server/src/document_store.mli

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ val get_opt : t -> Uri.t -> Document.t option
1212

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

15-
val get_size : t -> int
15+
val unregister_promotions : t -> Uri.t list -> unit Fiber.t
16+
17+
val register_promotions : t -> Uri.t list -> unit Fiber.t
1618

1719
val close : t -> unit Fiber.t

0 commit comments

Comments
 (0)