1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798openBaseopenFlechemoduleF=Stdlib.Format(* This is actually quite a weak check, just a placeholder as Flèche can tells
us precisely what has opened a proof; but we need to bump the dep. *)letcheck_thm(info:Lang.Ast.Info.t)=let(=)=Poly.equalininfo.kind=12&&(info.detail=Some"Theorem"||info.detail=Some"Lemma"||info.detail=Some"Proposition"||info.detail=Some"Corollary"||info.detail=Some"Definition"||info.detail=Some"Fixpoint"||info.detail=Some"Fact")letcheck_thminfos=List.exists~f:check_thminfos(* A node can have multiple names (ie mutual recursive defs) *)letget_names(infos:Lang.Ast.Info.tlist)=List.concat_mapinfos~f:(fun(info:Lang.Ast.Info.t)->matchinfo.name.vwith|None->[]|Somes->[s])moduleThmDecl=structtypet={names:stringlist;node:Doc.Node.t}endletgather_thmacc(node:Doc.Node.t)=matchnode.astwith|None->acc(* unparseable node *)|Someast->(matchast.ast_infowith|None->acc|Someinfo->ifcheck_thminfothenletnames=get_namesinfoin{ThmDecl.names;node}::accelseacc)letget_theorems~doc:{Doc.nodes;_}=List.fold_leftnodes~init:[]~f:gather_thm|>List.revletvernac_timeout~timeout(f:'a->'b)(x:'a):'b=matchControl.timeouttimeoutfxwith|None->Exninfo.iraise(Control.Timeout,Exninfo.null)|Somex->xletinterp=letintern=Vernacinterp.fs_interninVernacinterp.interp~internletcoq_interp_with_timeout?timeout~stcmd=letopenCoqinletst=State.to_coqstinletcmd=Ast.to_coqcmdin(matchtimeoutwith|None->interp~stcmd|Sometimeout->vernac_timeout~timeout(interp~st)cmd)|>State.of_coqletinterp?timeout~token~stcmd=Coq.Protect.evalcmd~token~f:(coq_interp_with_timeout?timeout~st)letrun_tac~token~st?timeouttac=(* Parse tac, loc==FIXME *)letstr=Gramlib.Stream.of_stringtacinletstr=Coq.Parsing.Parsable.make?loc:Nonestrinlet(let*)xf=Coq.Protect.E.bind~fxinlet*ast=Coq.Parsing.parse~token~ststrinmatchastwith|None->Coq.Protect.E.okNone|Someast->interp?timeout~token~stast|>Coq.Protect.E.map~f:Option.someletpp_diagfmt(d:Pp.tLang.Diagnostic.t)=letopenStdlibinletpr=Fleche_lsp.JCoq.Pp_t.to_yojsoninFormat.fprintffmt"@[%a@]"(Yojson.Safe.pretty_print~std:true)(Fleche_lsp.JLang.Diagnostic.to_yojsonprd)letpp_diagsfmtdl=letopenStdlibinFormat.fprintffmt"@[%a@]"(Format.pp_print_listpp_diag)dl(* completed == Yes && no diags errors *)letcompleted_without_error~(doc:Fleche.Doc.t)=letdiags=Fleche.Doc.diagsdocinletdiags=List.filter~f:Lang.Diagnostic.is_errordiagsinmatchdoc.completedwith|Yes_->ifList.is_emptydiagsthenNoneelseSomediags|_->Somediags