dfa: don't report the same constant expression twice (IDEA-158693, IDEA-CR-12537)

This commit is contained in:
peter
2016-08-01 20:21:23 +02:00
parent 7b37b37f81
commit d923897b64
2 changed files with 5 additions and 4 deletions
@@ -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,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;
}