mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-167263 Stream API migration does not work when replacing simple loop on array of primitive types (int, long, double)
This commit is contained in:
+1
-1
@@ -242,7 +242,7 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
|
||||
|
||||
static boolean isAddAllCall(TerminalBlock tb) {
|
||||
PsiMethodCallExpression call = tb.getSingleMethodCall();
|
||||
if (call == null) return false;
|
||||
if (call == null || tb.getVariable().getType() instanceof PsiPrimitiveType) return false;
|
||||
if (!ExpressionUtils.isReferenceTo(call.getArgumentList().getExpressions()[0], tb.getVariable())) return false;
|
||||
if (!"add".equals(call.getMethodExpression().getReferenceName())) return false;
|
||||
PsiExpression qualifierExpression = call.getMethodExpression().getQualifierExpression();
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace with collect" "true"
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
final double[] array = new double[10];
|
||||
final List<Double> list = Arrays.stream(array).boxed().collect(Collectors.toList());
|
||||
// Cannot be replaced with list.addAll()
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace with collect" "true"
|
||||
import java.util.*;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
final double[] array = new double[10];
|
||||
final List<Double> list = new ArrayList<>();
|
||||
// Cannot be replaced with list.addAll()
|
||||
for (double d : ar<caret>ray) {
|
||||
list.add(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user