From 5d15bd646f73073244e4f5da64905ba0b2b592e5 Mon Sep 17 00:00:00 2001 From: Srinesh Nisala Date: Sun, 26 Jan 2025 15:41:49 +0530 Subject: [PATCH 1/2] feat: add chooseImports action (#19) --- lua/java-refactor/action.lua | 20 +++++++++++++++++++ lua/java-refactor/client-command-handlers.lua | 19 ++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/lua/java-refactor/action.lua b/lua/java-refactor/action.lua index 257f1e4..ff90e33 100644 --- a/lua/java-refactor/action.lua +++ b/lua/java-refactor/action.lua @@ -299,4 +299,24 @@ function Action:override_methods_prompt(params) self.jdtls:add_overridable_methods(params.params, selected_methods) vim.lsp.util.apply_workspace_edit(edit, 'utf-8') end + +---@param selections jdtls.ImportSelection[] +function Action.choose_imports(selections) + local selected_candidates = {} + + for _, selection in ipairs(selections) do + local selected_candidate = ui.select_sync( + 'Select methods to override.', + selection.candidates, + function(candidate, index) + return index .. ' ' .. candidate.fullyQualifiedName + end + ) + + table.insert(selected_candidates, selected_candidate) + end + + return selected_candidates +end + return Action diff --git a/lua/java-refactor/client-command-handlers.lua b/lua/java-refactor/client-command-handlers.lua index bb3ce86..604887c 100644 --- a/lua/java-refactor/client-command-handlers.lua +++ b/lua/java-refactor/client-command-handlers.lua @@ -65,6 +65,25 @@ local M = { end) end, + ---@param params [string, jdtls.ImportSelection[], boolean] + [ClientCommand.CHOOSE_IMPORTS] = function(params) + local get_error_handler = require('java-refactor.utils.error_handler') + local instance = require('java-refactor.utils.instance-factory') + local action = instance.get_action() + + local selections = params[2] + local ok, result = pcall(function() + return action.choose_imports(selections) + end) + + if not ok then + get_error_handler('Failed to choose imports')(result) + return + end + + return result or {} + end, + ---@param is_full_build boolean [ClientCommand.COMPILE_WORKSPACE] = function(is_full_build) run('Failed to build workspace', function(action) From b51a57d862338999059e1d1717df3bc80a3a15c0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 26 Jan 2025 15:42:50 +0530 Subject: [PATCH 2/2] chore(main): release 1.8.0 (#20) 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 9655a06..14c3d91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [1.8.0](https://github.com/nvim-java/nvim-java-refactor/compare/v1.7.0...v1.8.0) (2025-01-26) + + +### Features + +* add chooseImports action ([#19](https://github.com/nvim-java/nvim-java-refactor/issues/19)) ([5d15bd6](https://github.com/nvim-java/nvim-java-refactor/commit/5d15bd646f73073244e4f5da64905ba0b2b592e5)) + ## [1.7.0](https://github.com/nvim-java/nvim-java-refactor/compare/v1.6.0...v1.7.0) (2025-01-21)