File: .lake/packages/batteries/Batteries/CodeAction/Attr.lean

full_name: Std.CodeAction.TacticCodeAction
code: /-- A tactic code action extension. -/
abbrev TacticCodeAction 
goal: Type

full_name: Std.CodeAction.TacticSeqCodeAction
code: /-- A tactic code action extension. -/
abbrev TacticSeqCodeAction 
goal: Type

full_name: Std.CodeAction.mkTacticCodeAction
code: /-- Read a tactic code action from a declaration of the right type. -/
def mkTacticCodeAction (n : Name) : ImportM TacticCodeAction 
goal: Lean.ImportM Std.CodeAction.TacticCodeAction

full_name: Std.CodeAction.mkTacticSeqCodeAction
code: /-- Read a tacticSeq code action from a declaration of the right type. -/
def mkTacticSeqCodeAction (n : Name) : ImportM TacticSeqCodeAction 
goal: Lean.ImportM Std.CodeAction.TacticSeqCodeAction

full_name: Std.CodeAction.instInhabitedTacticCodeActionEntry
code: /-- An entry in the tactic code actions extension, containing the attribute arguments. -/
structure TacticCodeActionEntry where
  /-- The declaration to tag -/
  declName : Name
  /-- The tactic kinds that this extension supports. If empty it is called on all tactic kinds. -/
  tacticKinds : Array Name
  deriving Inhabited
goal: Inhabited Std.CodeAction.TacticCodeActionEntry

full_name: Std.CodeAction.TacticCodeActionEntry
code: /-- An entry in the tactic code actions extension, containing the attribute arguments. -/
structure TacticCodeActionEntry where
  /-- The declaration to tag -/
  declName : Name
  /-- The tactic kinds that this extension supports. If empty it is called on all tactic kinds. -/
  tacticKinds : Array Name
  deriving Inhabited
goal: Type

full_name: Std.CodeAction.TacticCodeActionEntry.declName
code: /-- An entry in the tactic code actions extension, containing the attribute arguments. -/
structure TacticCodeActionEntry where
  /-- The declaration to tag -/
  declName : Name
  /-- The tactic kinds that this extension supports. If empty it is called on all tactic kinds. -/
  tacticKinds : Array Name
  deriving Inhabited
goal: Lean.Name

full_name: Std.CodeAction.TacticCodeActionEntry.tacticKinds
code: /-- An entry in the tactic code actions extension, containing the attribute arguments. -/
structure TacticCodeActionEntry where
  /-- The declaration to tag -/
  declName : Name
  /-- The tactic kinds that this extension supports. If empty it is called on all tactic kinds. -/
  tacticKinds : Array Name
  deriving Inhabited
goal: Array Lean.Name

full_name: Std.CodeAction.TacticCodeActions
code: /-- The state of the tactic code actions extension. -/
structure TacticCodeActions where
  /-- The list of tactic code actions to apply on any tactic. -/
  onAnyTactic : Array TacticCodeAction := {}
  /-- The list of tactic code actions to apply when a particular tactic kind is highlighted. -/
  onTactic : NameMap (Array TacticCodeAction) := {}
  deriving Inhabited
goal: Type

full_name: Std.CodeAction.TacticCodeActions.onTactic
code: /-- The state of the tactic code actions extension. -/
structure TacticCodeActions where
  /-- The list of tactic code actions to apply on any tactic. -/
  onAnyTactic : Array TacticCodeAction := {}
  /-- The list of tactic code actions to apply when a particular tactic kind is highlighted. -/
  onTactic : NameMap (Array TacticCodeAction) := {}
  deriving Inhabited
goal: Lean.NameMap (Array Std.CodeAction.TacticCodeAction)

full_name: Std.CodeAction.TacticCodeActions.onAnyTactic
code: /-- The state of the tactic code actions extension. -/
structure TacticCodeActions where
  /-- The list of tactic code actions to apply on any tactic. -/
  onAnyTactic : Array TacticCodeAction := {}
  /-- The list of tactic code actions to apply when a particular tactic kind is highlighted. -/
  onTactic : NameMap (Array TacticCodeAction) := {}
  deriving Inhabited
