mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 21:55:01 +07:00
EA-55951 - CCE: StreamApiMigrationInspection$ReplaceWithForeachCallFix.applyFix
This commit is contained in:
+4
-1
@@ -256,7 +256,10 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
|
||||
final PsiIfStatement ifStmt = extractIfStatement(body);
|
||||
|
||||
String foreEachText = wrapInBlock(body);
|
||||
String iterated = iteratedValue.getText();
|
||||
String iterated = iteratedValue instanceof PsiCallExpression ||
|
||||
iteratedValue instanceof PsiReferenceExpression ||
|
||||
iteratedValue instanceof PsiQualifiedExpression ||
|
||||
iteratedValue instanceof PsiParenthesizedExpression ? iteratedValue.getText() : "(" + iteratedValue.getText() + ")";
|
||||
if (ifStmt != null) {
|
||||
final PsiExpression condition = ifStmt.getCondition();
|
||||
if (condition != null) {
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace with forEach" "true"
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class Sample {
|
||||
List<String> foo = new ArrayList<>();
|
||||
String foo(){
|
||||
((List<String>) foo).stream().filter(s -> s == null).forEach(System.out::println);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Replace with forEach" "true"
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class Sample {
|
||||
List<String> foo = new ArrayList<>();
|
||||
String foo(){
|
||||
for (String s : (List<String>)fo<caret>o) {
|
||||
if (s == null) {
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user