IG: test IgnoreClassFix more

This commit is contained in:
Bas Leijdekkers
2018-02-07 08:26:23 +01:00
parent dd3706a8dd
commit e4eb26feb2
9 changed files with 101 additions and 0 deletions
@@ -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(<caret>nice);
}
}
@@ -0,0 +1,7 @@
// "Ignore allocations of objects with type 'java.lang.String'" "true"
class X {
void x() {
new <caret>String();
}
}
@@ -0,0 +1,8 @@
// "Ignore '.size()' calls on type 'java.util.ArrayList'" "true"
import java.util.ArrayList;
class X {
boolean x(ArrayList<String> list) {
return list.<caret>size() == 0;
}
}
@@ -0,0 +1,5 @@
// "Allow static imports for class 'java.lang.Math'" "true"
import static <caret>java.lang.Math.*;
class X {}
@@ -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(<caret>nice);
}
}
@@ -0,0 +1,7 @@
// "Ignore allocations of objects with type 'java.lang.String'" "true"
class X {
void x() {
new <caret>String();
}
}
@@ -0,0 +1,8 @@
// "Ignore '.size()' calls on type 'java.util.ArrayList'" "true"
import java.util.ArrayList;
class X {
boolean x(ArrayList<String> list) {
return list.<caret>size() == 0;
}
}
@@ -0,0 +1,5 @@
// "Allow static imports for class 'java.lang.Math'" "true"
import static <caret>java.lang.Math.*;
class X {}
@@ -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";
}
}