This PR adds core metaprogramming functions for forking off background tasks from elaboration such that their results are visible to reporting and the language server
29 lines
985 B
Text
29 lines
985 B
Text
/-
|
|
Copyright (c) 2023 Lean FRO. All rights reserved.
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
Additional snapshot functionality that needs further imports.
|
|
|
|
Authors: Sebastian Ullrich
|
|
-/
|
|
|
|
prelude
|
|
import Lean.Language.Basic
|
|
import Lean.CoreM
|
|
import Lean.Elab.InfoTree
|
|
|
|
namespace Lean.Language
|
|
|
|
/-- Produces trace of given snapshot tree, synchronously waiting on all children. -/
|
|
partial def SnapshotTree.trace (s : SnapshotTree) : CoreM Unit :=
|
|
go none s
|
|
where go range? s := do
|
|
let file ← getFileMap
|
|
let mut desc := f!"{s.element.desc}"
|
|
if let some range := range? then
|
|
desc := desc ++ f!"{file.toPosition range.start}-{file.toPosition range.stop} "
|
|
desc := desc ++ .prefixJoin "\n• " (← s.element.diagnostics.msgLog.toList.mapM (·.toString))
|
|
if let some t := s.element.infoTree? then
|
|
trace[Elab.info] (← t.format)
|
|
withTraceNode `Elab.snapshotTree (fun _ => pure desc) do
|
|
s.children.toList.forM fun c => go c.range? c.get
|