Refactoring - moving variable declaration
Anyone know how to do the refactoring as follows:
<!--
Before refactoring
-->
for (int i = 0; i < sorts.length; i++) {
SortOrder sort = sorts+;
<!--
After refactoring
-->
SortOrder sort = null;
for (int i = 0; i < sorts.length; i++) {
sort = sorts+;
Thanks in advance
Martin
请先登录再写评论。
Martin wrote:
Try using the "Split into declaration and assignment" intention action
by positioning the cursor on the "SortOrder sort = sorts+;" line and
pressing Alt-Enter. After that you should be able to cut & paste the
declaration before the loop and add the null initializer.
Ciao,
Gordon
--
Gordon Tyler (Software Developer)
Quest Software <http://java.quest.com/>
260 King Street East, Toronto, Ontario M5A 4L5, Canada
Voice: (416) 933-5046 | Fax: (416) 933-5001
Gordon Tyler wrote:
>> Anyone know how to do the refactoring as follows:
>>
>> <!--
>> Before refactoring
>> -->
>> for (int i = 0; i < sorts.length; i++) {
>> SortOrder sort = sorts+;
>>
>> <!--
>> After refactoring
>> -->
>> SortOrder sort = null;
>> for (int i = 0; i < sorts.length; i++) {
>> sort = sorts+;
I do this quite frequently as well.
It would be really nice if there was an intention action to do this
without the additional cut & paste and add null initializer actions.
btw, if you have the LineMover plugin, it is a better option than the
cut & paste step, although still suboptimal for this case.
Tim