mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 05:21:29 +07:00
IDEA-110978 Refactors this as null when converting for-each loop to indexed for loop
This commit is contained in:
@@ -216,7 +216,7 @@ public class ReplaceForEachLoopWithIndexedForLoopIntention extends Intention {
|
||||
}
|
||||
return createVariable(variableName, expression, context);
|
||||
}
|
||||
return null;
|
||||
return expression.getText();
|
||||
}
|
||||
|
||||
private static String createVariable(String variableNameRoot,
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.siyeh.ipp.forloop.indexed;
|
||||
import java.util.*;
|
||||
class NormalForEachLoop implements List<Integer>{
|
||||
void foo() {
|
||||
<caret>for (Integer i : this) {
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.siyeh.ipp.forloop.indexed;
|
||||
import java.util.*;
|
||||
class NormalForEachLoop implements List<Integer>{
|
||||
void foo() {
|
||||
for (int i1 = 0, thisSize = this.size(); i1 < thisSize; i1++) {
|
||||
Integer i = this.get(i1);
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import com.siyeh.ipp.IPPTestCase;
|
||||
public class ReplaceForEachLoopWithIndexedForLoopIntentionTest extends IPPTestCase {
|
||||
public void testLabeledForLoop() { doTest(); }
|
||||
public void testNormalForeachLoop() { doTest(); }
|
||||
public void testThisExpr() { doTest(); }
|
||||
public void testNewArray() { doTest(); }
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user