File: .lake/packages/lean4/src/lean/Lean/Server/InfoUtils.lean

full_name: Lean.Elab.InfoWithCtx
code: /-- Elaborator information with elaborator context.

It can be thought of as a "thunked" elaboration computation that allows us
to retroactively extract type information, symbol locations, etc.
through arbitrary invocations of `runMetaM` (where the necessary context and state
can be reconstructed from `ctx` and `info.lctx`).

W.r.t. widgets, this is used to tag different parts of expressions in `ppExprTagged`.
This is the input to the RPC call `Lean.Widget.InteractiveDiagnostics.infoToInteractive`.
It carries over information about delaborated
`Info` nodes in a `CodeWithInfos`, and the associated pretty-printing
functionality is purpose-specific to showing the contents of infoview popups.

For use in standard LSP go-to-definition (see `Lean.Server.FileWorker.locationLinksOfInfo`),
all the elaborator information we need for similar tasks is already fully recoverable via
the `InfoTree` structure (see `Lean.Elab.InfoTree.visitM`).
There we use this as a convenience wrapper for queried nodes (e.g. the return value of
`Lean.Elab.InfoTree.hoverableInfoAt?`). It also includes the children info nodes
as additional context (this is unused in the RPC case, as delaboration has no notion of child nodes).

NOTE: This type is for internal use in the infoview/LSP. It should not be used in user widgets.
-/
structure InfoWithCtx where
  ctx  : Elab.ContextInfo
  info : Elab.Info
  children : PersistentArray InfoTree
goal: Type

full_name: Lean.Elab.InfoWithCtx.ctx
code: /-- Elaborator information with elaborator context.

It can be thought of as a "thunked" elaboration computation that allows us
to retroactively extract type information, symbol locations, etc.
through arbitrary invocations of `runMetaM` (where the necessary context and state
can be reconstructed from `ctx` and `info.lctx`).

W.r.t. widgets, this is used to tag different parts of expressions in `ppExprTagged`.
This is the input to the RPC call `Lean.Widget.InteractiveDiagnostics.infoToInteractive`.
It carries over information about delaborated
`Info` nodes in a `CodeWithInfos`, and the associated pretty-printing
functionality is purpose-specific to showing the contents of infoview popups.

For use in standard LSP go-to-definition (see `Lean.Server.FileWorker.locationLinksOfInfo`),
all the elaborator information we need for similar tasks is already fully recoverable via
the `InfoTree` structure (see `Lean.Elab.InfoTree.visitM`).
There we use this as a convenience wrapper for queried nodes (e.g. the return value of
`Lean.Elab.InfoTree.hoverableInfoAt?`). It also includes the children info nodes
as additional context (this is unused in the RPC case, as delaboration has no notion of child nodes).

NOTE: This type is for internal use in the infoview/LSP. It should not be used in user widgets.
-/
structure InfoWithCtx where
  ctx  : Elab.ContextInfo
  info : Elab.Info
  children : PersistentArray InfoTree
goal: Lean.Elab.ContextInfo

full_name: Lean.Elab.InfoWithCtx.info
code: /-- Elaborator information with elaborator context.

It can be thought of as a "thunked" elaboration computation that allows us
to retroactively extract type information, symbol locations, etc.
through arbitrary invocations of `runMetaM` (where the necessary context and state
can be reconstructed from `ctx` and `info.lctx`).

W.r.t. widgets, this is used to tag different parts of expressions in `ppExprTagged`.
This is the input to the RPC call `Lean.Widget.InteractiveDiagnostics.infoToInteractive`.
It carries over information about delaborated
`Info` nodes in a `CodeWithInfos`, and the associated pretty-printing
functionality is purpose-specific to showing the contents of infoview popups.

For use in standard LSP go-to-definition (see `Lean.Server.FileWorker.locationLinksOfInfo`),
all the elaborator information we need for similar tasks is already fully recoverable via
the `InfoTree` structure (see `Lean.Elab.InfoTree.visitM`).
There we use this as a convenience wrapper for queried nodes (e.g. the return value of
`Lean.Elab.InfoTree.hoverableInfoAt?`). It also includes the children info nodes
as additional context (this is unused in the RPC case, as delaboration has no notion of child nodes).

