File: .lake/packages/lean4/src/lean/Lean/Server/CodeActions/Basic.lean

full_name: Lean.Server.LazyCodeAction.eager
code: /-- A code action optionally supporting a lazy code action computation that is only run when the user clicks on
the code action in the editor.

If you want to use the lazy feature, make sure that the `edit?` field on the `eager` code action result is `none`.
 -/
structure LazyCodeAction where
  /-- This is the initial code action that is sent to the server, to implement -/
  eager : CodeAction
  lazy? : Option (IO CodeAction) := none
goal: Lean.Lsp.CodeAction

full_name: Lean.Server.LazyCodeAction.lazy?
code: /-- A code action optionally supporting a lazy code action computation that is only run when the user clicks on
the code action in the editor.

If you want to use the lazy feature, make sure that the `edit?` field on the `eager` code action result is `none`.
 -/
structure LazyCodeAction where
  /-- This is the initial code action that is sent to the server, to implement -/
  eager : CodeAction
  lazy? : Option (IO CodeAction) := none
goal: Option (IO Lean.Lsp.CodeAction)

full_name: Lean.Server.LazyCodeAction
code: /-- A code action optionally supporting a lazy code action computation that is only run when the user clicks on
the code action in the editor.

If you want to use the lazy feature, make sure that the `edit?` field on the `eager` code action result is `none`.
 -/
structure LazyCodeAction where
  /-- This is the initial code action that is sent to the server, to implement -/
  eager : CodeAction
  lazy? : Option (IO CodeAction) := none
goal: Type

full_name: Lean.Server.CodeActionResolveData
code: /-- Passed as the `data?` field of `Lsp.CodeAction` to recover the context of the code action. -/
structure CodeActionResolveData where
  params : CodeActionParams
  /-- Name of CodeActionProvider that produced this request. -/
  providerName : Name
  /-- Index in the list of code action that the given provider generated. -/
  providerResultIndex : Nat
  deriving ToJson, FromJson
goal: Type

full_name: Lean.Server.CodeActionResolveData.providerName
code: /-- Passed as the `data?` field of `Lsp.CodeAction` to recover the context of the code action. -/
structure CodeActionResolveData where
  params : CodeActionParams
  /-- Name of CodeActionProvider that produced this request. -/
  providerName : Name
  /-- Index in the list of code action that the given provider generated. -/
  providerResultIndex : Nat
  deriving ToJson, FromJson
goal: Lean.Name

full_name: Lean.Server.CodeActionResolveData.providerResultIndex
code: /-- Passed as the `data?` field of `Lsp.CodeAction` to recover the context of the code action. -/
structure CodeActionResolveData where
  params : CodeActionParams
  /-- Name of CodeActionProvider that produced this request. -/
  providerName : Name
  /-- Index in the list of code action that the given provider generated. -/
  providerResultIndex : Nat
  deriving ToJson, FromJson
goal: Nat

full_name: Lean.Server.CodeActionResolveData.params
code: /-- Passed as the `data?` field of `Lsp.CodeAction` to recover the context of the code action. -/
structure CodeActionResolveData where
  params : CodeActionParams
  /-- Name of CodeActionProvider that produced this request. -/
  providerName : Name
  /-- Index in the list of code action that the given provider generated. -/
  providerResultIndex : Nat
  deriving ToJson, FromJson
goal: Lean.Lsp.CodeActionParams

full_name: Lean.Server.instToJsonCodeActionResolveData
code: ToJson
goal: Lean.ToJson Lean.Server.CodeActionResolveData

full_name: Lean.Server.instFromJsonCodeActionResolveData
code: FromJson
goal: Lean.FromJson Lean.Server.CodeActionResolveData

full_name: Lean.Server.CodeAction.getFileSource!
code: def CodeAction.getFileSource! (ca : CodeAction) : DocumentUri 
goal: Lean.Lsp.DocumentUri

full_name: Lean.Server.«instFileSourceCodeAction_.lake»
code: instance : FileSource CodeAction 
goal: Lean.Lsp.FileSource Lean.Lsp.CodeAction

full_name: Lean.Server.instCoeCodeActionLazyCodeAction
code: instance : Coe CodeAction LazyCodeAction 
goal: Coe Lean.Lsp.CodeAction Lean.Server.LazyCodeAction

full_name: Lean.Server.CodeActionProvider
code: /-- A code action provider is a function for providing LSP code actions for an editor.
You can register them with the `@[code_action_provider]` attribute.

This is a low-level interface for making LSP code actions.
This interface can be used to implement the following applications:
- refactoring code: adding underscores to unused variables,
- suggesting imports
- document-level refactoring: removing unused imports, sorting imports, formatting.
- Helper suggestions for working with type holes (`_`)
- Helper suggestions for tactics.

When implementing your own `CodeActionProvider`, we assume that no long-running computations are allowed.
If you need to create a code-action with a long-running computation, you can use the `lazy?` field on `LazyCodeAction`
to perform the computation after the user has clicked on the code action in their editor.
-/
def CodeActionProvider 
goal: Type

full_name: Lean.Server.initFn._@..lake.packages.lean4.src.lean.Lean.Server.CodeActions.Basic._hyg.401
code: private builtin_initialize builtinCodeActionProviders : IO.Ref (NameMap CodeActionProvider) ←
  IO.mkRef ∅
