Skip to content

Commit

Permalink
Merge pull request #844 from ejgallego/nits_refactor_fleche
Browse files Browse the repository at this point in the history
Nits refactor fleche
  • Loading branch information
ejgallego authored Sep 30, 2024
2 parents f4a0290 + 64943ff commit b5d3df6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 21 deletions.
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

0 comments on commit b5d3df6

Please sign in to comment.