NOTE: This type is for internal use in the infoview/LSP. It should not be used in user widgets.
-/
structure InfoWithCtx where
  ctx  : Elab.ContextInfo
  info : Elab.Info
  children : PersistentArray InfoTree
goal: Lean.Elab.Info

full_name: Lean.Elab.InfoWithCtx.children
code: /-- Elaborator information with elaborator context.

It can be thought of as a "thunked" elaboration computation that allows us
to retroactively extract type information, symbol locations, etc.
through arbitrary invocations of `runMetaM` (where the necessary context and state
can be reconstructed from `ctx` and `info.lctx`).

W.r.t. widgets, this is used to tag different parts of expressions in `ppExprTagged`.
This is the input to the RPC call `Lean.Widget.InteractiveDiagnostics.infoToInteractive`.
It carries over information about delaborated
`Info` nodes in a `CodeWithInfos`, and the associated pretty-printing
functionality is purpose-specific to showing the contents of infoview popups.

For use in standard LSP go-to-definition (see `Lean.Server.FileWorker.locationLinksOfInfo`),
all the elaborator information we need for similar tasks is already fully recoverable via
the `InfoTree` structure (see `Lean.Elab.InfoTree.visitM`).
There we use this as a convenience wrapper for queried nodes (e.g. the return value of
`Lean.Elab.InfoTree.hoverableInfoAt?`). It also includes the children info nodes
as additional context (this is unused in the RPC case, as delaboration has no notion of child nodes).

NOTE: This type is for internal use in the infoview/LSP. It should not be used in user widgets.
-/
structure InfoWithCtx where
  ctx  : Elab.ContextInfo
  info : Elab.Info
  children : PersistentArray InfoTree
goal: Lean.PersistentArray Lean.Elab.InfoTree

full_name: Lean.Elab.InfoTree.visitM
code: /-- Visit nodes, passing in a surrounding context (the innermost one combined with all outer ones)
and accumulating results on the way back up. -/
partial def InfoTree.visitM [Monad m]
    (preNode  : ContextInfo → Info → (children : PersistentArray InfoTree) → m Unit := fun _ _ _ => pure ())
    (postNode : ContextInfo → Info → (children : PersistentArray InfoTree) → List (Option α) → m α)
    : InfoTree → m (Option α) 
goal: Lean.Elab.InfoTree → m (Option α)

full_name: Lean.Elab.InfoTree.visitM.go
code: /-- Visit nodes, passing in a surrounding context (the innermost one combined with all outer ones)
and accumulating results on the way back up. -/
partial def InfoTree.visitM [Monad m]
    (preNode  : ContextInfo → Info → (children : PersistentArray InfoTree) → m Unit := fun _ _ _ => pure ())
    (postNode : ContextInfo → Info → (children : PersistentArray InfoTree) → List (Option α) → m α)
    : InfoTree → m (Option α) 
goal: Option Lean.Elab.ContextInfo → Lean.Elab.InfoTree → m (Option α)

full_name: Lean.Elab.InfoTree.visitM'
code: /-- `InfoTree.visitM` specialized to `Unit` return type -/
def InfoTree.visitM' [Monad m]
    (preNode  : ContextInfo → Info → (children : PersistentArray InfoTree) → m Unit := fun _ _ _ => pure ())
    (postNode : ContextInfo → Info → (children : PersistentArray InfoTree) → m Unit := fun _ _ _ => pure ())
    (t : InfoTree) : m Unit 
goal: m Unit

full_name: Lean.Elab.InfoTree.collectNodesBottomUp
code: /--
  Visit nodes bottom-up, passing in a surrounding context (the innermost one) and the union of nested results (empty at leaves). -/
def InfoTree.collectNodesBottomUp (p : ContextInfo → Info → PersistentArray InfoTree → List α → List α) (i : InfoTree) : List α 
goal: List α

full_name: Lean.Elab.InfoTree.deepestNodes
code: /--
  For every branch of the `InfoTree`, find the deepest node in that branch for which `p` returns
  `some _`  and return the union of all such nodes. The visitor `p` is given a node together with
  its innermost surrounding `ContextInfo`. -/