goal: IO (IO.Ref (Lean.NameMap Lean.Server.CodeActionProvider))

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Server.CodeActions.Basic.0.Lean.Server.builtinCodeActionProviders
code: private builtin_initialize builtinCodeActionProviders : IO.Ref (NameMap CodeActionProvider) ←
  IO.mkRef ∅
goal: IO.Ref (Lean.NameMap Lean.Server.CodeActionProvider)

full_name: Lean.Server.addBuiltinCodeActionProvider
code: def addBuiltinCodeActionProvider (decl : Name) (provider : CodeActionProvider) : IO Unit 
goal: IO Unit

full_name: Lean.Server.codeActionProviderExt
code: builtin_initialize codeActionProviderExt : SimplePersistentEnvExtension Name NameSet ← registerSimplePersistentEnvExtension {
  addImportedFn := fun nss => nss.foldl (fun acc ns => ns.foldl NameSet.insert acc) ∅
  addEntryFn := fun s n => s.insert n
  toArrayFn  := fun es => es.toArray.qsort Name.quickLt
}
goal: Lean.SimplePersistentEnvExtension Lean.Name Lean.NameSet

full_name: Lean.Server.initFn._@..lake.packages.lean4.src.lean.Lean.Server.CodeActions.Basic._hyg.449
code: builtin_initialize codeActionProviderExt : SimplePersistentEnvExtension Name NameSet ← registerSimplePersistentEnvExtension {
  addImportedFn := fun nss => nss.foldl (fun acc ns => ns.foldl NameSet.insert acc) ∅
  addEntryFn := fun s n => s.insert n
  toArrayFn  := fun es => es.toArray.qsort Name.quickLt
}
goal: IO (Lean.SimplePersistentEnvExtension Lean.Name Lean.NameSet)

full_name: Lean.Server.initFn._@..lake.packages.lean4.src.lean.Lean.Server.CodeActions.Basic._hyg.510
code: builtin_initialize
  let mkAttr (builtin : Bool) (name : Name) := registerBuiltinAttribute {
    name
    descr           := (if builtin then "(builtin) " else "") ++
      "Use to decorate methods for suggesting code actions. This is a low-level interface for making code actions."
    applicationTime := .afterCompilation
    add             := fun decl stx kind => do
      Attribute.Builtin.ensureNoArgs stx
      unless kind == AttributeKind.global do throwError "invalid attribute '{name}', must be global"
      unless (← getConstInfo decl).type.isConstOf ``CodeActionProvider do
        throwError "invalid attribute '{name}', must be of type `Lean.Server.CodeActionProvider`"
      let env ← getEnv
      if builtin then
        let h := mkConst decl
        declareBuiltin decl <| mkApp2 (mkConst ``addBuiltinCodeActionProvider) (toExpr decl) h
      else
        setEnv <| codeActionProviderExt.addEntry env decl
  }
  mkAttr true `builtin_code_action_provider
  mkAttr false `code_action_provider
goal: IO Unit

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Server.CodeActions.Basic.0.Lean.Server.evalCodeActionProviderUnsafe
code: private unsafe def evalCodeActionProviderUnsafe [MonadEnv M] [MonadOptions M] [MonadError M] [Monad M] (declName : Name) : M CodeActionProvider 
goal: M Lean.Server.CodeActionProvider

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Server.CodeActions.Basic.0.Lean.Server.evalCodeActionProvider
code: /-- Get a `CodeActionProvider` from a declaration name. -/
@[implemented_by evalCodeActionProviderUnsafe]
private opaque evalCodeActionProvider [MonadEnv M] [MonadOptions M] [MonadError M] [Monad M] (declName : Name) : M CodeActionProvider
goal: M Lean.Server.CodeActionProvider

full_name: Lean.Server.handleCodeAction
code: /-- Handles a `textDocument/codeAction` request.

This is implemented by calling all of the registered `CodeActionProvider` functions.

[reference](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_codeAction). -/
def handleCodeAction (params : CodeActionParams) : RequestM (RequestTask (Array CodeAction)) 
goal: Lean.Server.RequestM (Lean.Server.RequestTask (Array Lean.Lsp.CodeAction))

full_name: Lean.Server.initFn._@..lake.packages.lean4.src.lean.Lean.Server.CodeActions.Basic._hyg.1209
code: builtin_initialize
  registerLspRequestHandler "textDocument/codeAction" CodeActionParams (Array CodeAction) handleCodeAction
goal: IO Unit

full_name: Lean.Server.handleCodeActionResolve
code: /-- Handler for `"codeAction/resolve"`.

[reference](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeAction_resolve)
-/
def handleCodeActionResolve (param : CodeAction) : RequestM (RequestTask CodeAction) 
goal: Lean.Server.RequestM (Lean.Server.RequestTask Lean.Lsp.CodeAction)

full_name: Lean.Server.initFn._@..lake.packages.lean4.src.lean.Lean.Server.CodeActions.Basic._hyg.1541
code: builtin_initialize
  registerLspRequestHandler "codeAction/resolve" CodeAction CodeAction handleCodeActionResolve
goal: IO Unit