boolean (@NotNull PsiExpression from, @NotNull PsiExpression to, @NotNull PsiExpression diff) { diff = PsiUtil.skipParenthesizedExprDown(diff); if (diff == null) return false; EquivalenceChecker eq = EquivalenceChecker.getCanonicalPsiEquivalence(); if (isZero(from) && eq.expressionsAreEquivalent(to, diff)) return true; if (isZero(diff) && eq.expressionsAreEquivalent(to, from)) return true; if (to instanceof PsiPolyadicExpression && from instanceof PsiPolyadicExpression) { final Pair<@NotNull PsiExpression, @NotNull PsiExpression> polyadicDiff = getPolyadicDiff((PsiPolyadicExpression)from, (PsiPolyadicExpression)to); from = polyadicDiff.first; to = polyadicDiff.second; } if (diff instanceof PsiBinaryExpression && ((PsiBinaryExpression)diff).getOperationTokenType().equals(JavaTokenType.MINUS)) { PsiExpression left = ((PsiBinaryExpression)diff).getLOperand(); PsiExpression right = ((PsiBinaryExpression)diff).getROperand(); if (right != null && eq.expressionsAreEquivalent(to, left) && eq.expressionsAreEquivalent(from, right)) { return true; } } if (from instanceof PsiBinaryExpression && ((PsiBinaryExpression)from).getOperationTokenType().equals(JavaTokenType.MINUS)) { PsiExpression left = ((PsiBinaryExpression)from).getLOperand(); PsiExpression right = ((PsiBinaryExpression)from).getROperand(); if (right != null && eq.expressionsAreEquivalent(to, left) && eq.expressionsAreEquivalent(diff, right)) { return true; } } if (to instanceof PsiBinaryExpression && ((PsiBinaryExpression)to).getOperationTokenType().equals(JavaTokenType.PLUS)) { PsiExpression left = ((PsiBinaryExpression)to).getLOperand(); PsiExpression right = ((PsiBinaryExpression)to).getROperand(); if (right != null && eq.expressionsAreEquivalent(left, from) && eq.expressionsAreEquivalent(right, diff) || (eq.expressionsAreEquivalent(right, from) && eq.expressionsAreEquivalent(left, diff))) { return true; } } Integer fromConstant = tryCast(computeConstantExpression(from), Integer.class); if (fromConstant == null) return false; Integer toConstant = tryCast(computeConstantExpression(to), Integer.class); if (toConstant == null) return false; Integer diffConstant = tryCast(computeConstantExpression(diff), Integer.class); if (diffConstant == null) return false; return diffConstant == toConstant - fromConstant; }