@@ -27,20 +27,20 @@ local available_actions = List:new({
27
27
-- 'extractInterface',
28
28
}):concat (refactor_edit_request_needed_actions )
29
29
30
- --- @class java-refactor.RefactorCommands
30
+ --- @class java-refactor.Refactor
31
31
--- @field jdtls_client java-core.JdtlsClient
32
- local RefactorCommands = class ()
32
+ local Refactor = class ()
33
33
34
34
--- @param client vim.lsp.Client
35
- function RefactorCommands :_init (client )
35
+ function Refactor :_init (client )
36
36
self .jdtls_client = JdtlsClient (client )
37
37
end
38
38
39
39
--- Run refactor command
40
40
--- @param action_name jdtls.CodeActionCommand
41
41
--- @param action_context lsp.CodeActionParams
42
42
--- @param action_info lsp.LSPAny
43
- function RefactorCommands :refactor (action_name , action_context , action_info )
43
+ function Refactor :refactor (action_name , action_context , action_info )
44
44
if not vim .tbl_contains (available_actions , action_name ) then
45
45
notify .error (
46
46
string.format (' Refactoring command "%s" is not supported' , action_name )
@@ -49,7 +49,7 @@ function RefactorCommands:refactor(action_name, action_context, action_info)
49
49
end
50
50
51
51
if vim .tbl_contains (refactor_edit_request_needed_actions , action_name ) then
52
- local formatting_options = RefactorCommands .make_formatting_options ()
52
+ local formatting_options = Refactor .make_formatting_options ()
53
53
local selections
54
54
55
55
if vim .tbl_contains (refactor_edit_request_needed_actions , action_name ) then
@@ -64,7 +64,7 @@ function RefactorCommands:refactor(action_name, action_context, action_info)
64
64
vim .api .nvim_get_current_buf ()
65
65
)
66
66
67
- RefactorCommands .perform_refactor_edit (changes )
67
+ Refactor .perform_refactor_edit (changes )
68
68
elseif action_name == ' moveFile' then
69
69
self :move_file (action_info --[[ @as jdtls.CodeActionMoveTypeCommandInfo]] )
70
70
elseif action_name == ' moveType' then
87
87
88
88
--- @private
89
89
--- @param action_info jdtls.CodeActionMoveTypeCommandInfo
90
- function RefactorCommands :move_file (action_info )
90
+ function Refactor :move_file (action_info )
91
91
if not action_info or not action_info .uri then
92
92
return
93
93
end
@@ -133,13 +133,13 @@ function RefactorCommands:move_file(action_info)
133
133
destination = selected_destination ,
134
134
})
135
135
136
- RefactorCommands .perform_refactor_edit (changes )
136
+ Refactor .perform_refactor_edit (changes )
137
137
end
138
138
139
139
--- @private
140
140
--- @param action_context lsp.CodeActionParams
141
141
--- @param action_info jdtls.CodeActionMoveTypeCommandInfo
142
- function RefactorCommands :move_instance_method (action_context , action_info )
142
+ function Refactor :move_instance_method (action_context , action_info )
143
143
local move_des = self .jdtls_client :get_move_destination ({
144
144
moveKind = ' moveInstanceMethod' ,
145
145
sourceUris = { action_context .textDocument .uri },
189
189
--- @private
190
190
--- @param action_context lsp.CodeActionParams
191
191
--- @param action_info jdtls.CodeActionMoveTypeCommandInfo
192
- function RefactorCommands :move_static_member (action_context , action_info )
192
+ function Refactor :move_static_member (action_context , action_info )
193
193
local exclude = List :new ()
194
194
195
195
if action_info .enclosingTypeName then
227
227
--- @private
228
228
--- @param action_context lsp.CodeActionParams
229
229
--- @param action_info jdtls.CodeActionMoveTypeCommandInfo
230
- function RefactorCommands :move_type (action_context , action_info )
230
+ function Refactor :move_type (action_context , action_info )
231
231
if not action_info or not action_info .supportedDestinationKinds then
232
232
return
233
233
end
@@ -287,20 +287,20 @@ end
287
287
--- @param move_kind string
288
288
--- @param action_context lsp.CodeActionParams
289
289
--- @param destination ? jdtls.InstanceMethodMoveDestination | jdtls.ResourceMoveDestination | lsp.SymbolInformation
290
- function RefactorCommands :perform_move (move_kind , action_context , destination )
290
+ function Refactor :perform_move (move_kind , action_context , destination )
291
291
local changes = self .jdtls_client :java_move ({
292
292
moveKind = move_kind ,
293
293
sourceUris = { action_context .textDocument .uri },
294
294
params = action_context ,
295
295
destination = destination ,
296
296
})
297
297
298
- RefactorCommands .perform_refactor_edit (changes )
298
+ Refactor .perform_refactor_edit (changes )
299
299
end
300
300
301
301
--- @private
302
302
--- @param changes jdtls.RefactorWorkspaceEdit
303
- function RefactorCommands .perform_refactor_edit (changes )
303
+ function Refactor .perform_refactor_edit (changes )
304
304
if not changes then
305
305
notify .warn (' No edits suggested for the code action' )
306
306
return
@@ -313,7 +313,7 @@ function RefactorCommands.perform_refactor_edit(changes)
313
313
vim .lsp .util .apply_workspace_edit (changes .edit , ' utf-8' )
314
314
315
315
if changes .command then
316
- RefactorCommands .run_lsp_client_command (
316
+ Refactor .run_lsp_client_command (
317
317
changes .command .command ,
318
318
changes .command .arguments
319
319
)
324
324
--- @param prompt string
325
325
--- @param project_name string
326
326
--- @param exclude string[]
327
- function RefactorCommands :select_target_class (prompt , project_name , exclude )
327
+ function Refactor :select_target_class (prompt , project_name , exclude )
328
328
local classes = self .jdtls_client :java_search_symbols ({
329
329
query = ' *' ,
330
330
projectName = project_name ,
347
347
--- @private
348
348
--- @param command_name string
349
349
--- @param arguments any
350
- function RefactorCommands .run_lsp_client_command (command_name , arguments )
350
+ function Refactor .run_lsp_client_command (command_name , arguments )
351
351
local command = vim .lsp .commands [command_name ]
352
352
353
353
if not command then
360
360
361
361
--- @private
362
362
--- @return lsp.FormattingOptions
363
- function RefactorCommands .make_formatting_options ()
363
+ function Refactor .make_formatting_options ()
364
364
return {
365
365
tabSize = vim .bo .tabstop ,
366
366
insertSpaces = vim .bo .expandtab ,
371
371
--- @param refactor_type jdtls.CodeActionCommand
372
372
--- @param params lsp.CodeActionParams
373
373
--- @return jdtls.SelectionInfo[]
374
- function RefactorCommands :get_selections (refactor_type , params )
374
+ function Refactor :get_selections (refactor_type , params )
375
375
local selections = List :new ()
376
376
local buffer = vim .api .nvim_get_current_buf ()
377
377
413
413
--- @field supportedDestinationKinds string[]
414
414
--- @field uri ? string
415
415
416
- return RefactorCommands
416
+ return Refactor
0 commit comments