Skip to content

LSP: code action framework (specs/lsp/code_actions.t27) #12234

Closed

Description

@gHashTag

The code action framework: the lightbulb. This module owns the protocol side only (kinds, filtering, preferred and disabled actions, lazy edits, resolve, commands); the actions themselves come from the modules for use hygiene (specs/lsp/use_actions.t27), refactorings (specs/lsp/refactor.t27) and lint fixes (specs/lsp/lint.t27). Part of the LSP epic, Refs #12209 (wave 1, standard features). Only .t27: no code in any other language, not even scratch probes or a loader; see skill only-t27.

Prior art:

Boundary

  • specs/lsp/code_actions.t27

User Scenarios

  • Given the cursor on a diagnostic that has a fix, when the client sends textDocument/codeAction with context.diagnostics and only: ["quickfix"], then the answer holds the quick fixes for that diagnostic only, with the best one marked isPreferred.
  • Given a request with only: ["refactor"], when the module answers, then it returns kinds refactor.extract, refactor.inline, refactor.rewrite and refactor.move but no quickfix and no source.*.
  • Given an action whose edit is expensive, when it is listed, then it has no edit, only data; when the client sends codeAction/resolve, then the edit is computed and returned.
  • Given an action that cannot apply here, when the client supports disabled, then the action is listed with a disabled.reason.
  • Given 6 diagnostics of the same code in one file, when the client asks for source.fixAll, then one action fixes all 6 in a single WorkspaceEdit.

Requirements

  • FR-001: The module MUST define the kinds t27 uses as one table: quickfix, refactor, refactor.extract, refactor.inline, refactor.rewrite, refactor.move, source, source.organizeImports, source.fixAll and source.fixAll.t27, and MUST filter by context.only with prefix semantics.
  • FR-002: The module MUST register providers (a name, the kinds it can produce, a function from snapshot, range and diagnostics to actions) and MUST run only providers whose kinds match only.
  • FR-003: Actions MUST be returned without edit when the provider marks them lazy, and codeAction/resolve MUST fill in edit from data without re-running the other providers.
  • FR-004: The module MUST support isPreferred, disabled, diagnostics linkage, command and triggerKind (invoked or automatic).
  • FR-005: Every returned edit MUST apply cleanly: a test applies each edit from every provider to its fixture and re-analyses with 0 new errors.
  • FR-006: The module MUST NOT contain a provider; adding one is a one-line registration in the module that owns the action.

Success Criteria

  • At least 25 tests in specs/lsp/code_actions.t27 pass, run on the lab with t27c test-report (exit 0), using 3 stub providers registered in the test.
  • A negative control asks for only: ["source.organizeImports"] and asserts that no quickfix provider ran (counted by the stubs).
  • git diff --name-only master lists only specs/lsp/code_actions.t27 (0 files in other languages).

Activity

  1. gHashTag commented on Nov 17, 2026

    @gHashTag
    CollaboratorAuthor

    LSP spec created (typecheck OK, tests pass).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/specs.t27 spec files and conformanceenhancementNew feature or requestspec

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions