Skip to content
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
20 changes: 20 additions & 0 deletions lua/java-refactor/action.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 19 additions & 0 deletions lua/java-refactor/client-command-handlers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading