mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
simplifiable assertions: autoboxing (IDEA-176911)
This commit is contained in:
+6
-2
@@ -20,12 +20,16 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import com.siyeh.ig.PsiReplacementUtil;
|
||||
import com.siyeh.ig.psiutils.*;
|
||||
import com.siyeh.ig.psiutils.ComparisonUtils;
|
||||
import com.siyeh.ig.psiutils.ImportUtils;
|
||||
import com.siyeh.ig.psiutils.MethodCallUtils;
|
||||
import com.siyeh.ig.psiutils.TypeUtils;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -97,7 +101,7 @@ public abstract class SimplifiableAssertionInspection extends BaseInspection {
|
||||
return false;
|
||||
}
|
||||
final PsiType type = lhs.getType();
|
||||
return type != null && ClassUtils.isPrimitive(type);
|
||||
return type != null && TypeConversionUtil.isPrimitiveAndNotNullOrWrapper(type);
|
||||
}
|
||||
else if (expression instanceof PsiMethodCallExpression) {
|
||||
final PsiMethodCallExpression call = (PsiMethodCallExpression)expression;
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import org.junit.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class BoxedComparisonToEquals {
|
||||
void test(Integer a, int b) {
|
||||
assertEquals((int) a, b);
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import org.junit.*;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class BoxedComparisonToEquals {
|
||||
void test(Integer a, int b) {
|
||||
<caret>assertTrue(a == b);
|
||||
}
|
||||
}
|
||||
+1
@@ -27,6 +27,7 @@ public class SimplifiableJUnitAssertionFixTest extends IGQuickFixesTestCase {
|
||||
public void testJUnit3TestCase() { doTest(); }
|
||||
public void testJUnit4TestCase() { doTest(); }
|
||||
public void testIntegerPrimitive() { doTest(); }
|
||||
public void testBoxedComparisonToEquals() { doTest(); }
|
||||
public void testDoublePrimitive() { doTest(); }
|
||||
public void testEqualsToTrueJUnit5() { doTest(); }
|
||||
public void testTrueToEqualsJUnit5() { doTest(); }
|
||||
|
||||
Reference in New Issue
Block a user