boolean (@NotNull PsiIfStatement ifStatement, @NotNull Set<PsiVariable> nonFinalVariables, @NotNull Set<PsiVariable> declaredVariables) { PsiStatement[] statements = getStatements(ifStatement); if (statements.length == 0) return false; Set<PsiVariable> usedVariables = new HashSet<>(); for (PsiStatement statement : statements) { PsiAssignmentExpression assignment = getAssignment(statement); if (assignment == null) return false; PsiExpression lhs = assignment.getLExpression(); Set<PsiVariable> lhsVariables = VariableAccessUtils.collectUsedVariables(lhs); if (haveCommonElements(lhsVariables, nonFinalVariables) || mayHaveOutsideOfLoopSideEffects(lhs, declaredVariables)) return false; PsiExpression rhs = assignment.getRExpression(); if (rhs == null) return false; Set<PsiVariable> rhsVariables = VariableAccessUtils.collectUsedVariables(rhs); if (haveCommonElements(rhsVariables, nonFinalVariables) || mayHaveOutsideOfLoopSideEffects(rhs, declaredVariables)) return false; usedVariables.addAll(rhsVariables); if (!usedVariables.addAll(lhsVariables)) return false; } return true; }