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

Nits refactor fleche #844

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 1 addition & 3 deletions controller/rq_goals.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
(************************************************************************)

(* Replace by ppx when we can print goals properly in the client *)
let mk_message (range, level, text) =
let level = Lang.Diagnostic.Severity.to_int level in
Lsp.JFleche.Message.{ range; level; text }
let mk_message (range, level, text) = Lsp.JFleche.Message.{ range; level; text }

let mk_messages node =
Option.map Fleche.Doc.Node.messages node
Expand Down
19 changes: 11 additions & 8 deletions fleche/doc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,10 @@ end = struct
else 3
in
let f (_, lvl, _) =
let lvl = Lang.Diagnostic.Severity.to_int lvl in
if lvl = 2 then Both else if lvl < cutoff then Left else Right
(* warning = 2 *)
if lvl = Lang.Diagnostic.Severity.warning then Both
else if lvl < cutoff then Left
else Right
in
let diags, messages = partition ~f fbs in
(List.map (of_feed ~drange) diags, messages)
Expand Down Expand Up @@ -670,16 +672,17 @@ let search_node ~command ~doc ~st =
(fun (node : Node.t) -> Option.default Memo.Stats.zero node.info.stats)
Memo.Stats.zero node
in
let back_overflow num =
let ll = List.length doc.nodes in
Pp.(
str "not enough nodes: [" ++ int num ++ str " > " ++ int ll
++ str "] available document nodes")
in
match command with
| Coq.Ast.Meta.Command.Back num -> (
match Base.List.nth doc.nodes num with
| None ->
let ll = List.length doc.nodes in
let message =
Pp.(
str "not enough nodes: [" ++ int num ++ str " > " ++ int ll
++ str "] available document nodes")
in
let message = back_overflow num in
(Coq.Protect.E.error message, nstats None)
| Some node -> (Coq.Protect.E.ok node.state, nstats (Some node)))
| Restart -> (
Expand Down
1 change: 0 additions & 1 deletion lang/diagnostic.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ module Severity = struct
let warning = 2
let information = 3
let hint = 4
let to_int x = x
end

type t =
Expand Down
13 changes: 5 additions & 8 deletions lang/diagnostic.mli
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,12 @@ module Data : sig
end

module Severity : sig
type t
type t = int

val error : t
val warning : t
val information : t
val hint : t

(** Convert to LSP-like levels *)
val to_int : t -> int
val error : t (* 1 *)
val warning : t (* 2 *)
val information : t (* 3 *)
val hint : t (* 4 *)
end

type t =
Expand Down
1 change: 0 additions & 1 deletion lsp/jLang.ml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ module Diagnostic = struct

let to_yojson { Lang.Diagnostic.range; severity; message; data } =
let range = Range.conv range in
let severity = Lang.Diagnostic.Severity.to_int severity in
let message = Pp.to_string message in
_t_to_yojson { range; severity; message; data }
end
Expand Down