StreamApiMigrationInspection: improve stream source recognition

This commit is contained in:
Roman
2017-09-27 12:28:23 +07:00
parent 1779a8a871
commit 545ae69261
19 changed files with 571 additions and 30 deletions
@@ -0,0 +1,17 @@
// "Replace with forEach" "true"
import java.util.function.UnaryOperator;
import java.util.stream.Stream;
public class Main {
static class A {
A next(){return null;}
int x;
}
static boolean isGood(A a) {}
public long test() {
Stream.iterate(new A(), (UnaryOperator<A>) Main::isGood, a -> a.next()).filter(a -> a.x < 3).forEach(System.out::println);
}
}
@@ -0,0 +1,18 @@
// "Replace with forEach" "true"
public class Main {
static class A {
A next(){return null;}
int x;
}
static boolean isGood(A a) {}
public long test() {
for <caret>(A a = new A(); isGood(a); a = a.next()) {
if(a.x < 3) {
System.out.println(a);
}
}
}
}
@@ -0,0 +1,13 @@
// "Replace with forEach" "false"
public class Main {
public long test() {
int j = 0;
for <caret>(int i = 0; j < 10; j = j + i) {
if(i < 3) {
System.out.println(i);
}
}
}
}