Skip to content
39 changes: 31 additions & 8 deletions src/lsp/lp_doc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,31 @@ let process_cmd _file (nodes,st,dg,logs) cmd =

| Cmd_Error(loc, msg) ->
Comment thread
fblanqui marked this conversation as resolved.
Outdated
Comment thread
fblanqui marked this conversation as resolved.
Outdated
let nodes = { cmd; exec = false; goals = [] } :: nodes in
let cmd_loc, loc, diag, log = match cmd_loc, loc with
let cmd_loc, diag, log = match cmd_loc, loc with
Comment thread
fblanqui marked this conversation as resolved.
Outdated
Comment thread
fblanqui marked this conversation as resolved.
Outdated
Comment thread
fblanqui marked this conversation as resolved.
Outdated
| Some l, Some Some l' ->
if l.fname = l'.fname then
(* if error in the same file, use the precise location *)
Comment thread
fblanqui marked this conversation as resolved.
Outdated
Some l', Some l', msg, Pos.popt_to_string (Some l') ^ msg
let log_msg =
let form = Format.formatter_of_buffer lp_logger in
Color.update_with_color form;
Format.fprintf (form) (Color.red "[%s] %s") (Pos.popt_to_string
~print_dirname:false
~print_fname:false
(Some l')) msg;
Format.pp_print_flush form ();
buf_get_and_clear lp_logger
in
Some l', msg, log_msg
else
(* else, use the location of the command *)
Comment thread
fblanqui marked this conversation as resolved.
Outdated
cmd_loc, Some l', Pos.popt_to_string (Some l') ^ "\n" ^ msg
, Pos.popt_to_string (Some l') ^ "\n" ^ msg
cmd_loc,
Pos.popt_to_string (Some l') ^ "\n" ^ msg,
Pos.popt_to_string (Some l') ^ "\n" ^ msg
(* Otherwise,
cmd_loc doesn't change and loc is : option_default loc cmd_loc *)
Comment thread
fblanqui marked this conversation as resolved.
Outdated
| _, Some l' -> cmd_loc, l', msg, Pos.popt_to_string (l') ^ "\n" ^ msg
| _, None -> cmd_loc, cmd_loc, msg, msg in
nodes, st, (cmd_loc, 1, diag, None) :: dg, ((1, log), loc) :: logs
| _, Some l' -> cmd_loc, msg, Pos.popt_to_string (l') ^ "\n" ^ msg
Comment thread
fblanqui marked this conversation as resolved.
Outdated
Comment thread
fblanqui marked this conversation as resolved.
Outdated
| _, None -> cmd_loc, msg, msg in
nodes, st, (cmd_loc, 1, diag, None) :: dg, ((1, log), cmd_loc) :: logs

let new_doc ~uri ~version ~text =
let root, logs =
Expand Down Expand Up @@ -205,7 +216,19 @@ let check_text ~doc =
let logs, diags =
match error with
| None -> logs, diags
| Some(pos,msg) -> logs @ [((1, msg), Some pos)], diags @ [pos,1,msg,None]
| Some(pos,msg) ->
Comment thread
fblanqui marked this conversation as resolved.
Outdated
let log_msg =
let form = Format.formatter_of_buffer lp_logger in
Color.update_with_color form;
Format.fprintf (form) (Color.red "[%s] %s")
(Pos.popt_to_string
~print_dirname:false
~print_fname:false
(Some pos)) msg;
Format.pp_print_flush form ();
buf_get_and_clear lp_logger
in
logs @ [((1, log_msg),Some pos)], diags @ [pos,1,msg,None]
in
let map = Pure.rangemap cmds in
let doc = { doc with nodes; final=Some(final); map; logs } in
Expand Down