Implement codeAction/resolve: the offered refactors actually apply (#15) - #19
Merged
Merged
Conversation
The server advertised resolveProvider: true and offered Extract Variable / Extract Method / Toggle block style as edit-less actions with a data payload, but METHOD_MAP had no codeAction/resolve entry — a conformant client showed the refactors and invoking any of them died with -32601. (The interim mitigation described in #15 never landed; main carried the original bug.) - lib/mruby_lsp/code_action_resolve.rb: a faithful port of ruby-lsp 0.26.9's CodeActionResolve (the pinned vendored-vector commit) onto our Document/Locator plumbing — Extract Variable (incl. the one-line block semicolon form and the empty-line-above placement), Extract Method (def after the enclosing method; above the selection at script level), Toggle block style (brace <-> do/end, recursing into nested blocks), and the Create Attribute Reader/Writer/Accessor family. Like ruby-lsp's locate, a typed locate-miss falls back to the walked root — that fallback is what makes the class-less attribute case insert at Program scope. Unresolvable input returns the action unchanged (an edit-less action is a client no-op) — degrade, don't crash. No regex on source (hand scan for indentation). - code_action.rb now offers exactly what ruby-lsp offers: the extract pair on any non-empty selection, toggle at a cursor inside a block or on any selection (resolve decides applicability), the attribute family when an ivar is under the cursor/selection, quickfix passthrough unchanged. codeActionKinds gains "" (the attribute actions' kind). - dispatch: METHOD_MAP + Server#code_action_resolve. - Coverage: test/overlay/code_action_resolve_test.rb (17 prism-only checks) and test/conformance/replay_actions.py, which replays BOTH vector families verbatim (uri file:///fake, offer contexts with embedded quickfixes) — code_action_resolve 22/22 and code_actions 5/5 byte-equal, raising the CI-asserted conformance baseline from 112/112 to 139/139 (ci.yml, README scorecard, CONTRIBUTING updated). Built on the CI branch: the replay harness needs its consent-answering clients. Verified over real LSP stdio against the compiled mruby HEAD reflection VM: all six replayed features green (35+48+16+13+5+22).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on #18 — merge that first.
resolveProvider: trueand offered Extract Variable, Extract Method, and Toggle block style as edit-less actions, butMETHOD_MAPhad nocodeAction/resolveentry: a conformant client showed the refactors and invoking any of them died with-32601.lib/mruby_lsp/code_action_resolve.rb: a faithful port of ruby-lsp 0.26.9'sCodeActionResolveonto our Document/Locator plumbing — Extract Variable, Extract Method, Toggle block style, and the Create Attribute Reader/Writer/Accessor family. Unresolvable input returns the action unchanged (edit-less → client no-op), never crashes.code_action.rbnow offers exactly what ruby-lsp offers (extract pair on selection, toggle at a cursor inside a block or on any selection, attribute family on ivars, quickfix passthrough unchanged).METHOD_MAP+Server#code_action_resolve.test/overlay/code_action_resolve_test.rb(prism-only unit checks) andtest/conformance/replay_actions.py, wired into CI via two new scripts intest/conformance/replays/(code_actions.sh,code_action_resolve.sh) — no edits toci.ymlitself, following the directory convention ci: run the whole test suite against the real server on every PR (#1) #18 establishes.Test plan
code_action_resolve22/22,code_actions5/5)workflow_dispatchon this branch)