Java intention: Quick fix for error "foreach not applicable to type java.util.Iterator" - handle comments and take care of empty block when copying the loop body (IDEA-124751)

This commit is contained in:
Pavel Dolgov
2016-07-04 14:37:31 +03:00
parent c78e91e07d
commit 65a5b0e437
6 changed files with 39 additions and 13 deletions
@@ -6,6 +6,7 @@ public class CodeBlockBody {
for (Iterator<Integer> it2 = it1; it2.hasNext(); ) {
Integer integer = it2.next();
System.out.println(integer + " a");
// a comment
System.out.println(integer + " b");
}
}
@@ -0,0 +1,10 @@
// "Replace 'for each' loop with iterator 'for' loop" "true"
import java.util.Iterator;
public class EmptyBlockBody {
void foo(Iterator<Integer> it) {
for (Iterator<Integer> it1 = it; it1.hasNext(); ) {
Integer integer = it1.next();
}
}
}
@@ -5,6 +5,7 @@ public class CodeBlockBody {
void foo(Iterator<Integer> it,Iterator<Integer> it1) {
for (Integer integer : <caret>it1) {
System.out.println(integer + " a");
// a comment
System.out.println(integer + " b");
}
}
@@ -0,0 +1,8 @@
// "Replace 'for each' loop with iterator 'for' loop" "true"
import java.util.Iterator;
public class EmptyBlockBody {
void foo(Iterator<Integer> it) {
for (Integer integer : <caret>it) {}
}
}