Skip to content

Commit

Permalink
feat: highlight proof states without embedding them in terms (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
david-christiansen authored Sep 10, 2024
1 parent b96f12c commit 82bdbe1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/highlighting/SubVerso/Highlighting/Code.lean
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,12 @@ structure HighlightState where
inMessages : List (MessageBundle ⊕ OpenTactic)
deriving Inhabited

def HighlightState.empty : HighlightState where
messages := #[]
nextMessage := none
output := []
inMessages := []

def HighlightState.ofMessages [Monad m] [MonadFileMap m]
(stx : Syntax) (messages : Array Message) : m HighlightState := do
let msgs ← bundleMessages <$> messages.filterM (isRelevant stx)
Expand Down Expand Up @@ -777,3 +783,9 @@ def highlight (stx : Syntax) (messages : Array Message) (trees : PersistentArray
let st ← HighlightState.ofMessages stx messages
let ((), {output := output, ..}) ← StateT.run (highlight' ids trees stx true) st
pure <| .fromOutput output

def highlightProofState (ci : ContextInfo) (goals : List MVarId) (trees : PersistentArray Lean.Elab.InfoTree) : TermElabM (Array (Highlighted.Goal Highlighted)) := do
let modrefs := Lean.Server.findModuleRefs (← getFileMap) trees.toArray
let ids := build modrefs
let (hlGoals, _) ← StateT.run (highlightGoals ids ci goals) .empty
pure hlGoals

0 comments on commit 82bdbe1

Please sign in to comment.