PsiVariable (PsiAssignmentExpression assignment, IElementType compoundAssignmentOp) { PsiReferenceExpression lExpr = tryCast(assignment.getLExpression(), PsiReferenceExpression.class); if (lExpr == null) return null; PsiVariable var = tryCast(lExpr.resolve(), PsiVariable.class); if (var == null) return null; if (compoundAssignmentOp.equals(assignment.getOperationTokenType())) { return var; } else if (JavaTokenType.EQ.equals(assignment.getOperationTokenType())) { if (assignment.getRExpression() instanceof PsiBinaryExpression binOp) { IElementType op = TypeConversionUtil.convertEQtoOperation(compoundAssignmentOp); if (op.equals(binOp.getOperationTokenType())) { PsiExpression left = binOp.getLOperand(); PsiExpression right = binOp.getROperand(); if (sameReference(left, lExpr) || sameReference(right, lExpr)) { return var; } } } } return null; }