partial def InfoTree.deepestNodes (p : ContextInfo → Info → PersistentArray InfoTree → Option α) (infoTree : InfoTree) : List α 
goal: List α

full_name: Lean.Elab.InfoTree.foldInfo
code: partial def InfoTree.foldInfo (f : ContextInfo → Info → α → α) (init : α) : InfoTree → α 
goal: Lean.Elab.InfoTree → α

full_name: Lean.Elab.InfoTree.foldInfo.go
code: partial def InfoTree.foldInfo (f : ContextInfo → Info → α → α) (init : α) : InfoTree → α 
goal: Lean.Elab.InfoTree → α

full_name: Lean.Elab.InfoTree.foldInfoTree.go
code: /--
Fold an info tree as follows, while ensuring that the correct `ContextInfo` is supplied at each stage:

 * Nodes are combined with the initial value `init` using `f`, and the result is then combined with the children using a left fold
 * On InfoTree holes, we just return the initial value.

This is like `InfoTree.foldInfo`, but it also passes the whole node to `f` instead of just the head.
-/
partial def InfoTree.foldInfoTree (init : α) (f : ContextInfo → InfoTree → α → α) : InfoTree → α 
goal: Lean.Elab.InfoTree → α

full_name: Lean.Elab.InfoTree.foldInfoTree
code: /--
Fold an info tree as follows, while ensuring that the correct `ContextInfo` is supplied at each stage:

 * Nodes are combined with the initial value `init` using `f`, and the result is then combined with the children using a left fold
 * On InfoTree holes, we just return the initial value.

This is like `InfoTree.foldInfo`, but it also passes the whole node to `f` instead of just the head.
-/
partial def InfoTree.foldInfoTree (init : α) (f : ContextInfo → InfoTree → α → α) : InfoTree → α 
goal: Lean.Elab.InfoTree → α

full_name: Lean.Elab.Info.isTerm
code: def Info.isTerm : Info → Bool
  
goal: Lean.Elab.Info → Bool

full_name: Lean.Elab.Info.isCompletion
code: def Info.isCompletion : Info → Bool
  
goal: Lean.Elab.Info → Bool

full_name: Lean.Elab.InfoTree.getCompletionInfos
code: def InfoTree.getCompletionInfos (infoTree : InfoTree) : Array (ContextInfo × CompletionInfo) 
goal: Array (Lean.Elab.ContextInfo × Lean.Elab.CompletionInfo)

full_name: Lean.Elab.Info.stx
code: def Info.stx : Info → Syntax
  
goal: Lean.Elab.Info → Lean.Syntax

full_name: Lean.Elab.Info.lctx
code: def Info.lctx : Info → LocalContext
  
goal: Lean.Elab.Info → Lean.LocalContext

full_name: Lean.Elab.Info.pos?
code: def Info.pos? (i : Info) : Option String.Pos 
goal: Option String.Pos

full_name: Lean.Elab.Info.tailPos?
code: def Info.tailPos? (i : Info) : Option String.Pos 
goal: Option String.Pos

full_name: Lean.Elab.Info.range?
code: def Info.range? (i : Info) : Option String.Range 
goal: Option String.Range

full_name: Lean.Elab.Info.contains
code: def Info.contains (i : Info) (pos : String.Pos) (includeStop := false) : Bool 
goal: Bool

full_name: Lean.Elab.Info.size?
code: def Info.size? (i : Info) : Option String.Pos 
goal: Option String.Pos

full_name: Lean.Elab.Info.isSmaller
code: def Info.isSmaller (i₁ i₂ : Info) : Bool 
goal: Bool

full_name: Lean.Elab.Info.occursDirectlyBefore
code: def Info.occursDirectlyBefore (i : Info) (hoverPos : String.Pos) : Bool 
goal: Bool

full_name: Lean.Elab.Info.occursInside?
code: def Info.occursInside? (i : Info) (hoverPos : String.Pos) : Option String.Pos 
goal: Option String.Pos

full_name: Lean.Elab.InfoTree.smallestInfo?
code: def InfoTree.smallestInfo? (p : Info → Bool) (t : InfoTree) : Option (ContextInfo × Info) 
goal: Option (Lean.Elab.ContextInfo × Lean.Elab.Info)

