mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 21:55:01 +07:00
RedundantArrayForVarargsCallInspection: do not warn if nested array initializers are used (fixes IDEA-165068)
This commit is contained in:
+4
@@ -31,6 +31,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -120,6 +121,9 @@ public class RedundantArrayForVarargsCallInspection extends GenericsInspectionTo
|
||||
if (initializers == null) {
|
||||
return;
|
||||
}
|
||||
if (Arrays.stream(initializers).anyMatch(expr -> expr instanceof PsiArrayInitializerExpression)) {
|
||||
return;
|
||||
}
|
||||
if (!isSafeToFlatten(expression, method, initializers)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import java.util.*;
|
||||
|
||||
public class NestedArray {
|
||||
public NestedArray() {}
|
||||
|
||||
@@ -13,4 +15,22 @@ public class NestedArray {
|
||||
method(<warning descr="Redundant array creation for calling varargs method">new Object[]{"2", params}</warning>);
|
||||
method(<warning descr="Redundant array creation for calling varargs method">new Object[]{params, params}</warning>);
|
||||
}
|
||||
|
||||
public static Collection quickFixErrorIDEA165068() {
|
||||
return Arrays.asList(new String[][]{
|
||||
{"bla", " bla"},
|
||||
{"bla", " bla"},
|
||||
{"bla", " bla"},
|
||||
{"bla", " bla"},
|
||||
});
|
||||
}
|
||||
|
||||
public static Collection quickFixError2() {
|
||||
return Arrays.asList(<warning descr="Redundant array creation for calling varargs method">new String[][]{
|
||||
new String[] {"bla", " bla"},
|
||||
new String[] {"bla", " bla"},
|
||||
new String[] {"bla", " bla"},
|
||||
new String[] {"bla", " bla"},
|
||||
}</warning>);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user