From 2c281a110fd616ce10c44963e63e13bdf9e638d7 Mon Sep 17 00:00:00 2001 From: Srinesh Nisala Date: Tue, 21 Jan 2025 18:45:04 +0530 Subject: [PATCH 1/2] feat: add handler for overrideMethodsPrompt action (#16) --- lua/java-refactor/action.lua | 29 +++++++++++++++++++ lua/java-refactor/client-command-handlers.lua | 8 +++++ lua/java-refactor/refactor.lua | 2 -- 3 files changed, 37 insertions(+), 2 deletions(-) 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 From 5379779f4fc66e46eb9a636ba2b85f595cea8103 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 21 Jan 2025 18:48:00 +0530 Subject: [PATCH 2/2] chore(main): release 1.7.0 (#17) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) 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)