IG: fix inspection option

This commit is contained in:
Bas Leijdekkers
2015-12-02 10:50:30 +01:00
parent 3a669178f5
commit 3fec091935
4 changed files with 30 additions and 2 deletions
@@ -294,7 +294,7 @@ public class ImplicitNumericConversionInspection extends BaseInspection {
if (expressionType.equals(expectedType)) {
return;
}
if (ignoreWideningConversions && TypeUtils.isNarrowingConversion(expressionType, expectedType)) {
if (ignoreWideningConversions && !TypeUtils.isNarrowingConversion(expressionType, expectedType)) {
return;
}
if (ignoreCharConversions && PsiType.CHAR.equals(expectedType)) {
@@ -0,0 +1,7 @@
class IgnoreCharConversion {
void m(int i) {
final char a = 'a';
i = a;
}
}
@@ -0,0 +1,6 @@
class IgnoreWidening {
void m(int i) {
long l = i;
byte b = 2;
}
}
@@ -6,7 +6,22 @@ import org.jetbrains.annotations.Nullable;
public class ImplicitNumericConversionInspectionTest extends LightInspectionTestCase {
public void testImplicitNumericConversion() throws Exception {
public void testImplicitNumericConversion() {
doTest();
}
public void testIgnoreCharConversion() {
final ImplicitNumericConversionInspection inspection = new ImplicitNumericConversionInspection();
inspection.ignoreCharConversions = true;
myFixture.enableInspections(inspection);
doTest();
}
public void testIgnoreWidening() {
final ImplicitNumericConversionInspection inspection = new ImplicitNumericConversionInspection();
inspection.ignoreWideningConversions = true;
inspection.ignoreConstantConversions = true;
myFixture.enableInspections(inspection);
doTest();
}