MessageLog
with interactive diagnostics.
Can be created using Diagnostics.empty
or Diagnostics.ofMessageLog
.
- msgLog : Lean.MessageLog
Non-interactive message log.
Dynamic mutable slot usable by the language server for memorizing interactive diagnostics. If
none
, interactive diagnostics are not remembered, which should only be used for messages not containing any interactive elements as client-side state will be lost on recreating a diagnostic.See also section "Communication" in Lean/Server/README.md.
Instances For
Equations
- Lean.Language.Snapshot.instInhabitedDiagnostics = { default := { msgLog := default, interactiveDiagsRef? := default } }
The empty set of diagnostics.
Equations
- Lean.Language.Snapshot.Diagnostics.empty = { msgLog := Lean.MessageLog.empty, interactiveDiagsRef? := none }
The base class of all snapshots: all the generic information the language server needs about a snapshot.
- diagnostics : Lean.Language.Snapshot.Diagnostics
The messages produced by this step. The union of message logs of all finished snapshots is reported to the user.
- infoTree? : Option Lean.Elab.InfoTree
General elaboration metadata produced by this step.
- isFatal : Bool
Whether it should be indicated to the user that a fatal error (which should be part of
diagnostics
) occurred that prevents processing of the remainder of the file.
Instances For
Equations
- Lean.Language.instInhabitedSnapshot = { default := { diagnostics := default, infoTree? := default, isFatal := default } }
A task producing some snapshot type (usually a subclass of Snapshot
).
- range? : Option String.Range
Range that is marked as being processed by the server while the task is running. If
none
, the range of the outer task if some or else the entire file is reported. - task : Task α
Underlying task producing the snapshot.
Instances For
Equations
- ⋯ = ⋯
Creates a snapshot task from a reporting range and a BaseIO
action.
Equations
- Lean.Language.SnapshotTask.ofIO range? act = do let __do_lift ← act.asTask pure { range? := range?, task := __do_lift }
Creates a finished snapshot task.
Equations
- Lean.Language.SnapshotTask.pure a = { range? := none, task := { get := a } }
Explicitly cancels a tasks. Like with basic Tasks
s, cancellation happens implicitly when the
last reference to the task is dropped if it is not an I/O task.
Transforms a task's output without changing the reporting range.
Equations
- t.map f range? sync = { range? := range?, task := Task.map f t.task Task.Priority.default sync }
Chains two snapshot tasks. The range is taken from the first task if not specified; the range of the second task is discarded.
Equations
- t.bind act range? sync = { range? := range?, task := t.task.bind (fun (x : α) => (act x).task) Task.Priority.default sync }
Chains two snapshot tasks. The range is taken from the first task if not specified; the range of the second task is discarded.
Equations
- One or more equations did not get rendered due to their size.
Synchronously waits on the result of the task.
Equations
- t.get = t.task.get
Returns task result if already finished or else none
.
Arbitrary value paired with a syntax that should be inspected when considering the value for reuse.
- stx : Lean.Syntax
Syntax to be inspected for reuse.
- val : α
Potentially reusable value.
Pair of (optional) old snapshot task usable for incremental reuse and new snapshot promise for
incremental reporting. Inside the elaborator, we build snapshots by carrying such bundles and then
checking if we can reuse old?
if set or else redoing the corresponding elaboration step. In either
case, we derive new bundles for nested snapshots, if any, and finally resolve
new
to the result.
Note that failing to resolve
a created promise will block the language server indefinitely!
We use withAlwaysResolvedPromise
/withAlwaysResolvedPromises
to ensure this doesn't happen.
In the future, the 1-element history old?
may be replaced with a global cache indexed by strong
hashes but the promise will still need to be passed through the elaborator.
- old? : Option (Lean.Language.SyntaxGuarded (Lean.Language.SnapshotTask α))
Snapshot task of corresponding elaboration in previous document version if any, paired with its old syntax to be considered for reuse. Should be set to
none
as soon as reuse can be ruled out. - new : IO.Promise α
Promise of snapshot value for the current document. When resolved, the language server will report its result even before the current elaborator invocation has finished.
Runs act
with a newly created promise and finally resolves it to default
if not done by act
.
Always resolving promises involved in the snapshot tree is important to avoid deadlocking the language server.
Equations
- Lean.Language.withAlwaysResolvedPromise act = do let p ← liftM IO.Promise.new tryFinally (act p) (liftM (IO.Promise.resolve default p))
Runs act
with count
newly created promises and finally resolves them to default
if not done by
act
.
Always resolving promises involved in the snapshot tree is important to avoid deadlocking the language server.
Equations
- One or more equations did not get rendered due to their size.
Tree of snapshots where each snapshot comes with an array of asynchronous further subtrees. Used
for asynchronously collecting information about the entirety of snapshots in the language server.
The involved tasks may form a DAG on the Task
dependency level but this is not captured by this
data structure.
- mk: Lean.Language.Snapshot → Array (Lean.Language.SnapshotTask Lean.Language.SnapshotTree) → Lean.Language.SnapshotTree
Creates a snapshot tree node.
Instances For
Equations
- Lean.Language.instInhabitedSnapshotTree = { default := Lean.Language.SnapshotTree.mk default default }
The immediately available element of the snapshot tree node.
Equations
- x.element = match x with | Lean.Language.SnapshotTree.mk s children => s
The asynchronously available children of the snapshot tree node.
Equations
- x.children = match x with | Lean.Language.SnapshotTree.mk element children => children
Produces debug tree format of given snapshot tree, synchronously waiting on all children.
Helper class for projecting a heterogeneous hierarchy of snapshot classes to a homogeneous representation.
- toSnapshotTree : α → Lean.Language.SnapshotTree
Transforms a language-specific snapshot to a homogeneous snapshot tree.
Instances
- Lean.Elab.Command.instToSnapshotTreeMacroExpandedSnapshot
- Lean.Elab.Tactic.instToSnapshotTreeTacticParsedSnapshot
- Lean.Elab.instToSnapshotTreeBodyProcessedSnapshot
- Lean.Elab.instToSnapshotTreeDefsParsedSnapshot
- Lean.Elab.instToSnapshotTreeHeaderProcessedSnapshot
- Lean.Language.Lean.instToSnapshotTreeCommandFinishedSnapshot
- Lean.Language.Lean.instToSnapshotTreeCommandParsedSnapshot
- Lean.Language.Lean.instToSnapshotTreeHeaderParsedSnapshot
- Lean.Language.Lean.instToSnapshotTreeHeaderProcessedSnapshot
- Lean.Language.instToSnapshotTreeDynamicSnapshot
- Lean.Language.instToSnapshotTreeOption
- Lean.Language.instToSnapshotTreeSnapshotLeaf
Equations
- Lean.Language.instToSnapshotTreeOption = { toSnapshotTree := fun (x : Option α) => match x with | some a => Lean.Language.toSnapshotTree a | none => default }
Snapshot type without child nodes.
Equations
- Lean.Language.instToSnapshotTreeSnapshotLeaf = { toSnapshotTree := fun (s : Lean.Language.SnapshotLeaf) => Lean.Language.SnapshotTree.mk s.toSnapshot #[] }
Arbitrary snapshot type, used for extensibility.
- val : Dynamic
Concrete snapshot value as
Dynamic
. - tree : Lean.Language.SnapshotTree
Snapshot tree retrieved from
val
before erasure.
Equations
- Lean.Language.instToSnapshotTreeDynamicSnapshot = { toSnapshotTree := fun (s : Lean.Language.DynamicSnapshot) => s.tree }
Creates a DynamicSnapshot
from a typed snapshot value.
Equations
- Lean.Language.DynamicSnapshot.ofTyped val = { val := Dynamic.mk val, tree := Lean.Language.toSnapshotTree val }
Returns the original snapshot value if it is of the given type.
Equations
- Lean.Language.DynamicSnapshot.toTyped? α snap = Dynamic.get? α snap.val
Equations
- One or more equations did not get rendered due to their size.
Runs a tree of snapshots to conclusion, incrementally performing f
on each snapshot in tree
preorder.
Option for printing end position of each message in addition to start position. Used for testing message ranges in the test suite.
Reports messages on stdout. If json
is true, prints messages as JSON (one per line).
Equations
- One or more equations did not get rendered due to their size.
Runs a tree of snapshots to conclusion and incrementally report messages on stdout. Messages are
reported in tree preorder.
This function is used by the cmdline driver; see Lean.Server.FileWorker.reportSnapshots
for how
the language server reports snapshots asynchronously.
Equations
- s.runAndReport opts json = s.forM fun (x : Lean.Language.Snapshot) => Lean.Language.reportMessages x.diagnostics.msgLog opts json
Waits on and returns all snapshots in the tree.
Equations
- s.getAll = (StateT.run (s.forM fun (s : Lean.Language.Snapshot) => modify fun (x : Array Lean.Language.Snapshot) => x.push s) #[]).snd
Context of an input processing invocation.
Monad transformer holding all relevant data for processing.
Equations
Monad holding all relevant data for processing.
Instances For
Equations
- Lean.Language.instMonadLiftProcessingMProcessingTIO = { monadLift := fun {α : Type} (act : Lean.Language.ProcessingM α) (ctx : Lean.Language.ProcessingContext) => liftM (act ctx) }
Creates snapshot message log from non-interactive message log, also allocating a mutable cell that can be used by the server to memorize interactive diagnostics derived from the log.
Equations
- Lean.Language.Snapshot.Diagnostics.ofMessageLog msgLog = do let __do_lift ← IO.mkRef none pure { msgLog := msgLog, interactiveDiagsRef? := some __do_lift }
Creates diagnostics from a single error message that should span the whole file.
Equations
- One or more equations did not get rendered due to their size.
Adds unexpected exceptions from header processing to the message log as a last resort; standard errors should already have been caught earlier.
Equations
- One or more equations did not get rendered due to their size.
Builds a function for processing a language using incremental snapshots by passing the previous
snapshot to Language.process
on subsequent invocations.
Equations
- One or more equations did not get rendered due to their size.