diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/fixes/ignore_class_fix/afterAccessToStaticFieldLockedOnInstance.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/fixes/ignore_class_fix/afterAccessToStaticFieldLockedOnInstance.java new file mode 100644 index 000000000000..0d2081b31e22 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/fixes/ignore_class_fix/afterAccessToStaticFieldLockedOnInstance.java @@ -0,0 +1,9 @@ +// "Ignore static fields with type 'java.lang.String'" "true" + +class X { + private static String nice; + + synchronized void x() { + System.out.println(nice); + } +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/fixes/ignore_class_fix/afterResultOfObjectAllocationIgnored.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/fixes/ignore_class_fix/afterResultOfObjectAllocationIgnored.java new file mode 100644 index 000000000000..c919b46497fd --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/fixes/ignore_class_fix/afterResultOfObjectAllocationIgnored.java @@ -0,0 +1,7 @@ +// "Ignore allocations of objects with type 'java.lang.String'" "true" + +class X { + void x() { + new String(); + } +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/fixes/ignore_class_fix/afterSizeReplaceableByIsEmpty.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/fixes/ignore_class_fix/afterSizeReplaceableByIsEmpty.java new file mode 100644 index 000000000000..6a0476ceb46b --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/fixes/ignore_class_fix/afterSizeReplaceableByIsEmpty.java @@ -0,0 +1,8 @@ +// "Ignore '.size()' calls on type 'java.util.ArrayList'" "true" +import java.util.ArrayList; + +class X { + boolean x(ArrayList list) { + return list.size() == 0; + } +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/fixes/ignore_class_fix/afterStaticImport.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/fixes/ignore_class_fix/afterStaticImport.java new file mode 100644 index 000000000000..f15cbd2d5e24 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/fixes/ignore_class_fix/afterStaticImport.java @@ -0,0 +1,5 @@ +// "Allow static imports for class 'java.lang.Math'" "true" + +import static java.lang.Math.*; + +class X {} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/fixes/ignore_class_fix/beforeAccessToStaticFieldLockedOnInstance.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/fixes/ignore_class_fix/beforeAccessToStaticFieldLockedOnInstance.java new file mode 100644 index 000000000000..0d2081b31e22 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/fixes/ignore_class_fix/beforeAccessToStaticFieldLockedOnInstance.java @@ -0,0 +1,9 @@ +// "Ignore static fields with type 'java.lang.String'" "true" + +class X { + private static String nice; + + synchronized void x() { + System.out.println(nice); + } +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/fixes/ignore_class_fix/beforeResultOfObjectAllocationIgnored.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/fixes/ignore_class_fix/beforeResultOfObjectAllocationIgnored.java new file mode 100644 index 000000000000..c919b46497fd --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/fixes/ignore_class_fix/beforeResultOfObjectAllocationIgnored.java @@ -0,0 +1,7 @@ +// "Ignore allocations of objects with type 'java.lang.String'" "true" + +class X { + void x() { + new String(); + } +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/fixes/ignore_class_fix/beforeSizeReplaceableByIsEmpty.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/fixes/ignore_class_fix/beforeSizeReplaceableByIsEmpty.java new file mode 100644 index 000000000000..6a0476ceb46b --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/fixes/ignore_class_fix/beforeSizeReplaceableByIsEmpty.java @@ -0,0 +1,8 @@ +// "Ignore '.size()' calls on type 'java.util.ArrayList'" "true" +import java.util.ArrayList; + +class X { + boolean x(ArrayList list) { + return list.size() == 0; + } +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/fixes/ignore_class_fix/beforeStaticImport.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/fixes/ignore_class_fix/beforeStaticImport.java new file mode 100644 index 000000000000..f15cbd2d5e24 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/fixes/ignore_class_fix/beforeStaticImport.java @@ -0,0 +1,5 @@ +// "Allow static imports for class 'java.lang.Math'" "true" + +import static java.lang.Math.*; + +class X {} \ No newline at end of file diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/IgnoreClassFixTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/IgnoreClassFixTest.java new file mode 100644 index 000000000000..d73e58950713 --- /dev/null +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/IgnoreClassFixTest.java @@ -0,0 +1,43 @@ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +package com.siyeh.ig.fixes; + +import com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase; +import com.intellij.codeInspection.LocalInspectionTool; +import com.intellij.openapi.application.ex.PathManagerEx; +import com.siyeh.ig.bugs.ResultOfObjectAllocationIgnoredInspection; +import com.siyeh.ig.imports.StaticImportInspection; +import com.siyeh.ig.style.SizeReplaceableByIsEmptyInspection; +import com.siyeh.ig.threading.AccessToStaticFieldLockedOnInstanceInspection; +import org.jetbrains.annotations.NotNull; + +/** + * @author Bas Leijdekkers + */ +public class IgnoreClassFixTest extends LightQuickFixParameterizedTestCase { + + @NotNull + @Override + protected LocalInspectionTool[] configureLocalInspectionTools() { + return new LocalInspectionTool[]{ + new SizeReplaceableByIsEmptyInspection(), + new ResultOfObjectAllocationIgnoredInspection(), + new StaticImportInspection(), + new AccessToStaticFieldLockedOnInstanceInspection() + }; + } + + public void test() { + doAllTests(); + } + + @Override + protected String getBasePath() { + return "/com/siyeh/igfixes/fixes/ignore_class_fix"; + } + + @NotNull + @Override + protected String getTestDataPath() { + return PathManagerEx.getCommunityHomePath() + "/plugins/InspectionGadgets/test"; + } +} \ No newline at end of file