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 occurred. 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 occurred.
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 occurred somewhere before the command that the request is looking for and the request sends a "content changed" error.
- chanOut : IO.Channel Lean.JsonRpc.Message
Synchronized output channel for LSP messages. Notifications for outdated versions are discarded on read.
Latest document version received by the client, used for filtering out notifications from previous versions.
- chanIsProcessing : IO.Channel Bool
Channel that receives a message for every a
$/lean/fileProgress
notification, indicating whether the notification suggests that the file is currently being processed. - stickyDiagnosticsRef : IO.Ref (Array Lean.Widget.InteractiveDiagnostic)
Diagnostics that are included in every single
textDocument/publishDiagnostics
notification. - hLog : IO.FS.Stream
- initParams : Lean.Lsp.InitializeParams
- processor : Lean.Parser.InputContext → BaseIO Lean.Language.Lean.InitialSnapshot
- clientHasWidgets : Bool
- cmdlineOpts : Lean.Options
Options defined on the worker cmdline (i.e. not including options from
setup-file
), used for context-free tasks such as editing delay.
Instances For
Asynchronous snapshot elaboration #
Type of state stored in Snapshot.Diagnostics.cacheRef?
.
See also section "Communication" in Lean/Server/README.md.
Instances For
- availableImports : ImportCompletion.AvailableImports
- lastRequestTimestampMs : Nat
Instances For
- reporterCancelTk : IO.CancelToken
Token flagged for aborting
doc.reporter
when a new document version comes in. - srcSearchPathTask : Task Lean.SearchPath
- importCachingTask? : Option (Task (Except IO.Error Lean.Server.FileWorker.AvailableImportsCache))
- 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
Callback from Lean language processor after parsing imports that requests necessary information from Lake for processing imports.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Creates an LSP message output channel along with a reader that sends out read messages on the output FS stream after discarding outdated notifications. This is the only component of the worker with access to the output stream, so we can synchronize messages from parallel elaboration tasks here.
Instances For
Instances For
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
Received from the watchdog when a dependency of this file is detected as being stale. Issues a sticky diagnostic to the client that it should run "Restart File".
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
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
Instances For
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Instances For
Instances For
Equations
- One or more equations did not get rendered due to their size.