mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 03:13:40 +07:00
StreamApiMigrationInspection: correctly handle anonymous classes/lambdas (IDEA-CR-14138)
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
// "Replace with collect" "true"
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Collect {
|
||||
public static void collectWithLambda(List<String> test) {
|
||||
Runnable r = () -> {
|
||||
List<String> result;
|
||||
System.out.println("We're inside the lambda");
|
||||
result = test.stream().map(String::trim).collect(Collectors.toList());
|
||||
System.out.println(result);
|
||||
};
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// "Replace with collect" "false"
|
||||
import java.util.*;
|
||||
|
||||
public class Collect {
|
||||
public static void collectWithAnonymous(List<String> test) {
|
||||
List<String> result = new ArrayList<>();
|
||||
Runnable r = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (String str : te<caret>st) {
|
||||
result.add(str.trim());
|
||||
}
|
||||
}
|
||||
};
|
||||
r.run();
|
||||
System.out.println(result);
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Replace with collect" "false"
|
||||
import java.util.*;
|
||||
|
||||
public class Collect {
|
||||
public static void collectWithLambda(List<String> test) {
|
||||
List<String> result = new ArrayList<>();
|
||||
Runnable r = () -> {
|
||||
for(String str : te<caret>st) {
|
||||
result.add(str.trim());
|
||||
}
|
||||
};
|
||||
r.run();
|
||||
System.out.println(result);
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Replace with collect" "true"
|
||||
import java.util.*;
|
||||
|
||||
public class Collect {
|
||||
public static void collectWithLambda(List<String> test) {
|
||||
Runnable r = () -> {
|
||||
List<String> result = new ArrayList<>();
|
||||
System.out.println("We're inside the lambda");
|
||||
for(String str : te<caret>st) {
|
||||
result.add(str.trim());
|
||||
}
|
||||
System.out.println(result);
|
||||
};
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user