feat: Lean.Linter.logLintIf (#2852)
A utility function moving from Mathlib.
This commit is contained in:
parent
007b1b5979
commit
ac73c8d342
1 changed files with 6 additions and 0 deletions
|
|
@ -10,6 +10,12 @@ def logLint [Monad m] [MonadLog m] [AddMessageContext m] [MonadOptions m]
|
|||
(linterOption : Lean.Option Bool) (stx : Syntax) (msg : MessageData) : m Unit :=
|
||||
logWarningAt stx (.tagged linterOption.name m!"{msg} [{linterOption.name}]")
|
||||
|
||||
/-- If `linterOption` is true, print a linter warning message at the position determined by `stx`.
|
||||
-/
|
||||
def logLintIf [Monad m] [MonadLog m] [AddMessageContext m] [MonadOptions m]
|
||||
(linterOption : Lean.Option Bool) (stx : Syntax) (msg : MessageData) : m Unit := do
|
||||
if linterOption.get (← getOptions) then logLint linterOption stx msg
|
||||
|
||||
/-- Go upwards through the given `tree` starting from the smallest node that
|
||||
contains the given `range` and collect all `MacroExpansionInfo`s on the way up.
|
||||
The result is `some []` if no `MacroExpansionInfo` was found on the way and
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue