File tree Expand file tree Collapse file tree 4 files changed +62
-3
lines changed
Expand file tree Collapse file tree 4 files changed +62
-3
lines changed Original file line number Diff line number Diff line change @@ -119,7 +119,11 @@ Yep! That's all :)
119119
120120### Refactor
121121
122- - ` JavaRefactorExtractVariable ` - Create a variable from returned value at cursor
122+ - ` JavaRefactorExtractVariable ` - Create a variable from value at cursor
123+ - ` JavaRefactorExtractVariableAllOccurrence ` - Create a variable for all
124+ occurrences from value at cursor
125+ - ` JavaRefactorExtractConstant ` - Create a constant from the value at cursor
126+ - ` JavaRefactorExtractMethod ` - Create method from the value at cursor
123127
124128### Settings
125129
@@ -212,12 +216,31 @@ require('java').profile.ui()
212216
213217### Refactor
214218
215- - ` extract_variable ` - Create a variable from returned value at cursor
219+ - ` extract_variable ` - Create a variable from value at cursor
216220
217221``` lua
218222require (' java' ).refactor .extract_variable ()
219223```
220224
225+ - ` extract_variable_all_occurrence ` - Create a variable for all occurrences from
226+ value at cursor
227+
228+ ``` lua
229+ require (' java' ).refactor .extract_variable_all_occurrence ()
230+ ```
231+
232+ - ` extract_constant ` - Create a constant from the value at cursor
233+
234+ ``` lua
235+ require (' java' ).refactor .extract_constant ()
236+ ```
237+
238+ - ` extract_method ` - Create method from the value at cursor
239+
240+ ``` lua
241+ require (' java' ).refactor .extract_method ()
242+ ```
243+
221244### Settings
222245
223246- ` change_runtime ` - Change the JDK version to another
Original file line number Diff line number Diff line change @@ -84,6 +84,10 @@ M.manipulate = {}
8484---- ------------------------------------------------------------------
8585M .refactor = {}
8686M .refactor .extract_variable = refactor .extract_variable
87+ M .refactor .extract_constant = refactor .extract_constant
88+ M .refactor .extract_method = refactor .extract_method
89+ M .refactor .extract_variable_all_occurrence =
90+ refactor .extract_variable_all_occurrence
8791
8892---- ------------------------------------------------------------------
8993-- Runner APIs --
Original file line number Diff line number Diff line change @@ -6,10 +6,28 @@ local async = require('java-core.utils.async').sync
66local M = {}
77
88function M .extract_variable ()
9+ M .extract (' extractVariable' )
10+ end
11+
12+ function M .extract_variable_all_occurrence ()
13+ M .extract (' extractVariableAllOccurrence' )
14+ end
15+
16+ function M .extract_constant ()
17+ M .extract (' extractConstant' )
18+ end
19+
20+ function M .extract_method ()
21+ M .extract (' extractMethod' )
22+ end
23+
24+ ---
25+ --- @param refactor_command jdtls.CodeActionCommand
26+ function M .extract (refactor_command )
927 return async (function ()
1028 local RefactorCommands = require (' java-refactor.refactor-commands' )
1129 local refactor_commands = RefactorCommands (jdtls ())
12- refactor_commands :extract_variable ( )
30+ refactor_commands :refactor ( refactor_command )
1331 end )
1432 .catch (get_error_handler (' failed to refactor variable' ))
1533 .run ()
Original file line number Diff line number Diff line change @@ -30,6 +30,20 @@ local cmd_map = {
3030 java .refactor .extract_variable ,
3131 { range = 2 },
3232 },
33+
34+ JavaRefactorExtractMethod = {
35+ java .refactor .extract_method ,
36+ },
37+
38+ JavaRefactorExtractConstant = {
39+ java .refactor .extract_constant ,
40+ { range = 2 },
41+ },
42+
43+ JavaRefactorExtractVariableAllOccurrence = {
44+ java .refactor .extract_variable_all_occurrence ,
45+ { range = 2 },
46+ },
3347}
3448
3549for cmd , details in pairs (cmd_map ) do
You can’t perform that action at this time.
0 commit comments