Java intention: Quick fix for error "foreach not applicable to type java.util.Iterator" (IDEA-124751)

This commit is contained in:
Pavel Dolgov
2016-07-01 16:12:36 +03:00
parent 57b55ceeb6
commit d50a5c7a07
19 changed files with 302 additions and 2 deletions
@@ -0,0 +1,12 @@
// "Replace 'for each' loop with iterator 'for' loop" "true"
import java.util.Iterator;
public class CodeBlockBody {
void foo(Iterator<Integer> it,Iterator<Integer> it1) {
for (Iterator<Integer> it2 = it1; it2.hasNext(); ) {
Integer integer = it2.next();
System.out.println(integer + " a");
System.out.println(integer + " b");
}
}
}
@@ -0,0 +1,10 @@
// "Replace 'for each' loop with iterator 'for' loop" "true"
import java.util.Iterator;
public class EmptyBody {
void foo(Iterator<Integer> it) {
for (Iterator<Integer> it1 = it; it1.hasNext(); ) {
Integer integer = it1.next();
}
}
}
@@ -0,0 +1,11 @@
// "Replace 'for each' loop with iterator 'for' loop" "true"
import java.util.Iterator;
public class IncompatibleItemType {
void foo(Iterator<Integer> it) {
for (Iterator<Integer> it1 = it; it1.hasNext(); ) {
String string = it1.next();
System.out.println(string);
}
}
}
@@ -0,0 +1,10 @@
// "Replace 'for each' loop with iterator 'for' loop" "true"
import java.util.Iterator;
public class MissingBody {
void foo(Iterator<Integer> it1) {
for (Iterator<Integer> it = it1; it.hasNext(); ) {
Integer integer = it.next();
}
}
}
@@ -0,0 +1,11 @@
// "Replace 'for each' loop with iterator 'for' loop" "true"
import java.util.Iterator;
public class OneStatementBody {
void foo(Iterator<Integer> it) {
for (Iterator<Integer> it1 = it; it1.hasNext(); ) {
Integer integer = it1.next();
System.out.println(integer);
}
}
}
@@ -0,0 +1,11 @@
// "Replace 'for each' loop with iterator 'for' loop" "true"
import java.util.Iterator;
public class PrimitiveItem {
void foo(Iterator<Integer> it) {
for (Iterator<Integer> it1 = it; it1.hasNext(); ) {
int i = it1.next();
System.out.println(i);
}
}
}
@@ -0,0 +1,11 @@
// "Replace 'for each' loop with iterator 'for' loop" "true"
import java.util.Iterator;
public class CodeBlockBody {
void foo(Iterator<Integer> it,Iterator<Integer> it1) {
for (Integer integer : <caret>it1) {
System.out.println(integer + " a");
System.out.println(integer + " b");
}
}
}
@@ -0,0 +1,8 @@
// "Replace 'for each' loop with iterator 'for' loop" "true"
import java.util.Iterator;
public class EmptyBody {
void foo(Iterator<Integer> it) {
for (Integer integer : <caret>it) ;
}
}
@@ -0,0 +1,8 @@
// "Replace 'for each' loop with iterator 'for' loop" "true"
import java.util.Iterator;
public class IncompatibleItemType {
void foo(Iterator<Integer> it) {
for (String string : <caret>it) System.out.println(string);
}
}
@@ -0,0 +1,8 @@
// "Replace 'for each' loop with iterator 'for' loop" "true"
import java.util.Iterator;
public class MissingBody {
void foo(Iterator<Integer> it1) {
for (Integer integer : <caret>it1)
}
}
@@ -0,0 +1,8 @@
// "Replace 'for each' loop with iterator 'for' loop" "false"
import java.lang.ref.Reference;
public class NotIterator {
void foo(Reference<String> it) {
for (String string : <caret>it) System.out.println(string);
}
}
@@ -0,0 +1,8 @@
// "Replace 'for each' loop with iterator 'for' loop" "true"
import java.util.Iterator;
public class OneStatementBody {
void foo(Iterator<Integer> it) {
for (Integer integer : <caret>it) System.out.println(integer);
}
}
@@ -0,0 +1,8 @@
// "Replace 'for each' loop with iterator 'for' loop" "true"
import java.util.Iterator;
public class PrimitiveItem {
void foo(Iterator<Integer> it) {
for (int i : <caret>it) System.out.println(i);
}
}