mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-09 15:41:26 +07:00
StreamApiMigrationInspection: improve stream source recognition
This commit is contained in:
+17
@@ -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);
|
||||
}
|
||||
}
|
||||
+18
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user