Repository navigation
Open
Labels
area/specs.t27 spec files and conformance.t27 spec files and conformanceenhancementNew feature or requestNew feature or requestspec
Description
Refactorings as code actions: extract, inline, rewrite, move, and generate. rust-analyzer ships about 168 assists, sourcekit-lsp 54 refactorings and Gleam about 45 code actions; the first 15 below are the ones users reach for daily. 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.
Depends on specs/lsp/code_actions.t27 (registration), specs/lsp/index.t27 and specs/lsp/rename.t27 (the edits that cross files reuse rename's reference walk).
Prior art:
- rust-analyzer assists catalogue: https://rust-analyzer.github.io/book/assists.html
- sourcekit-lsp refactorings: https://github.com/swiftlang/sourcekit-lsp
- Gleam language server code actions: https://gleam.run/documentation/language-server-reference
- gopls refactor kinds
extract,inline,rewrite,move: https://go.dev/gopls/
Boundary
- specs/lsp/refactor.t27
User Scenarios
- Given a selection of 3 statements that read 2 locals and produce 1 value, when the client asks for
refactor.extract, then an actionExtract functionis listed; applying it makes a function with 2 parameters returning the value and replaces the selection by a call. - Given the cursor on a call to a one-use private function, when the client asks for
refactor.inline, thenInline functionreplaces the call and deletes the function, andt27c checkstays green. - Given the cursor on a function with no test, when the client asks for
refactor.rewrite, thenGenerate testadds atestblock with the function's name and a placeholder assertion in the right place. - Given a declaration in spec A used only by spec B, when the client asks for
refactor.move, thenMove to Bmoves it, rewrites theuselines and leaves A compiling. - Given a selection that is not a refactorable range, when the action is requested, then it is listed as disabled with a reason, or not listed at all, never as an action that fails when applied.
Requirements
- FR-001: The module MUST register the actions: extract function, extract constant, extract variable, inline function, inline constant, inline variable, add missing enum cases, flip operands, invert condition, wrap in block, unwrap block, generate test, generate doc comment, move declaration, and rename to match file.
- FR-002: Each action MUST declare its kind, a precondition on the selection, and an edit builder; the table is in the module so the matrix can list it.
- FR-003: Every edit MUST preserve behaviour: a test per action applies it on a fixture, runs
t27c checkthrough the snapshot and asserts 0 new diagnostics, and for extract and inline asserts that the test results are unchanged. - FR-004: Actions MUST be lazy (
codeAction/resolve), and move MUST use a change annotation that asks the user for confirmation. - FR-005: A name introduced by an action MUST NOT clash with a name in scope; the module picks
name_2style names and says so in the title.
Success Criteria
- At least 40 tests in
specs/lsp/refactor.t27pass, run on the lab witht27c test-report(exit 0), at least 2 per action. - A negative control asks each action on a range where its precondition fails and asserts it is absent or disabled.
git diff --name-only masterlists onlyspecs/lsp/refactor.t27(0 files in other languages).
Metadata
Metadata
Assignees
Labels
area/specs.t27 spec files and conformance.t27 spec files and conformanceenhancementNew feature or requestNew feature or requestspec
Activity
gHashTag commentedon Nov 17, 2026
Spec created: specs/lsp/refactor.t27 (typecheck OK, 1 test pass).
gHashTag commentedon Nov 17, 2026
Reopened: closed as spec-only. A .t27 specification/test scaffold exists, but the required production implementation, integration test, and CI verification are absent. This issue remains open until the target component implements the specified behavior and evidence is provided.
gHashTag commentedon Nov 17, 2026
Specs created. M4 milestone complete.
gHashTag commentedon Nov 18, 2026
Reopened: closed as spec-only. A .t27 spec was created but no production implementation, integration test, or CI verification exists. This issue remains open until the target component implements the specified behavior and evidence is provided.