Skip to content

Commit 4b1ffbb

Browse files
committed
feat: add ui selection for extractField command
1 parent 2c45126 commit 4b1ffbb

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

lua/java-refactor/refactor-commands.lua

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
local class = require('java-core.utils.class')
22
local notify = require('java-core.utils.notify')
33
local JdtlsClient = require('java-core.ls.clients.jdtls-client')
4+
local List = require('java-core.utils.list')
5+
local ui = require('java.utils.ui')
46

57
local available_commands = {
68
-- 'assignField',
@@ -51,21 +53,37 @@ function RefactorCommands:refactor(refactor_type, context)
5153

5254
local buffer = vim.api.nvim_get_current_buf()
5355

54-
local selection = {}
56+
local selections = List:new()
5557

5658
if
5759
context.range.start.character == context.range['end'].character
5860
and context.range.start.line == context.range['end'].line
5961
then
60-
selection =
61-
self.jdtls_client:java_infer_selection(refactor_type, context, buffer)
62+
local selection =
63+
self.jdtls_client:java_infer_selection(refactor_type, context, buffer)[1]
64+
65+
if refactor_type == 'extractField' then
66+
if selection.params and vim.islist(selection.params) then
67+
local initialize_in =
68+
ui.select('Initialize the field in', selection.params)
69+
70+
if not initialize_in then
71+
return
72+
end
73+
74+
selections:push(initialize_in)
75+
end
76+
end
77+
78+
selections:push(selection)
79+
vim.print(selections)
6280
end
6381

6482
local edit = self.jdtls_client:java_get_refactor_edit(
6583
refactor_type,
6684
context,
6785
formatting_options,
68-
selection,
86+
selections,
6987
buffer
7088
)
7189

0 commit comments

Comments
 (0)