boolean (@NotNull PsiReferenceExpression expression) { PsiElement parent = PsiUtil.skipParenthesizedExprUp(expression.getParent()); if (parent instanceof PsiAssignmentExpression assignment) { if (PsiTreeUtil.isAncestor(assignment.getLExpression(), expression, false)) { return true; } } else if (parent instanceof PsiUnaryExpression unary) { IElementType tokenType = unary.getOperationTokenType(); if ((tokenType.equals(JavaTokenType.PLUSPLUS) || tokenType.equals(JavaTokenType.MINUSMINUS)) && PsiTreeUtil.isAncestor(unary.getOperand(), expression, false)) { return true; } } return false; }