Skip to content

Commit acc94e3

Browse files
committed
Update change-signature handling for upstream changes
There were changes to no longer provide the `signature` within the code-action command arguments but instead require an additional request from the client. See: - eclipse-jdtls/eclipse.jdt.ls#3322 - redhat-developer/vscode-java#3845 Closes: #743
1 parent 7758410 commit acc94e3

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

lua/jdtls.lua

+30-4
Original file line numberDiff line numberDiff line change
@@ -462,11 +462,10 @@ end
462462

463463

464464
---@param bufnr integer
465-
---@param command table
465+
---@param signature table
466+
---@param cmd_name string
466467
---@param code_action_params table
467-
local function change_signature(bufnr, command, code_action_params)
468-
local cmd_name = command.arguments[1]
469-
local signature = command.arguments[3]
468+
local function change_signature_prompt(bufnr, signature, cmd_name, code_action_params)
470469
local edit_buf = api.nvim_create_buf(false, true)
471470
api.nvim_create_autocmd("BufUnload", {
472471
buffer = edit_buf,
@@ -594,6 +593,33 @@ local function change_signature(bufnr, command, code_action_params)
594593
end
595594

596595

596+
---@param bufnr integer
597+
---@param command table
598+
---@param code_action_params table
599+
local function change_signature(bufnr, command, code_action_params)
600+
local cmd_name = command.arguments[1]
601+
local signature = command.arguments[3]
602+
if signature then
603+
change_signature_prompt(bufnr, signature, cmd_name, code_action_params)
604+
return
605+
end
606+
local client = get_clients({ bufnr = bufnr, name = "jdtls" })[1]
607+
if not client then
608+
vim.notify("Server provided no signature, and can't retrieve client to fetch one", vim.log.levels.ERROR)
609+
return
610+
end
611+
local function on_signature(err, sig)
612+
if err then
613+
error(vim.inspect(err))
614+
end
615+
change_signature_prompt(bufnr, sig, cmd_name, code_action_params)
616+
end
617+
client.request("java/getChangeSignatureInfo", code_action_params, on_signature, bufnr)
618+
end
619+
620+
621+
622+
597623
---@param after_refactor? function
598624
local function java_apply_refactoring_command(command, outer_ctx, after_refactor)
599625
local cmd = command.arguments[1]

0 commit comments

Comments
 (0)