feat: store subexpression positions

This commit is contained in:
Wojciech Nawrocki 2022-05-18 16:11:04 -04:00 committed by Sebastian Ullrich
parent 25a8646a5f
commit e555490ee2

View file

@ -22,7 +22,11 @@ structure InfoWithCtx where
deriving Inhabited, RpcEncoding with { withRef := true }
structure CodeToken where
/-- The `Elab.Info` node with the semantics of this part of the output. -/
info : WithRpcRef InfoWithCtx
/-- The position of this subexpression within the top-level expression.
See `Lean.PrettyPrinter.Delaborator.SubExpr`. -/
subexprPos : Nat
-- TODO(WN): add fields for semantic highlighting
-- kind : Lsp.SymbolKind
deriving Inhabited, RpcEncoding
@ -42,7 +46,7 @@ where
tt.rewrite fun (n, _) subTt =>
match infos.find? n with
| none => go subTt
| some i => TaggedText.tag ⟨WithRpcRef.mk { ctx, info := i }⟩ (go subTt)
| some i => TaggedText.tag ⟨WithRpcRef.mk { ctx, info := i }, n⟩ (go subTt)
def exprToInteractive (e : Expr) (explicit : Bool := false) : MetaM CodeWithInfos := do
let optsPerPos := if explicit then