mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
dfa: don't report the same constant expression twice (IDEA-158693, IDEA-CR-12537)
This commit is contained in:
+4
-3
@@ -303,7 +303,7 @@ public class DataFlowInspectionBase extends BaseJavaBatchLocalInspectionTool {
|
||||
}
|
||||
}
|
||||
|
||||
reportConstantPushes(runner, holder, visitor);
|
||||
reportConstantPushes(runner, holder, visitor, reportedAnchors);
|
||||
|
||||
reportNullableArguments(visitor, holder, reportedAnchors);
|
||||
reportNullableAssignments(visitor, holder, reportedAnchors);
|
||||
@@ -323,13 +323,14 @@ public class DataFlowInspectionBase extends BaseJavaBatchLocalInspectionTool {
|
||||
|
||||
private void reportConstantPushes(StandardDataFlowRunner runner,
|
||||
ProblemsHolder holder,
|
||||
DataFlowInstructionVisitor visitor) {
|
||||
DataFlowInstructionVisitor visitor,
|
||||
Set<PsiElement> reportedAnchors) {
|
||||
for (Instruction instruction : runner.getInstructions()) {
|
||||
if (instruction instanceof PushInstruction) {
|
||||
PsiExpression place = ((PushInstruction)instruction).getPlace();
|
||||
DfaValue value = ((PushInstruction)instruction).getValue();
|
||||
Object constant = value instanceof DfaConstValue ? ((DfaConstValue)value).getValue() : null;
|
||||
if (place instanceof PsiPolyadicExpression && constant instanceof Boolean) {
|
||||
if (place instanceof PsiPolyadicExpression && constant instanceof Boolean && reportedAnchors.add(place)) {
|
||||
reportConstantCondition(holder, visitor, place, (Boolean)constant);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
class BrokenAlignment {
|
||||
|
||||
boolean smth() {
|
||||
if (<warning descr="Condition '2 == 2' is always 'true'"><warning descr="Condition '2 == 2' is always 'true'">2 == 2</warning></warning>) {
|
||||
if (<warning descr="Condition '2 == 2' is always 'true'">2 == 2</warning>) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user