# Documentation

Lean.Widget.InteractiveDiagnostic

inductive Lean.Widget.StrictOrLazy (α : Type) (β : Type) :
• strict: {α β : Type} → α
• lazy: {α β : Type} → β
Instances For
instance Lean.Widget.instInhabitedStrictOrLazy :
{a : Type} → [inst : ] → {a_1 : Type} →
Equations
• Lean.Widget.instInhabitedStrictOrLazy = { default := }
instance Lean.Widget.instRpcEncodableStrictOrLazy {α : Type} {β : Type} [inst : ] [inst : ] :
Equations
• Lean.Widget.instRpcEncodableStrictOrLazy = { rpcEncode := Lean.Widget.instRpcEncodableStrictOrLazy.enc✝, rpcDecode := Lean.Widget.instRpcEncodableStrictOrLazy.dec✝ }
• indent : Nat
• children :
Instances For
• A piece of Lean code with elaboration/typing data. Note: does not necessarily correspond to an Expr, the name is for RPC API compatibility.

expr:
• An interactive goal display.

goal:
• Some messages (in particular, traces) are too costly to print eagerly. Instead, we allow the user to expand sub-traces interactively.

trace: NatLean.NameBool
Instances For
@[inline]

The message field is the text of a message possibly containing interactive embeds of type MsgEmbed. We maintain the invariant that embeds are stored in .tags with empty .text subtrees, i.e. .tag embed (.text ""), because a MsgEmbed display involve more than just text.

Equations
Equations
• Lean.Widget.instRpcEncodableDiagnosticWith = { rpcEncode := Lean.Widget.instRpcEncodableDiagnosticWith.enc✝, rpcDecode := Lean.Widget.instRpcEncodableDiagnosticWith.dec✝ }
Equations
• One or more equations did not get rendered due to their size.
Equations
• One or more equations did not get rendered due to their size.

The msgToInteractive algorithm turns a MessageData into TaggedText MsgEmbed in two stages.

First, in msgToInteractiveAux we produce a Format object whose .tag nodes refer to EmbedFmt objects stored in an auxiliary array. Only the most shallow .tag in every branch through the Format corresponds to an EmbedFmt. The kind of this tag determines how the nested Format object (possibly including further .tags), is processed. For example, if the output is .tag (.expr ctx infos) fmt then tags in the nested fmt object refer to elements of infos.

In the second stage, we recursively transform such a Format into TaggedText MsgEmbed according to the rule above by first pretty-printing it and then grabbing data referenced by the tags from all the nested arrays (such as the infos array in the example above).

We cannot easily do the translation in a single MessageData → TaggedText MsgEmbed→ TaggedText MsgEmbed step because that would effectively require reimplementing the (stateful, to keep track of indentation) Format.prettyM algorithm.

Equations
def Lean.Widget.msgToInteractive (msgData : Lean.MessageData) (hasWidgets : Bool) (indent : ) :
Equations
• One or more equations did not get rendered due to their size.
partial def Lean.Widget.msgToInteractive.fmtToTT (embeds : ) (fmt : Lean.Format) (indent : Nat) :

Transform a Lean Message concerning the given text into an LSP Diagnostic.

Equations
• One or more equations did not get rendered due to their size.