mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-112968 Show "Value is always" warning only for null/true/false
This commit is contained in:
+1
-1
@@ -169,7 +169,7 @@ public class StandardInstructionVisitor extends InstructionVisitor {
|
||||
DfaValue dfaValue = instruction.getValue();
|
||||
if (dfaValue instanceof DfaVariableValue) {
|
||||
DfaConstValue constValue = memState.getConstantValue((DfaVariableValue)dfaValue);
|
||||
myPossibleVariableValues.putValue(instruction, constValue != null ? constValue : ANY_VALUE);
|
||||
myPossibleVariableValues.putValue(instruction, constValue != null && (constValue.getValue() == null || constValue.getValue() instanceof Boolean) ? constValue : ANY_VALUE);
|
||||
}
|
||||
}
|
||||
return super.visitPush(instruction, runner, memState);
|
||||
|
||||
@@ -161,28 +161,27 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase {
|
||||
myFixture.testHighlighting(true, false, true, getTestName(false) + ".java");
|
||||
}
|
||||
|
||||
public void testReportConstantReferences_ReplaceWithString() {
|
||||
public void _testReportConstantReferences_ReplaceWithString() {
|
||||
doTestReportConstantReferences();
|
||||
myFixture.launchAction(myFixture.findSingleIntention("Replace with 'CONST'"));
|
||||
myFixture.checkResultByFile(getTestName(false) + "_after.java");
|
||||
}
|
||||
public void testReportConstantReferences_ReplaceWithIntConstant() {
|
||||
public void _testReportConstantReferences_ReplaceWithIntConstant() {
|
||||
doTestReportConstantReferences();
|
||||
myFixture.launchAction(myFixture.findSingleIntention("Replace with 'CONST'"));
|
||||
myFixture.checkResultByFile(getTestName(false) + "_after.java");
|
||||
}
|
||||
public void testReportConstantReferences_ReplaceWithEnum() {
|
||||
public void _testReportConstantReferences_ReplaceWithEnum() {
|
||||
myFixture.addClass("package foo; public enum MyEnum { FOO }");
|
||||
doTestReportConstantReferences();
|
||||
myFixture.launchAction(myFixture.findSingleIntention("Replace with 'FOO'"));
|
||||
myFixture.checkResultByFile(getTestName(false) + "_after.java");
|
||||
}
|
||||
public void testReportConstantReferences_NotInComplexAssignment() {
|
||||
myFixture.addClass("package foo; public enum MyEnum { FOO }");
|
||||
public void _testReportConstantReferences_NotInComplexAssignment() {
|
||||
doTestReportConstantReferences();
|
||||
assertEmpty(myFixture.filterAvailableIntentions("Replace with"));
|
||||
}
|
||||
public void testReportConstantReferences_Switch() { doTestReportConstantReferences(); }
|
||||
public void _testReportConstantReferences_Switch() { doTestReportConstantReferences(); }
|
||||
|
||||
public void testCheckFieldInitializers() {
|
||||
doTest();
|
||||
|
||||
Reference in New Issue
Block a user