full_name: Lean.Elab.InfoTree.hoverableInfoAt?
code: /-- Find an info node, if any, which should be shown on hover/cursor at position `hoverPos`. -/
partial def InfoTree.hoverableInfoAt? (t : InfoTree) (hoverPos : String.Pos) (includeStop := false) (omitAppFns := false) (omitIdentApps := false) : Option InfoWithCtx 
goal: Option Lean.Elab.InfoWithCtx

full_name: Lean.Elab.Info.type?
code: def Info.type? (i : Info) : MetaM (Option Expr) 
goal: Lean.MetaM (Option Lean.Expr)

full_name: Lean.Elab.Info.docString?
code: def Info.docString? (i : Info) : MetaM (Option String) 
goal: Lean.MetaM (Option String)

full_name: Lean.Elab.Info.fmtHover?.isAtomicFormat
code: /-- Construct a hover popup, if any, from an info node in a context.-/
def Info.fmtHover? (ci : ContextInfo) (i : Info) : IO (Option FormatWithInfos) 
goal: Lean.Format → Bool

full_name: Lean.Elab.Info.fmtHover?.fmtTermAndModule?
code: /-- Construct a hover popup, if any, from an info node in a context.-/
def Info.fmtHover? (ci : ContextInfo) (i : Info) : IO (Option FormatWithInfos) 
goal: Lean.MetaM (Option Lean.FormatWithInfos × Option Lean.Format)

full_name: Lean.Elab.Info.fmtHover?
code: /-- Construct a hover popup, if any, from an info node in a context.-/
def Info.fmtHover? (ci : ContextInfo) (i : Info) : IO (Option FormatWithInfos) 
goal: IO (Option Lean.FormatWithInfos)

full_name: Lean.Elab.Info.fmtHover?.fmtModule?
code: /-- Construct a hover popup, if any, from an info node in a context.-/
def Info.fmtHover? (ci : ContextInfo) (i : Info) : IO (Option FormatWithInfos) 
goal: Lean.MetaM (Option Lean.Format)

full_name: Lean.Elab.GoalsAtResult.ctxInfo
code: structure GoalsAtResult where
  ctxInfo    : ContextInfo
  tacticInfo : TacticInfo
  useAfter   : Bool
  /-- Whether the tactic info is further indented than the hover position. -/
  indented   : Bool
  -- for overlapping goals, only keep those of the highest reported priority
  priority   : Nat
goal: Lean.Elab.ContextInfo

full_name: Lean.Elab.GoalsAtResult.tacticInfo
code: structure GoalsAtResult where
  ctxInfo    : ContextInfo
  tacticInfo : TacticInfo
  useAfter   : Bool
  /-- Whether the tactic info is further indented than the hover position. -/
  indented   : Bool
  -- for overlapping goals, only keep those of the highest reported priority
  priority   : Nat
goal: Lean.Elab.TacticInfo

full_name: Lean.Elab.GoalsAtResult.indented
code: structure GoalsAtResult where
  ctxInfo    : ContextInfo
  tacticInfo : TacticInfo
  useAfter   : Bool
  /-- Whether the tactic info is further indented than the hover position. -/
  indented   : Bool
  -- for overlapping goals, only keep those of the highest reported priority
  priority   : Nat
goal: Bool

full_name: Lean.Elab.GoalsAtResult.useAfter
code: structure GoalsAtResult where
  ctxInfo    : ContextInfo
  tacticInfo : TacticInfo
  useAfter   : Bool
  /-- Whether the tactic info is further indented than the hover position. -/
  indented   : Bool
  -- for overlapping goals, only keep those of the highest reported priority
  priority   : Nat
goal: Bool

full_name: Lean.Elab.GoalsAtResult.priority
code: structure GoalsAtResult where
  ctxInfo    : ContextInfo
  tacticInfo : TacticInfo
  useAfter   : Bool
  /-- Whether the tactic info is further indented than the hover position. -/
  indented   : Bool
  -- for overlapping goals, only keep those of the highest reported priority
  priority   : Nat
goal: Nat

