diff --git a/CHANGELOG.md b/CHANGELOG.md index ceb47c4..9655a06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [1.7.0](https://github.com/nvim-java/nvim-java-refactor/compare/v1.6.0...v1.7.0) (2025-01-21) + + +### Features + +* add handler for overrideMethodsPrompt action ([#16](https://github.com/nvim-java/nvim-java-refactor/issues/16)) ([2c281a1](https://github.com/nvim-java/nvim-java-refactor/commit/2c281a110fd616ce10c44963e63e13bdf9e638d7)) + ## [1.6.0](https://github.com/nvim-java/nvim-java-refactor/compare/v1.5.0...v1.6.0) (2024-07-25) diff --git a/lua/java-refactor/action.lua b/lua/java-refactor/action.lua index d78baa4..257f1e4 100644 --- a/lua/java-refactor/action.lua +++ b/lua/java-refactor/action.lua @@ -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 diff --git a/lua/java-refactor/client-command-handlers.lua b/lua/java-refactor/client-command-handlers.lua index 8e56ac5..bb3ce86 100644 --- a/lua/java-refactor/client-command-handlers.lua +++ b/lua/java-refactor/client-command-handlers.lua @@ -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) diff --git a/lua/java-refactor/refactor.lua b/lua/java-refactor/refactor.lua index d2b3e21..43f8ff9 100644 --- a/lua/java-refactor/refactor.lua +++ b/lua/java-refactor/refactor.lua @@ -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