boolean (@Nullable PsiExpression expression, @NotNull PsiVariable variable) { final PsiExpression strippedExpression = PsiUtil.skipParenthesizedExprDown(expression); if (strippedExpression == null) { return false; } if (!(strippedExpression instanceof PsiAssignmentExpression assignment)) { return false; } final IElementType tokenType = assignment.getOperationTokenType(); if (!tokenType.equals(JavaTokenType.EQ)) { return false; } final PsiExpression lhs = assignment.getLExpression(); if (SideEffectChecker.mayHaveSideEffects(lhs)) { return false; } if (!ExpressionUtils.isOffsetArrayAccess(lhs, variable)) { return false; } final PsiExpression rhs = assignment.getRExpression(); if (rhs == null) { return false; } if (SideEffectChecker.mayHaveSideEffects(rhs)) { return false; } if (!areExpressionsCopyable(lhs, rhs)) { return false; } final PsiType type = lhs.getType(); if (type instanceof PsiPrimitiveType) { final PsiExpression strippedLhs = PsiUtil.skipParenthesizedExprDown(lhs); final PsiExpression strippedRhs = PsiUtil.skipParenthesizedExprDown(rhs); if (!areExpressionsCopyable(strippedLhs, strippedRhs)) { return false; } } if (!ExpressionUtils.isOffsetArrayAccess(rhs, variable)) { return false; } return !isSameSourceAndDestination(lhs, rhs); }