Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file base.ml
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192(************************************************************************)(* * The Coq Proof Assistant / The Coq Development Team *)(* v * INRIA, CNRS and contributors - Copyright 1999-2018 *)(* <O___,, * (see CREDITS file for the list of authors) *)(* \VV/ **************************************************************)(* // * This file is distributed under the terms of the *)(* * GNU Lesser General Public License Version 2.1 *)(* * (see LICENSE file for the text of the license) *)(************************************************************************)(************************************************************************)(* Coq Language Server Protocol *)(* Copyright 2019 MINES ParisTech -- Dual License LGPL 2.1 / GPL3+ *)(* Written by: Emilio J. Gallego Arias *)(************************************************************************)(* Status: Experimental *)(************************************************************************)(* This file contains some coq-specific commands, we should instead
functorialize it so we can share with other OCaml-specific tools *)(* Whether to send extended lsp messages *)letstd_protocol=reftruemoduleJ=Yojson.Safelet_mk_extral=if!std_protocolthen[]elsel(* Ad-hoc parsing for file:///foo... *)let_parse_uristr=letl=String.lengthstr-7inString.(substr7l)letmk_reply~id~result=`Assoc[("jsonrpc",`String"2.0");("id",`Intid);("result",result)]letmk_request_error~id~code~message=`Assoc[("jsonrpc",`String"2.0");("id",`Intid);("error",`Assoc[("code",`Intcode);("message",`Stringmessage)])]letmk_notification~method_~params=`Assoc[("jsonrpc",`String"2.0");("method",`Stringmethod_);("params",`Assocparams)](* let json_of_goal g = let pr_hyp (s,(_,t)) = `Assoc ["hname", `String s;
"htype", `String (Format.asprintf "%a" Print.pp_term (Bindlib.unbox t))] in
let open Proofs in let j_env = List.map pr_hyp g.g_hyps in `Assoc [ "gid",
`Int g.g_meta.meta_key ; "hyps", `List j_env ; "type", `String
(Format.asprintf "%a" Print.pp_term g.g_type)]
let json_of_thm thm = let open Proofs in match thm with | None -> `Null |
Some thm -> `Assoc [ "goals", `List List.(map json_of_goal thm.t_goals) ] *)letmk_range{Fleche.Types.Range.start;end_}:J.t=`Assoc[("start",`Assoc[("line",`Intstart.line);("character",`Intstart.character)]);("end",`Assoc[("line",`Intend_.line);("character",`Intend_.character)])](* let mk_diagnostic ((p : Pos.pos), (lvl : int), (msg : string), (thm :
Proofs.theorem option)) : J.json = *)letmk_diagnostic((r:Fleche.Types.Range.t),(lvl:int),(msg:string),(_thm:unitoption)):J.t=(* let goal = json_of_thm thm in *)letrange=mk_rangerin`Assoc[(* mk_extra ["goal_info", goal] @ *)("range",range);("severity",`Intlvl);("message",`Stringmsg)]letmk_diagnostics~uri~versionld:J.t=mk_notification~method_:"textDocument/publishDiagnostics"~params:[("uri",`Stringuri);("version",`Intversion);("diagnostics",`ListList.(mapmk_diagnosticld))]