Skip to content

Commit

Permalink
Update change-signature handling for upstream changes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mfussenegger committed Jan 23, 2025
1 parent 7758410 commit acc94e3
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions lua/jdtls.lua
Original file line number Diff line number Diff line change
@@ -462,11 +462,10 @@ end


---@param bufnr integer
---@param command table
---@param signature table
---@param cmd_name string
---@param code_action_params table
local function change_signature(bufnr, command, code_action_params)
local cmd_name = command.arguments[1]
local signature = command.arguments[3]
local function change_signature_prompt(bufnr, signature, cmd_name, code_action_params)
local edit_buf = api.nvim_create_buf(false, true)
api.nvim_create_autocmd("BufUnload", {
buffer = edit_buf,
@@ -594,6 +593,33 @@ local function change_signature(bufnr, command, code_action_params)
end


---@param bufnr integer
---@param command table
---@param code_action_params table
local function change_signature(bufnr, command, code_action_params)
local cmd_name = command.arguments[1]
local signature = command.arguments[3]
if signature then
change_signature_prompt(bufnr, signature, cmd_name, code_action_params)
return
end
local client = get_clients({ bufnr = bufnr, name = "jdtls" })[1]
if not client then
vim.notify("Server provided no signature, and can't retrieve client to fetch one", vim.log.levels.ERROR)
return
end
local function on_signature(err, sig)
if err then
error(vim.inspect(err))
end
change_signature_prompt(bufnr, sig, cmd_name, code_action_params)
end
client.request("java/getChangeSignatureInfo", code_action_params, on_signature, bufnr)
end




---@param after_refactor? function
local function java_apply_refactoring_command(command, outer_ctx, after_refactor)
local cmd = command.arguments[1]

0 comments on commit acc94e3

Please sign in to comment.