full_name: Lean.Elab.GoalsAtResult
code: structure GoalsAtResult where
  ctxInfo    : ContextInfo
  tacticInfo : TacticInfo
  useAfter   : Bool
  /-- Whether the tactic info is further indented than the hover position. -/
  indented   : Bool
  -- for overlapping goals, only keep those of the highest reported priority
  priority   : Nat
goal: Type

full_name: Lean.Elab.InfoTree.goalsAt?.isEmptyBy
code: /--
  Try to retrieve `TacticInfo` for `hoverPos`.
  We retrieve all `TacticInfo` nodes s.t. `hoverPos` is inside the node's range plus trailing whitespace.
  We usually prefer the innermost such nodes so that for composite tactics such as `induction`, we show the nested proofs' states.
  However, if `hoverPos` is after the tactic, we prefer nodes that are not indented relative to it, meaning that e.g. at `|` in
  ```lean
  have := by
    exact foo
  |
  ```
  we show the (final, see below) state of `have`, not `exact`.

  Moreover, we instruct the LSP server to use the state after tactic execution if
  - the hover position is after the info's start position *and*
  - there is no nested tactic info after the hover position (tactic combinators should decide for themselves
    where to show intermediate states by calling `withTacticInfoContext`) -/
partial def InfoTree.goalsAt? (text : FileMap) (t : InfoTree) (hoverPos : String.Pos) : List GoalsAtResult 
goal: Bool

full_name: Lean.Elab.InfoTree.goalsAt?.hasNestedTactic
code: /--
  Try to retrieve `TacticInfo` for `hoverPos`.
  We retrieve all `TacticInfo` nodes s.t. `hoverPos` is inside the node's range plus trailing whitespace.
  We usually prefer the innermost such nodes so that for composite tactics such as `induction`, we show the nested proofs' states.
  However, if `hoverPos` is after the tactic, we prefer nodes that are not indented relative to it, meaning that e.g. at `|` in
  ```lean
  have := by
    exact foo
  |
  ```
  we show the (final, see below) state of `have`, not `exact`.

  Moreover, we instruct the LSP server to use the state after tactic execution if
  - the hover position is after the info's start position *and*
  - there is no nested tactic info after the hover position (tactic combinators should decide for themselves
    where to show intermediate states by calling `withTacticInfoContext`) -/
partial def InfoTree.goalsAt? (text : FileMap) (t : InfoTree) (hoverPos : String.Pos) : List GoalsAtResult 
goal: Lean.Elab.InfoTree → Bool

full_name: Lean.Elab.InfoTree.goalsAt?
code: /--
  Try to retrieve `TacticInfo` for `hoverPos`.
  We retrieve all `TacticInfo` nodes s.t. `hoverPos` is inside the node's range plus trailing whitespace.
  We usually prefer the innermost such nodes so that for composite tactics such as `induction`, we show the nested proofs' states.
  However, if `hoverPos` is after the tactic, we prefer nodes that are not indented relative to it, meaning that e.g. at `|` in
  ```lean
  have := by
    exact foo
  |
  ```
  we show the (final, see below) state of `have`, not `exact`.

  Moreover, we instruct the LSP server to use the state after tactic execution if
  - the hover position is after the info's start position *and*
  - there is no nested tactic info after the hover position (tactic combinators should decide for themselves
    where to show intermediate states by calling `withTacticInfoContext`) -/
partial def InfoTree.goalsAt? (text : FileMap) (t : InfoTree) (hoverPos : String.Pos) : List GoalsAtResult 
goal: List Lean.Elab.GoalsAtResult

full_name: Lean.Elab.InfoTree.termGoalAt?
code: partial def InfoTree.termGoalAt? (t : InfoTree) (hoverPos : String.Pos) : Option InfoWithCtx 
goal: Option Lean.Elab.InfoWithCtx

full_name: Lean.Elab.InfoTree.hasSorry.go
code: partial def InfoTree.hasSorry : InfoTree → IO Bool 
goal: Lean.Elab.InfoTree → IO Bool

full_name: Lean.Elab.InfoTree.hasSorry
code: partial def InfoTree.hasSorry : InfoTree → IO Bool 
goal: Lean.Elab.InfoTree → IO Bool