Skip to content
30 changes: 22 additions & 8 deletions src/lsp/lp_doc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,26 @@ 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
Some l',
msg,
Pos.popt_to_string
~print_dirname:false
~print_fname:false
(Some l') ^ " " ^ 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 +211,15 @@ 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
logs @ [
((1,
(Pos.popt_to_string
~print_dirname:false
~print_fname:false
(Some pos) ^ ": " ^ 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