mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
don't report negated compile-time constants as always true/false (IDEA-118388)
This commit is contained in:
+4
@@ -536,6 +536,10 @@ public class DataFlowInspectionBase extends BaseJavaBatchLocalInspectionTool {
|
||||
}
|
||||
|
||||
private static boolean isCompileConstantInIfCondition(PsiElement element) {
|
||||
if (element instanceof PsiPrefixExpression && ((PsiPrefixExpression)element).getOperationTokenType() == JavaTokenType.EXCL) {
|
||||
return isCompileConstantInIfCondition(((PsiPrefixExpression)element).getOperand());
|
||||
}
|
||||
|
||||
if (!(element instanceof PsiReferenceExpression)) return false;
|
||||
PsiElement resolved = ((PsiReferenceExpression)element).resolve();
|
||||
if (!(resolved instanceof PsiField)) return false;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
class Fun {
|
||||
public static final boolean isDebug = true;
|
||||
|
||||
void foo() {
|
||||
if (isDebug) {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
void fooNegated() {
|
||||
if (!isDebug) {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -184,6 +184,8 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase {
|
||||
public void testUnknownFloatMayBeNaN() { doTest(); }
|
||||
public void testFloatEquality() { doTest(); }
|
||||
public void testLastConstantConditionInAnd() { doTest(); }
|
||||
|
||||
public void testCompileTimeConstant() { doTest(); }
|
||||
|
||||
public void testTransientFinalField() { doTest(); }
|
||||
public void testRememberLocalTransientFieldState() { doTest(); }
|
||||
|
||||
Reference in New Issue
Block a user