Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Language Server Protocol for TLAPM #93

Merged
merged 145 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
e09e72d
Initial experiments with LSP.
kape1395 Sep 19, 2023
fc0cd13
Empty LSP server works.
kape1395 Sep 19, 2023
6d06443
Some code reorg.
kape1395 Sep 19, 2023
c5e54d4
Use the code formatter.
kape1395 Sep 19, 2023
e71f936
Improving it.
kape1395 Sep 19, 2023
705f1cc
CLI added, some refactorings, 2 transports.
kape1395 Sep 20, 2023
7b6735f
IO Tracing added.
kape1395 Sep 20, 2023
67b1629
Some LSP communication works already.
kape1395 Sep 22, 2023
6b90562
Option to redirect stderr to a file.
kape1395 Sep 23, 2023
637f37d
Use logging to a file rom the ts code.
kape1395 Sep 23, 2023
687f5a4
Docs store.
kape1395 Sep 23, 2023
a6ddb4f
Some experiments on test cases.
kape1395 Sep 23, 2023
ff2d50b
Handle some LSP packets.
kape1395 Sep 24, 2023
cc08f1d
Attempt to reuse the original traceln function.
kape1395 Sep 24, 2023
fd022ee
Track connection state.
kape1395 Sep 24, 2023
79eadba
Support prover-info cmd.
kape1395 Sep 24, 2023
d6c7131
Cleanup.
kape1395 Sep 24, 2023
bbbc308
Cleanup.
kape1395 Sep 24, 2023
31d69e1
Playing with more LSP command types.
kape1395 Sep 24, 2023
ac444b2
Notes.
kape1395 Sep 24, 2023
a54d399
Prove-step now contains the cursor in the doc.
kape1395 Sep 24, 2023
9bd124e
Some tests.
kape1395 Sep 29, 2023
413bd17
Some progress on the tlapm invokation.
kape1395 Oct 2, 2023
bf54288
Toolbox parser, support multiline fields.
kape1395 Oct 2, 2023
10f8edf
Small code simplifications.
kape1395 Oct 2, 2023
9316553
Some notes.
kape1395 Oct 3, 2023
866892d
Some test cases.
kape1395 Oct 7, 2023
eeab4f0
Support for reading a TLA file from STDIN.
kape1395 Oct 7, 2023
0f9da46
Use stream add function instead of stream directly.
kape1395 Oct 7, 2023
dede4da
Code reorganized to run on threads.
kape1395 Oct 7, 2023
7d62986
Working on the LSP prove-step command.
kape1395 Oct 7, 2023
4db77ad
Prover is now invoked.
kape1395 Oct 8, 2023
8719f7d
TLAPM is now invoked.
kape1395 Oct 8, 2023
d0120d7
Range translation fixed.
kape1395 Oct 8, 2023
462cad8
Obligations are now shown (on proof event only).
kape1395 Oct 8, 2023
679e556
Structs to maintain obligation state added.
kape1395 Oct 8, 2023
2253767
Notes.
kape1395 Oct 8, 2023
2b416ed
It starts looking like working.
kape1395 Oct 9, 2023
b7cd138
Line diff.
kape1395 Oct 9, 2023
cd5d78f
Docs module reorganized.
kape1395 Oct 9, 2023
32bbf85
Diagnostics pull implemented.
kape1395 Oct 10, 2023
b3bce51
Code formatting.
kape1395 Oct 10, 2023
7ec97db
Unify use of diagnostic source.
kape1395 Oct 10, 2023
9ab7d63
Misc fixes.
kape1395 Oct 10, 2023
2aa1f6f
Show failed obligation.
kape1395 Oct 10, 2023
989642c
Rename the prove-step command.
kape1395 Oct 13, 2023
46a66f0
Makefile env setup targets fixed.
kape1395 Oct 13, 2023
7b3e2b9
Parser is now invoked.
kape1395 Oct 14, 2023
7870b0a
Use modules instead of embedded recs.
kape1395 Oct 14, 2023
cb51893
Consider theorem ranges when checking a step.
kape1395 Oct 14, 2023
8d9d19c
A bit of error handling.
kape1395 Oct 14, 2023
c58d5e4
Make build work with older ocaml versions.
kape1395 Oct 14, 2023
37e8a07
Experiment: use custom notification to present proof states.
kape1395 Oct 15, 2023
58618d5
Notes.
kape1395 Oct 15, 2023
579804a
Proof state is shown somehow.
kape1395 Oct 15, 2023
1a72a56
Cleanup.
kape1395 Oct 16, 2023
0cc97f9
QED step locus tracking fixed in the parser.
kape1395 Oct 16, 2023
4b6baa8
Code action for "check-proof".
kape1395 Oct 16, 2023
2c4b5eb
Use Ocaml 5.1 in the CI build.
kape1395 Oct 16, 2023
871a148
Make CI work with OCaml 5.1.
kape1395 Oct 16, 2023
ca30c58
Better traceln impl.
kape1395 Oct 17, 2023
5177315
Use Re2 instead of Str.
kape1395 Oct 19, 2023
4425941
Try improve range calculations.
kape1395 Oct 19, 2023
83acdf3
Route the obl_num/terminated to the corresponding doc.
kape1395 Oct 20, 2023
38403e8
A bit of cleanup.
kape1395 Oct 20, 2023
ab6cb52
Working on the progress presentation and the cancellation.
kape1395 Oct 21, 2023
2116c53
Progress is now shown.
kape1395 Oct 21, 2023
7da3374
Cleanup.
kape1395 Oct 21, 2023
c72e177
Cancellation support.
kape1395 Oct 21, 2023
7e552c0
Improve error handling.
kape1395 Nov 11, 2023
a12ddea
Fixes #100.
kape1395 Nov 11, 2023
d0ed4b6
Use SigINT to interrupt the TLAPM instead of SigKILL.
kape1395 Dec 17, 2023
07819c6
Buffer proof info updates for some time before sending them to the IDE.
kape1395 Dec 17, 2023
ccaa8f7
Merge remote-tracking branch 'upstream/main' into lsp
kape1395 Dec 21, 2023
528e0a8
Invoke graceful termination on SigINT.
kape1395 Jan 5, 2024
668db17
Initial version of providing the proof state of a step.
kape1395 Jan 7, 2024
4074c28
Missing lib added, some auto-formatting.
kape1395 Jan 7, 2024
07e89f9
Make mutex usage compatible with older ocaml versions.
kape1395 Jan 7, 2024
0cb0251
Broken test fixed.
kape1395 Jan 7, 2024
f18baaa
Remove test LSP client. It is not relevant anymore.
kape1395 Jan 7, 2024
dd07c14
Adjust the proof state structs for the UI.
kape1395 Jan 8, 2024
0928d79
Split tlapm_lsp_docs into multiple files.
kape1395 Jan 12, 2024
332a174
Use HTTPS to download Isabelle.
kape1395 Jan 12, 2024
814e059
Take obligation text from the parser.
kape1395 Jan 13, 2024
ec55193
Use search path when parsing a document.
kape1395 Jan 13, 2024
9be9d3a
Only show steps from the current file.
kape1395 Jan 14, 2024
529e001
Proof steps are determined correctly again. Closes #114.
kape1395 Jan 16, 2024
bb88a5e
Retain proof state based on fingerprints; attach obligations to steps…
kape1395 Jan 21, 2024
b0497da
Include the BY clauses into the proof step range.
kape1395 Jan 22, 2024
d26164b
Show proof steps for HAVE, TAKE, WITNESS.
kape1395 Jan 22, 2024
87788f0
Better error message for unsupported recursive operators.
kape1395 Jan 23, 2024
7db485a
Code reorganized into sub-modules.
kape1395 Jan 23, 2024
8354385
Formatter.
kape1395 Jan 23, 2024
0311059
Move range to the main lsp lib.
kape1395 Jan 23, 2024
241cfb3
Prover client code reorganized.
kape1395 Jan 24, 2024
7db97e8
Reorganize code into sub-modules.
kape1395 Jan 24, 2024
4ef5e1f
Progress reorganized.
kape1395 Jan 24, 2024
54e5930
Add status to TlapsProofStepDetails.
kape1395 Jan 24, 2024
7d9cb83
LSP: omitted and progress fixed.
kape1395 Jan 26, 2024
b500bbd
Misc TODOs addressed.
kape1395 Jan 27, 2024
8bec891
Send updates to the current proof step details.
kape1395 Jan 27, 2024
c00773d
Retain decorators after tabs are switched.
kape1395 Jan 27, 2024
512586b
Set the current proof step via explicit LSP command.
kape1395 Jan 27, 2024
b5aa2a7
Send the obligation role with the details.
kape1395 Jan 27, 2024
f006a8f
Pass obligation status to UI.
kape1395 Jan 28, 2024
9289216
Have to process all the referenced modules.
kape1395 Jan 30, 2024
14e45b5
Exchange module search paths with the LSP client.
kape1395 Feb 3, 2024
52d2219
LSP now takes paths from the client.
kape1395 Feb 3, 2024
31ed7d8
Add `--prefer-stdlib` option and use it in the LSP server. This is to…
kape1395 Feb 9, 2024
1b4437c
Global ref to the parser paths eliminated.
kape1395 Feb 10, 2024
777c732
Propagate parser updates to the loaded docs.
kape1395 Feb 10, 2024
6231f51
Report an understandable error if an operator is applied with a wrong…
kape1395 Feb 13, 2024
5dc0169
Register parsing errors so that they can be reported nicely.
kape1395 Feb 13, 2024
d3eb73f
More of error handling in the parser.
kape1395 Feb 17, 2024
0a5b5f6
Merge remote-tracking branch 'origin/main' into lsp
kape1395 Feb 26, 2024
5fa594b
Merge remote-tracking branch 'upstream/main' into lsp
kape1395 Feb 26, 2024
edfd377
Mistype fixed.
kape1395 May 31, 2024
cee770f
Update lsp/lib/docs/doc_vsn.ml
kape1395 May 31, 2024
8dfcaa5
Remove unused module export.
kape1395 Jun 1, 2024
70d43c3
Mistype fixed.
kape1395 Jun 1, 2024
9bb6a52
Mistype fixed.
kape1395 Jun 1, 2024
9d9a559
Mistype fixed.
kape1395 Jun 1, 2024
6591218
Comment refined.
kape1395 Jun 1, 2024
09c9414
failwith -> assert false
kape1395 Jun 1, 2024
f653fd7
Use atomic instead of mutex in the signal handler.
kape1395 Jun 8, 2024
53cfe83
Merge remote-tracking branch 'origin/main' into lsp
kape1395 Jun 8, 2024
8b8ce33
Multiple mistypes in comments fixed.
kape1395 Jun 8, 2024
933a762
Use assert false for impossible cases.
kape1395 Jun 8, 2024
f682548
Use `type nonrec t = t` instead of a renamed type.
kape1395 Jun 8, 2024
1865962
A function simplified.
kape1395 Jun 8, 2024
6f7c3ac
Don't use needless namespaces.
kape1395 Jun 8, 2024
20583b6
Error message improved.
kape1395 Jun 8, 2024
7491db9
Make code more readable.
kape1395 Jun 8, 2024
7865485
Error message improved.
kape1395 Jun 8, 2024
6b6d9a8
Use OCaml 4.14 instead of 4.13. Build a release on 5.1.0.
kape1395 Jun 8, 2024
f5fccb3
Refine the `step_loc` description.
kape1395 Jun 8, 2024
c573aba
Improve comments.
kape1395 Jun 10, 2024
0ac8eac
Exactly 1 module has to be specified if TLAPM is invoked with the `--…
kape1395 Jun 10, 2024
9e1fbe7
Update to the new dependency versions.
kape1395 Aug 24, 2024
ab37243
Merge remote-tracking branch 'origin/main' into lsp
kape1395 Aug 24, 2024
47afb6b
Use proper library paths in all cases.
kape1395 Aug 26, 2024
0c996a6
Improve comments.
kape1395 Aug 26, 2024
4837328
Handle file read errors gracefully.
kape1395 Aug 26, 2024
8138f4b
Toolbox protocol v2 added, fixed the check if an obligation is in the…
kape1395 Aug 27, 2024
4d53b9e
Cleanup around the pending provers for an obligation.
kape1395 Aug 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Send updates to the current proof step details.
Signed-off-by: Karolis Petrauskas <k.petrauskas@gmail.com>
  • Loading branch information
kape1395 committed Jan 27, 2024
commit 8bec8912d9c1d77b556fd9172efc0c5d0ad78cec
2 changes: 1 addition & 1 deletion lsp/lib/docs/doc_actual.ml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ let locate_proof_range (act : t) range =
let parsed = Lazy.force act.parsed in
Proof_step.locate_proof_range parsed.ps range

let get_obligation_state act range =
let get_proof_step_details act range =
let parsed = Lazy.force act.parsed in
Proof_step.locate_proof_step parsed.ps range

Expand Down
2 changes: 1 addition & 1 deletion lsp/lib/docs/doc_actual.mli
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ val vsn : t -> int
val text : t -> string
val proof_res : t -> Doc_proof_res.t
val locate_proof_range : t -> Range.t -> Range.t
val get_obligation_state : t -> Range.Position.t -> Proof_step.t option
val get_proof_step_details : t -> Range.Position.t -> Proof_step.t option
val prover_prepare : t -> int -> t option
val prover_add_obl : t -> int -> Toolbox.Obligation.t -> t option
val prover_add_notif : t -> int -> Toolbox.tlapm_notif -> t option
Expand Down
8 changes: 4 additions & 4 deletions lsp/lib/docs/docs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,18 @@ let get_proof_res_latest docs uri =
let docs, res = get_proof_res docs uri latest_vsn in
(docs, Some latest_vsn, res)

let get_obligation_state docs uri vsn range =
let get_proof_step_details docs uri vsn range =
with_doc_vsn docs uri vsn @@ fun doc act ->
let res =
match Doc_actual.get_obligation_state act range with
match Doc_actual.get_proof_step_details act range with
| None -> None
| Some ps -> Some (Proof_step.as_lsp_tlaps_proof_step_details uri ps)
in
(doc, act, res)

let get_obligation_state_latest docs uri range =
let get_proof_step_details_latest docs uri range =
match latest_vsn docs uri with
| None -> (docs, None)
| Some latest_vsn ->
let docs, res = get_obligation_state docs uri latest_vsn range in
let docs, res = get_proof_step_details docs uri latest_vsn range in
(docs, res)
4 changes: 2 additions & 2 deletions lsp/lib/docs/docs.mli
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ val get_proof_res : t -> tk -> int -> t * Doc_proof_res.t option
val get_proof_res_latest : t -> tk -> t * int option * Doc_proof_res.t option
(** Get the latest actual proof results. Cleanup them, if needed. *)

val get_obligation_state :
val get_proof_step_details :
t ->
tk ->
int ->
Range.Position.t ->
t * Structs.TlapsProofStepDetails.t option
(** Get the current proof state for the specific obligation. *)

val get_obligation_state_latest :
val get_proof_step_details_latest :
t -> tk -> Range.Position.t -> t * Structs.TlapsProofStepDetails.t option
(** Get the current proof state for the specific obligation at the latest version of the document. *)
35 changes: 21 additions & 14 deletions lsp/lib/server/session.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ type t = {
progress : Prover.Progress.t;
mode : mode;
docs : Docs.t;
prov : Prover.t; (** Prover that is currently running. *)
delayed : DocUriSet.t; (** Docs which have delayed proof info updates. *)
current_obl : LspT.Location.t option;
(** The obligation that is currently selected. We will send state updates for it. *)
prov : Prover.t;
(** Prover that is currently running.
We are always running not more than 1 prover to
avoid their interference via fingerprints, etc. *)
delayed : DocUriSet.t;
(** Docs which have delayed proof info updates.
We use this to buffer the updates to the UI.*)
current_ps : LspT.Location.t option;
(** The proof step that is currently selected.
We will send state updates for it. *)
}

let with_docs' st f =
Expand Down Expand Up @@ -117,12 +123,12 @@ let send_obligation_proof_state st =
let maybe_st =
with_docs' st @@ fun (st, docs) ->
let docs, notif_data =
match st.current_obl with
match st.current_ps with
| None -> (docs, None)
| Some loc ->
let tlapm_range = Range.of_lsp_range loc.range in
let position = Range.from tlapm_range in
Docs.get_obligation_state_latest docs loc.uri position
Docs.get_proof_step_details_latest docs loc.uri position
in
let notif_packet = TlapsProofStepDetails.to_jsonrpc_packet notif_data in
st.output_adder (Some notif_packet);
Expand Down Expand Up @@ -199,9 +205,7 @@ module SessionHandlers = Handlers.Make (struct
| Some (vsn, p_range) -> (st, Some (vsn, Range.as_lsp_range p_range))

let track_obligation_proof_state (st : t) uri range =
let st =
{ st with current_obl = Some (LspT.Location.create ~uri ~range) }
in
let st = { st with current_ps = Some (LspT.Location.create ~uri ~range) } in
let st = send_obligation_proof_state st in
st

Expand Down Expand Up @@ -229,7 +233,7 @@ module SessionHandlers = Handlers.Make (struct
docs = Docs.empty;
prov = Prover.create sw fs proc_mgr;
delayed = DocUriSet.empty;
current_obl = None;
current_ps = None;
}
in
let () =
Expand Down Expand Up @@ -293,9 +297,12 @@ let handle_timer_tick st =
in
let st = DocUriSet.fold ff st.delayed st in
let st =
match DocUriSet.is_empty st.delayed with
| true -> st
| false -> send_obligation_proof_state st
match st.current_ps with
| Some current_ps -> (
match DocUriSet.mem current_ps.uri st.delayed with
| true -> st
| false -> send_obligation_proof_state st)
| None -> st
in
Some { st with delayed = DocUriSet.empty }

Expand Down Expand Up @@ -327,7 +334,7 @@ let run event_taker event_adder output_adder sw fs proc_mgr =
docs = Docs.empty;
prov = Prover.create sw fs proc_mgr;
delayed = DocUriSet.empty;
current_obl = None;
current_ps = None;
}
in
loop st
Loading