mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
StreamApiMigrationInspection: chained computeIfAbsent generated incorrect code
This commit is contained in:
+1
-1
@@ -324,7 +324,7 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
|
||||
PsiExpression body = LambdaUtil.extractSingleExpressionFromBody(lambda.getBody());
|
||||
if (!(body instanceof PsiNewExpression)) return false;
|
||||
PsiExpressionList ctorArgs = ((PsiNewExpression)body).getArgumentList();
|
||||
return ctorArgs != null && ctorArgs.getExpressions().length == 0;
|
||||
return ctorArgs != null && ctorArgs.getExpressions().length == 0 && extractQualifierClass(tb, qualifierCall) != null;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace with forEach" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
private Map<Integer, Map<Integer, List<String>>> test(String... list) {
|
||||
Map<Integer, Map<Integer, List<String>>> map = new HashMap<>();
|
||||
Arrays.stream(list).filter(Objects::nonNull).forEach(s -> map.computeIfAbsent(s.length(), k -> new HashMap<>()).computeIfAbsent(s.length(), k -> new ArrayList<>()).add(s));
|
||||
return map;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Replace with forEach" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
private Map<Integer, Map<Integer, List<String>>> test(String... list) {
|
||||
Map<Integer, Map<Integer, List<String>>> map = new HashMap<>();
|
||||
for(String s : li<caret>st) {
|
||||
if(s != null) {
|
||||
map.computeIfAbsent(s.length(), k -> new HashMap<>()).computeIfAbsent(s.length(), k -> new ArrayList<>()).add(s);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user