boolean (PsiExpression expression) { final PsiElement parent = expression.getParent(); if (parent instanceof PsiParenthesizedExpression parenthesizedExpression) { return isVariableValueUsed(parenthesizedExpression); } if (parent instanceof PsiPolyadicExpression polyadicExpression) { return isVariableValueUsed(polyadicExpression); } if (parent instanceof PsiTypeCastExpression typeCastExpression) { return isVariableValueUsed(typeCastExpression); } if (parent instanceof PsiReturnStatement) { return true; } if (parent instanceof PsiExpressionList) { final PsiElement grandParent = parent.getParent(); if (grandParent instanceof PsiMethodCallExpression) { return true; } } else if (parent instanceof PsiArrayInitializerExpression) { return true; } else if (parent instanceof PsiAssignmentExpression assignmentExpression) { final PsiExpression rhs = assignmentExpression.getRExpression(); return expression.equals(rhs); } else if (parent instanceof PsiVariable variable) { final PsiExpression initializer = variable.getInitializer(); return expression.equals(initializer); } return false; }