goal: Array Std.CodeAction.TacticCodeAction

full_name: Std.CodeAction.instInhabitedTacticCodeActions
code: /-- The state of the tactic code actions extension. -/
structure TacticCodeActions where
  /-- The list of tactic code actions to apply on any tactic. -/
  onAnyTactic : Array TacticCodeAction := {}
  /-- The list of tactic code actions to apply when a particular tactic kind is highlighted. -/
  onTactic : NameMap (Array TacticCodeAction) := {}
  deriving Inhabited
goal: Inhabited Std.CodeAction.TacticCodeActions

full_name: Std.CodeAction.TacticCodeActions.insert
code: /-- Insert a tactic code action entry into the `TacticCodeActions` structure. -/
def TacticCodeActions.insert (self : TacticCodeActions)
    (tacticKinds : Array Name) (action : TacticCodeAction) : TacticCodeActions 
goal: Std.CodeAction.TacticCodeActions

full_name: Std.CodeAction.tacticSeqCodeActionExt
code: /-- An extension which collects all the tactic code actions. -/
initialize tacticSeqCodeActionExt :
    PersistentEnvExtension Name (Name × TacticSeqCodeAction)
      (Array Name × Array TacticSeqCodeAction) ←
  registerPersistentEnvExtension {
    mkInitial := pure (#[], #[])
    addImportedFn := fun as => return (#[], ← as.foldlM (init := #[]) fun m as =>
      as.foldlM (init := m) fun m a => return m.push (← mkTacticSeqCodeAction a))
    addEntryFn := fun (s₁, s₂) (n₁, n₂) => (s₁.push n₁, s₂.push n₂)
    exportEntriesFn := (·.1)
  }
goal: Lean.PersistentEnvExtension Lean.Name (Lean.Name × Std.CodeAction.TacticSeqCodeAction)
  (Array Lean.Name × Array Std.CodeAction.TacticSeqCodeAction)

full_name: Std.CodeAction.initFn._@..lake.packages.batteries.Batteries.CodeAction.Attr._hyg.302
code: /-- An extension which collects all the tactic code actions. -/
initialize tacticSeqCodeActionExt :
    PersistentEnvExtension Name (Name × TacticSeqCodeAction)
      (Array Name × Array TacticSeqCodeAction) ←
  registerPersistentEnvExtension {
    mkInitial := pure (#[], #[])
    addImportedFn := fun as => return (#[], ← as.foldlM (init := #[]) fun m as =>
      as.foldlM (init := m) fun m a => return m.push (← mkTacticSeqCodeAction a))
    addEntryFn := fun (s₁, s₂) (n₁, n₂) => (s₁.push n₁, s₂.push n₂)
    exportEntriesFn := (·.1)
  }
goal: IO
  (Lean.PersistentEnvExtension Lean.Name (Lean.Name × Std.CodeAction.TacticSeqCodeAction)
    (Array Lean.Name × Array Std.CodeAction.TacticSeqCodeAction))

full_name: Std.CodeAction.initFn._@..lake.packages.batteries.Batteries.CodeAction.Attr._hyg.519
code: /-- An extension which collects all the tactic code actions. -/
initialize tacticCodeActionExt :
    PersistentEnvExtension TacticCodeActionEntry (TacticCodeActionEntry × TacticCodeAction)
      (Array TacticCodeActionEntry × TacticCodeActions) ←
  registerPersistentEnvExtension {
    mkInitial := pure (#[], {})
    addImportedFn := fun as => return (#[], ← as.foldlM (init := {}) fun m as =>
      as.foldlM (init := m) fun m ⟨name, kinds⟩ =>
        return m.insert kinds (← mkTacticCodeAction name))
    addEntryFn := fun (s₁, s₂) (e, n₂) => (s₁.push e, s₂.insert e.tacticKinds n₂)
    exportEntriesFn := (·.1)
  }
goal: IO
  (Lean.PersistentEnvExtension Std.CodeAction.TacticCodeActionEntry
    (Std.CodeAction.TacticCodeActionEntry × Std.CodeAction.TacticCodeAction)
    (Array Std.CodeAction.TacticCodeActionEntry × Std.CodeAction.TacticCodeActions))

full_name: Std.CodeAction.tacticCodeActionExt
code: /-- An extension which collects all the tactic code actions. -/
initialize tacticCodeActionExt :
    PersistentEnvExtension TacticCodeActionEntry (TacticCodeActionEntry × TacticCodeAction)
      (Array TacticCodeActionEntry × TacticCodeActions) ←
  registerPersistentEnvExtension {
    mkInitial := pure (#[], {})
    addImportedFn := fun as => return (#[], ← as.foldlM (init := {}) fun m as =>
      as.foldlM (init := m) fun m ⟨name, kinds⟩ =>
        return m.insert kinds (← mkTacticCodeAction name))
    addEntryFn := fun (s₁, s₂) (e, n₂) => (s₁.push e, s₂.insert e.tacticKinds n₂)
    exportEntriesFn := (·.1)
  }
goal: Lean.PersistentEnvExtension Std.CodeAction.TacticCodeActionEntry
  (Std.CodeAction.TacticCodeActionEntry × Std.CodeAction.TacticCodeAction)
  (Array Std.CodeAction.TacticCodeActionEntry × Std.CodeAction.TacticCodeActions)

full_name: Std.CodeAction.tactic_code_action
code: /--
This attribute marks a code action, which is used to suggest new tactics or replace existing ones.

* `@[tactic_code_action]`: This is a code action which applies to the spaces between tactics,
  to suggest a new tactic to change the goal state.

* `@[tactic_code_action kind]`: This is a code action which applies to applications of the tactic
  `kind` (a tactic syntax kind), which can replace the tactic or insert things before or after it.

* `@[tactic_code_action kind₁ kind₂]`: shorthand for
  `@[tactic_code_action kind₁, tactic_code_action kind₂]`.

* `@[tactic_code_action *]`: This is a tactic code action that applies to all tactics.
  Use sparingly.
-/
syntax (name := tactic_code_action) "tactic_code_action" ("*" <|> (ppSpace ident)*) : attr
goal: Lean.ParserDescr

full_name: Std.CodeAction.initFn._@..lake.packages.batteries.Batteries.CodeAction.Attr._hyg.792
code: initialize
  registerBuiltinAttribute {
    name := `tactic_code_action
    descr := "Declare a new tactic code action, to appear in the code actions on tactics"
    applicationTime := .afterCompilation
    add := fun decl stx kind => do
      unless kind == AttributeKind.global do
        throwError "invalid attribute 'tactic_code_action', must be global"
      match stx with
      | `(attr| tactic_code_action *) =>
        if (IR.getSorryDep (← getEnv) decl).isSome then return -- ignore in progress definitions
        modifyEnv (tacticCodeActionExt.addEntry · (⟨decl, #[]⟩, ← mkTacticCodeAction decl))
      | `(attr| tactic_code_action $[$args]*) =>
        if args.isEmpty then
          if (IR.getSorryDep (← getEnv) decl).isSome then return -- ignore in progress definitions
          modifyEnv (tacticSeqCodeActionExt.addEntry · (decl, ← mkTacticSeqCodeAction decl))
        else
          let args ← args.mapM realizeGlobalConstNoOverloadWithInfo
          if (IR.getSorryDep (← getEnv) decl).isSome then return -- ignore in progress definitions
          modifyEnv (tacticCodeActionExt.addEntry · (⟨decl, args⟩, ← mkTacticCodeAction decl))
      | _ => pure ()
  }
goal: IO Unit