From 72078f0b1da63ae8d3510c81629c2472094395cc Mon Sep 17 00:00:00 2001 From: Tagir Valeev Date: Thu, 11 May 2017 13:17:25 +0700 Subject: [PATCH] RedundantArrayForVarargsCallInspectionTest: make it LightInspectionTestCase --- .../CheckEnumConstant.java | 7 ++++++ .../redundantArrayForVarargs/Generic.java | 22 +++++++++++++++++++ .../src/Test.java => IDEADEV15215.java} | 4 ++-- .../IDEADEV15215/expected.xml | 10 --------- .../IDEADEV25923.java | 9 ++++++++ .../IDEADEV25923/expected.xml | 10 --------- .../IDEADEV25923/src/Test.java | 9 -------- .../src/Test.java => NestedArray.java} | 8 +++---- .../Test.java => PolymorphicSignature.java} | 4 ++-- .../redundantArrayForVarargs/RawArray.java | 9 ++++++++ .../checkEnumConstant/expected.xml | 9 -------- .../checkEnumConstant/src/Test.java | 7 ------ .../generic/expected.xml | 16 -------------- .../generic/src/Test.java | 22 ------------------- .../nestedArray/expected.xml | 17 -------------- .../polymorphicSignature/expected.xml | 3 --- .../rawArray/expected.xml | 9 -------- .../rawArray/src/Test.java | 9 -------- ...dantArrayForVarargsCallInspectionTest.java | 14 +++++++----- 19 files changed, 63 insertions(+), 135 deletions(-) create mode 100644 java/java-tests/testData/inspection/redundantArrayForVarargs/CheckEnumConstant.java create mode 100644 java/java-tests/testData/inspection/redundantArrayForVarargs/Generic.java rename java/java-tests/testData/inspection/redundantArrayForVarargs/{IDEADEV15215/src/Test.java => IDEADEV15215.java} (71%) delete mode 100644 java/java-tests/testData/inspection/redundantArrayForVarargs/IDEADEV15215/expected.xml create mode 100644 java/java-tests/testData/inspection/redundantArrayForVarargs/IDEADEV25923.java delete mode 100644 java/java-tests/testData/inspection/redundantArrayForVarargs/IDEADEV25923/expected.xml delete mode 100644 java/java-tests/testData/inspection/redundantArrayForVarargs/IDEADEV25923/src/Test.java rename java/java-tests/testData/inspection/redundantArrayForVarargs/{nestedArray/src/Test.java => NestedArray.java} (50%) rename java/java-tests/testData/inspection/redundantArrayForVarargs/{polymorphicSignature/src/Test.java => PolymorphicSignature.java} (53%) create mode 100644 java/java-tests/testData/inspection/redundantArrayForVarargs/RawArray.java delete mode 100644 java/java-tests/testData/inspection/redundantArrayForVarargs/checkEnumConstant/expected.xml delete mode 100644 java/java-tests/testData/inspection/redundantArrayForVarargs/checkEnumConstant/src/Test.java delete mode 100644 java/java-tests/testData/inspection/redundantArrayForVarargs/generic/expected.xml delete mode 100644 java/java-tests/testData/inspection/redundantArrayForVarargs/generic/src/Test.java delete mode 100644 java/java-tests/testData/inspection/redundantArrayForVarargs/nestedArray/expected.xml delete mode 100644 java/java-tests/testData/inspection/redundantArrayForVarargs/polymorphicSignature/expected.xml delete mode 100644 java/java-tests/testData/inspection/redundantArrayForVarargs/rawArray/expected.xml delete mode 100644 java/java-tests/testData/inspection/redundantArrayForVarargs/rawArray/src/Test.java diff --git a/java/java-tests/testData/inspection/redundantArrayForVarargs/CheckEnumConstant.java b/java/java-tests/testData/inspection/redundantArrayForVarargs/CheckEnumConstant.java new file mode 100644 index 000000000000..87f80dff50a3 --- /dev/null +++ b/java/java-tests/testData/inspection/redundantArrayForVarargs/CheckEnumConstant.java @@ -0,0 +1,7 @@ + +public enum CheckEnumConstant { + A(new String[]{"1", "2"}); + + CheckEnumConstant(String... ss) { + } +} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/redundantArrayForVarargs/Generic.java b/java/java-tests/testData/inspection/redundantArrayForVarargs/Generic.java new file mode 100644 index 000000000000..6641101c79d6 --- /dev/null +++ b/java/java-tests/testData/inspection/redundantArrayForVarargs/Generic.java @@ -0,0 +1,22 @@ + +class Generic { + class A {} + class B extends A {} + + void f() { + B b = new B(); + C l = asC(new A[]{b}); + A a = new A(); + C m = asC(new A[]{a}); + } + + public static C asC(T... ts) { + return null; + } + + class C {} + + void m() { + System.out.println(String.format("%s %s", new Object[] {"Z", "X"})); + } +} diff --git a/java/java-tests/testData/inspection/redundantArrayForVarargs/IDEADEV15215/src/Test.java b/java/java-tests/testData/inspection/redundantArrayForVarargs/IDEADEV15215.java similarity index 71% rename from java/java-tests/testData/inspection/redundantArrayForVarargs/IDEADEV15215/src/Test.java rename to java/java-tests/testData/inspection/redundantArrayForVarargs/IDEADEV15215.java index 6e5906243ab7..c7f18164d853 100644 --- a/java/java-tests/testData/inspection/redundantArrayForVarargs/IDEADEV15215/src/Test.java +++ b/java/java-tests/testData/inspection/redundantArrayForVarargs/IDEADEV15215.java @@ -1,5 +1,5 @@ -public class Test { +public class IDEADEV15215 { public static void main(String[] args) { foo(new byte[]{ 1, 2, 3 }); @@ -15,6 +15,6 @@ public class Test { public static void extra(String... args) { - extra(new String[]{"vvv","aaa"}); + extra(new String[]{"vvv","aaa"}); } } \ No newline at end of file diff --git a/java/java-tests/testData/inspection/redundantArrayForVarargs/IDEADEV15215/expected.xml b/java/java-tests/testData/inspection/redundantArrayForVarargs/IDEADEV15215/expected.xml deleted file mode 100644 index feec61b2f901..000000000000 --- a/java/java-tests/testData/inspection/redundantArrayForVarargs/IDEADEV15215/expected.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - Test.java - 18 - Redundant array creation - Redundant array creation for calling varargs method - - - \ No newline at end of file diff --git a/java/java-tests/testData/inspection/redundantArrayForVarargs/IDEADEV25923.java b/java/java-tests/testData/inspection/redundantArrayForVarargs/IDEADEV25923.java new file mode 100644 index 000000000000..2577a883c0c7 --- /dev/null +++ b/java/java-tests/testData/inspection/redundantArrayForVarargs/IDEADEV25923.java @@ -0,0 +1,9 @@ + +public class IDEADEV25923 { + public void foo(Object... params) {} + + { + foo(new Object[2]); + foo(new Object[0]); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/redundantArrayForVarargs/IDEADEV25923/expected.xml b/java/java-tests/testData/inspection/redundantArrayForVarargs/IDEADEV25923/expected.xml deleted file mode 100644 index 39c27163eab6..000000000000 --- a/java/java-tests/testData/inspection/redundantArrayForVarargs/IDEADEV25923/expected.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - Test.java - 7 - Redundant array creation - Redundant array creation for calling varargs method - - - \ No newline at end of file diff --git a/java/java-tests/testData/inspection/redundantArrayForVarargs/IDEADEV25923/src/Test.java b/java/java-tests/testData/inspection/redundantArrayForVarargs/IDEADEV25923/src/Test.java deleted file mode 100644 index 7d8c3b17812a..000000000000 --- a/java/java-tests/testData/inspection/redundantArrayForVarargs/IDEADEV25923/src/Test.java +++ /dev/null @@ -1,9 +0,0 @@ - -public class Test { - public void foo(Object... params) {} - - { - foo(new Object[2]); - foo(new Object[0]); - } -} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/redundantArrayForVarargs/nestedArray/src/Test.java b/java/java-tests/testData/inspection/redundantArrayForVarargs/NestedArray.java similarity index 50% rename from java/java-tests/testData/inspection/redundantArrayForVarargs/nestedArray/src/Test.java rename to java/java-tests/testData/inspection/redundantArrayForVarargs/NestedArray.java index 863ac6f1e177..d91e1b0e6169 100644 --- a/java/java-tests/testData/inspection/redundantArrayForVarargs/nestedArray/src/Test.java +++ b/java/java-tests/testData/inspection/redundantArrayForVarargs/NestedArray.java @@ -1,5 +1,5 @@ -public class IntentionTest { - public IntentionTest() {} +public class NestedArray { + public NestedArray() {} public void method( Object ... args ) { for (int i = 0; i < args.length; i++) { @@ -10,7 +10,7 @@ public class IntentionTest { public void main(String[] args) { String[] params = new String[]{ "0", "1" }; method(new Object[]{params}); - method(new Object[]{"2", params}); - method(new Object[]{params, params}); + method(new Object[]{"2", params}); + method(new Object[]{params, params}); } } \ No newline at end of file diff --git a/java/java-tests/testData/inspection/redundantArrayForVarargs/polymorphicSignature/src/Test.java b/java/java-tests/testData/inspection/redundantArrayForVarargs/PolymorphicSignature.java similarity index 53% rename from java/java-tests/testData/inspection/redundantArrayForVarargs/polymorphicSignature/src/Test.java rename to java/java-tests/testData/inspection/redundantArrayForVarargs/PolymorphicSignature.java index b6cd9f28da7f..0c8068d58587 100644 --- a/java/java-tests/testData/inspection/redundantArrayForVarargs/polymorphicSignature/src/Test.java +++ b/java/java-tests/testData/inspection/redundantArrayForVarargs/PolymorphicSignature.java @@ -1,8 +1,8 @@ import java.lang.invoke.MethodHandle; -public class Test { +public class PolymorphicSignature { - public static void main(String[] args) { + public static void main(String[] args) throws Throwable { MethodHandle meh = null; meh.invokeExact(new Object[] {}); } diff --git a/java/java-tests/testData/inspection/redundantArrayForVarargs/RawArray.java b/java/java-tests/testData/inspection/redundantArrayForVarargs/RawArray.java new file mode 100644 index 000000000000..da0500ea2df4 --- /dev/null +++ b/java/java-tests/testData/inspection/redundantArrayForVarargs/RawArray.java @@ -0,0 +1,9 @@ +public class RawArray { + { + try { + String.class.getConstructor(new Class[]{String.class}); + } catch (Exception e) { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/redundantArrayForVarargs/checkEnumConstant/expected.xml b/java/java-tests/testData/inspection/redundantArrayForVarargs/checkEnumConstant/expected.xml deleted file mode 100644 index d4c072df88f4..000000000000 --- a/java/java-tests/testData/inspection/redundantArrayForVarargs/checkEnumConstant/expected.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - Test.java - 3 - Redundant array creation - Redundant array creation for calling varargs method - - \ No newline at end of file diff --git a/java/java-tests/testData/inspection/redundantArrayForVarargs/checkEnumConstant/src/Test.java b/java/java-tests/testData/inspection/redundantArrayForVarargs/checkEnumConstant/src/Test.java deleted file mode 100644 index abef220717ae..000000000000 --- a/java/java-tests/testData/inspection/redundantArrayForVarargs/checkEnumConstant/src/Test.java +++ /dev/null @@ -1,7 +0,0 @@ - -public enum Test { - A(new String[]{"1", "2"}); - - Test(String... ss) { - } -} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/redundantArrayForVarargs/generic/expected.xml b/java/java-tests/testData/inspection/redundantArrayForVarargs/generic/expected.xml deleted file mode 100644 index 1a4164ee3399..000000000000 --- a/java/java-tests/testData/inspection/redundantArrayForVarargs/generic/expected.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - Test.java - 10 - Redundant array creation - Redundant array creation for calling varargs method - - - - Test.java - 20 - Redundant array creation - Redundant array creation for calling varargs method - - \ No newline at end of file diff --git a/java/java-tests/testData/inspection/redundantArrayForVarargs/generic/src/Test.java b/java/java-tests/testData/inspection/redundantArrayForVarargs/generic/src/Test.java deleted file mode 100644 index b90af553ffa6..000000000000 --- a/java/java-tests/testData/inspection/redundantArrayForVarargs/generic/src/Test.java +++ /dev/null @@ -1,22 +0,0 @@ - -class Test { - class A {} - class B extends A {} - - void f() { - B b = new B(); - C l = asC(new A[]{b}); - A a = new A(); - C m = asC(new A[]{a}); - } - - public static C asC(T... ts) { - return null; - } - - class C {} - - void m() { - System.out.println(String.format("%s %s", new Object[] {"Z", "X"})); - } -} diff --git a/java/java-tests/testData/inspection/redundantArrayForVarargs/nestedArray/expected.xml b/java/java-tests/testData/inspection/redundantArrayForVarargs/nestedArray/expected.xml deleted file mode 100644 index 35e28d87f030..000000000000 --- a/java/java-tests/testData/inspection/redundantArrayForVarargs/nestedArray/expected.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - Test.java - 13 - Redundant array creation - Redundant array creation for calling varargs method - - - - Test.java - 14 - Redundant array creation - Redundant array creation for calling varargs method - - - \ No newline at end of file diff --git a/java/java-tests/testData/inspection/redundantArrayForVarargs/polymorphicSignature/expected.xml b/java/java-tests/testData/inspection/redundantArrayForVarargs/polymorphicSignature/expected.xml deleted file mode 100644 index 5e933496b9cf..000000000000 --- a/java/java-tests/testData/inspection/redundantArrayForVarargs/polymorphicSignature/expected.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/java/java-tests/testData/inspection/redundantArrayForVarargs/rawArray/expected.xml b/java/java-tests/testData/inspection/redundantArrayForVarargs/rawArray/expected.xml deleted file mode 100644 index 2b78f14a5517..000000000000 --- a/java/java-tests/testData/inspection/redundantArrayForVarargs/rawArray/expected.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - Test.java - 4 - Redundant array creation - Redundant array creation for calling varargs method - - \ No newline at end of file diff --git a/java/java-tests/testData/inspection/redundantArrayForVarargs/rawArray/src/Test.java b/java/java-tests/testData/inspection/redundantArrayForVarargs/rawArray/src/Test.java deleted file mode 100644 index 68e9a3f198c1..000000000000 --- a/java/java-tests/testData/inspection/redundantArrayForVarargs/rawArray/src/Test.java +++ /dev/null @@ -1,9 +0,0 @@ -public class Test { - { - try { - String.class.getConstructor(new Class[]{String.class}); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } - } -} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantArrayForVarargsCallInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantArrayForVarargsCallInspectionTest.java index 38ceeff5bab3..70a156fcb5b0 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantArrayForVarargsCallInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantArrayForVarargsCallInspectionTest.java @@ -2,20 +2,22 @@ package com.intellij.codeInspection; import com.intellij.JavaTestUtil; import com.intellij.codeInspection.miscGenerics.RedundantArrayForVarargsCallInspection; -import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; -import com.intellij.testFramework.InspectionTestCase; +import com.siyeh.ig.LightInspectionTestCase; +import org.jetbrains.annotations.Nullable; /** * @author cdr */ -public class RedundantArrayForVarargsCallInspectionTest extends InspectionTestCase { +public class RedundantArrayForVarargsCallInspectionTest extends LightInspectionTestCase { @Override protected String getTestDataPath() { - return JavaTestUtil.getJavaTestDataPath() + "/inspection"; + return JavaTestUtil.getJavaTestDataPath() + "/inspection/redundantArrayForVarargs/"; } - private void doTest() throws Exception { - doTest("redundantArrayForVarargs/" + getTestName(true), new LocalInspectionToolWrapper(new RedundantArrayForVarargsCallInspection()),"java 1.5"); + @Nullable + @Override + protected InspectionProfileEntry getInspection() { + return new RedundantArrayForVarargsCallInspection(); } public void testIDEADEV15215() throws Exception { doTest(); }