Skip to content

fix(refactor): use method-call syntax for Action:rename#493

Merged
s1n7ax merged 1 commit into
nvim-java:mainfrom
fobbyal:fix/rename-method-call
Jun 6, 2026
Merged

fix(refactor): use method-call syntax for Action:rename#493
s1n7ax merged 1 commit into
nvim-java:mainfrom
fobbyal:fix/rename-method-call

Conversation

@fobbyal

@fobbyal fobbyal commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Summary

lua/java-refactor/client-command-handlers.lua:21 calls
action.rename(params) with a dot. Since Action:rename is defined
with self, the dot-call passes params as self and leaves the
actual params argument as nil, which makes action.lua:28 error
with:

Failed to rename the symbol
.../java-refactor/action.lua:28: bad argument #1 to 'ipairs' (table expected, got nil)

Every other handler in this file already uses : when calling into
Action:* methods (generate_constructor, generate_to_string,
apply_refactoring_command, etc.). This brings RENAME_COMMAND in
line with them.

The patch is a one-character change: .:.

Reproduction

  1. Open a Java file with jdtls attached.
  2. Select a string literal (or any expression) and trigger the refactoring
    that produces a follow-up rename — e.g. "Extract to constant"
    (textDocument/codeActionrefactor.extract.constant).
  3. jdtls applies the edit, then sends RENAME_COMMAND back so the new
    symbol can be renamed inline.
  4. The handler fails before the rename UI opens, with the error above.

After this fix, the rename UI opens on the newly extracted constant as
expected.

Test plan

  • Hot-applied the same one-character change to a local install
    (~/.local/share/nvim/lazy/nvim-java/lua/java-refactor/client-command-handlers.lua:21),
    restarted nvim, and confirmed "Extract to constant" → inline rename
    works end-to-end.

🤖 Generated with Claude Code

client-command-handlers.lua:21 used action.rename(params) (dot)
instead of action:rename(params) (colon). Since Action:rename is
defined with self, the dot-call passed params as self and left the
actual params argument as nil, causing action.lua:28 to error with
"bad argument nvim-java#1 to 'ipairs' (table expected, got nil)".

All other handlers in this file already use : when calling into
Action:* methods. This brings RENAME_COMMAND in line with them.

Reproduction: in any Java file with jdtls attached, trigger a
refactoring that produces a follow-up rename (e.g. "Extract to
constant" on a string literal). jdtls fires RENAME_COMMAND with
the new symbol's location, and the handler errors before the
rename UI opens. After this fix, the rename UI opens as expected.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@s1n7ax s1n7ax merged commit bb12076 into nvim-java:main Jun 6, 2026
8 checks passed
@s1n7ax

s1n7ax commented Jun 6, 2026

Copy link
Copy Markdown
Member

Thanks for the contribution <3

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants