Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ocamllsp): infer intf for closed docs #753

Merged
merged 1 commit into from
Jun 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions ocaml-lsp-server/src/inference.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let language_id_of_fname s =
| ext ->
Code_error.raise "unsupported file extension" [ ("extension", String ext) ]

let force_open_document (state : State.t) uri =
let open_document_from_file (state : State.t) uri =
let filename = Uri.to_path uri in
Fiber.of_thunk (fun () ->
match Io.String_path.read_file filename with
Expand All @@ -47,11 +47,10 @@ let force_open_document (state : State.t) uri =
let params =
DidOpenTextDocumentParams.create ~textDocument:text_document
in
let* doc =
let+ doc =
Document.make (State.wheel state) state.merlin_config
~merlin_thread:state.merlin params
in
let+ () = Document_store.open_document state.store doc in
Some doc)

let infer_intf (state : State.t) doc =
Expand All @@ -66,7 +65,7 @@ let infer_intf (state : State.t) doc =
let* impl =
match Document_store.get_opt state.store impl_uri with
| Some impl -> Fiber.return (Some impl)
| None -> force_open_document state impl_uri
| None -> open_document_from_file state impl_uri
in
match impl with
| None -> Fiber.return None
Expand Down