mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
Java intention: Quick fix for error "foreach not applicable to type java.util.Iterator" (IDEA-124751)
This commit is contained in:
+12
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
@@ -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) ;
|
||||
}
|
||||
}
|
||||
+8
@@ -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);
|
||||
}
|
||||
}
|
||||
+8
@@ -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)
|
||||
}
|
||||
}
|
||||
+8
@@ -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);
|
||||
}
|
||||
}
|
||||
+8
@@ -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);
|
||||
}
|
||||
}
|
||||
+8
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user