Skip to content

feat: add handler for overrideMethodsPrompt action #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions lua/java-refactor/action.lua
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,33 @@ end
---@field params lsp.CodeActionParams
---@field version number

---@param params nvim.CodeActionParamsResponse
function Action:override_methods_prompt(params)
local status = self.jdtls:list_overridable_methods(params.params)

if not status or not status.methods or #status.methods < 1 then
notify.warn('No methods to override.')
return
end

local selected_methods = ui.multi_select(
'Select methods to override.',
status.methods,
function(method)
return string.format(
'%s(%s)',
method.name,
table.concat(method.parameters, ', ')
)
end
)

if not selected_methods or #selected_methods < 1 then
return
end

local edit =
self.jdtls:add_overridable_methods(params.params, selected_methods)
vim.lsp.util.apply_workspace_edit(edit, 'utf-8')
end
return Action
8 changes: 8 additions & 0 deletions lua/java-refactor/client-command-handlers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ local M = {
end)
end,

---@param params nvim.CodeActionParamsResponse
[ClientCommand.OVERRIDE_METHODS_PROMPT] = function(_, params)
run('Failed to get overridable methods', function(action)
action:override_methods_prompt(params)
require('java-core.utils.notify').info('Successfully built the workspace')
end)
end,

---@param is_full_build boolean
[ClientCommand.COMPILE_WORKSPACE] = function(is_full_build)
run('Failed to build workspace', function(action)
Expand Down
2 changes: 0 additions & 2 deletions lua/java-refactor/refactor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ function Refactor:move_file(action_info)
params = nil,
})

vim.print(move_des)

if
not move_des
or not move_des.destinations
Expand Down
Loading