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

refactor: related information in diagnostics #907

Merged
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
19 changes: 10 additions & 9 deletions ocaml-lsp-server/src/diagnostics.ml
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,24 @@ type t =
; merlin : (Uri.t, Diagnostic.t list) Table.t
; send : PublishDiagnosticsParams.t list -> unit Fiber.t
; mutable dirty_uris : Uri_set.t
; capabilities : PublishDiagnosticsClientCapabilities.t option
; related_information : bool
}

let workspace_root t = Lazy.force t.workspace_root

let create capabilities ~workspace_root send =
let create (capabilities : PublishDiagnosticsClientCapabilities.t option)
~workspace_root send =
let related_information =
match capabilities with
| None -> false
| Some c -> Option.value ~default:false c.relatedInformation
in
{ dune = Table.create (module Dune) 32
; merlin = Table.create (module Uri) 32
; dirty_uris = Uri_set.empty
; send
; workspace_root
; capabilities
; related_information
}

let send =
Expand Down Expand Up @@ -294,12 +300,7 @@ let merlin_diagnostics diagnostics merlin =
in
let message = make_message Loc.print_main error in
let message, relatedInformation =
let related_information =
match diagnostics.capabilities with
| None -> false
| Some c -> Option.value ~default:false c.relatedInformation
in
match related_information with
match diagnostics.related_information with
| false -> (message, None)
| true -> (
match error.sub with
Expand Down