For general server architecture, see README.md
. For details of IPC communication, see Watchdog.lean
.
This module implements per-file worker processes.
File processing and requests+notifications against a file should be concurrent for two reasons:
- By the LSP standard, requests should be cancellable.
- Since Lean allows arbitrary user code to be executed during elaboration via the tactic framework, elaboration can be extremely slow and even not halt in some cases. Users should be able to work with the file while this is happening, e.g. make new changes to the file or send requests.
To achieve these goals, elaboration is executed in a chain of tasks, where each task corresponds to the elaboration of one command. When the elaboration of one command is done, the next task is spawned. On didChange notifications, we search for the task in which the change occured. If we stumble across a task that has not yet finished before finding the task we're looking for, we terminate it and start the elaboration there, otherwise we start the elaboration at the task where the change occured.
Requests iterate over tasks until they find the command that they need to answer the request. In order to not block the main thread, this is done in a request task. If a task that the request task waits for is terminated, a change occured somewhere before the command that the request is looking for and the request sends a "content changed" error.
- hIn : IO.FS.Stream
- hOut : IO.FS.Stream
- hLog : IO.FS.Stream
- headerTask : Task (Except IO.Error (Lean.Server.Snapshots.Snapshot × Lean.SearchPath))
- initParams : Lean.Lsp.InitializeParams
- clientHasWidgets : Bool
Instances For
Asynchronous snapshot elaboration #
- snaps : Array Lean.Server.Snapshots.Snapshot
Instances For
Equations
Instances For
Elaborates all commands after the last snap (at least the header snap is assumed to exist), emitting the diagnostics into hOut
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
- initHeaderStx : Lean.Syntax
- pendingRequests : Lean.Server.FileWorker.PendingRequestMap
- rpcSessions : Lean.RBMap UInt64 (IO.Ref Lean.Server.FileWorker.RpcSession) compare
A map of RPC session IDs. We allow asynchronous elab tasks and request handlers to modify sessions. A single
Ref
ensures atomic transactions.
Instances For
Equations
Instances For
Use lake print-paths
to compile dependencies on the fly and add them to LEAN_PATH
.
Compilation progress is reported to hOut
via LSP notifications. Return the search path for
source files.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Given the new document, updates editable doc state.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Lean.Server.FileWorker.handleCancelRequest p = Lean.Server.FileWorker.updatePendingRequests fun pendingRequests => Lean.RBMap.erase pendingRequests p.id
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Requests here are handled synchronously rather than in the asynchronous RequestM
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Lean.Server.FileWorker.queueRequest id requestTask = Lean.Server.FileWorker.updatePendingRequests fun pendingRequests => Lean.RBMap.insert pendingRequests id requestTask
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.