boolean (PsiExpression expression) { expression = PsiUtil.skipParenthesizedExprDown(expression); if (expression == null) { return false; } if (expression instanceof PsiNewExpression newExpression) { final PsiArrayInitializerExpression arrayInitializer = newExpression.getArrayInitializer(); return mayBeAccessedElsewhere(arrayInitializer); } else if (expression instanceof PsiArrayInitializerExpression arrayInitializerExpression) { for (PsiExpression initializer : arrayInitializerExpression.getInitializers()) { if (mayBeAccessedElsewhere(initializer)) { return true; } } return false; } else if (expression instanceof PsiReferenceExpression) { return expression.getType() instanceof PsiArrayType || TypeUtils.isJavaLangObject(expression.getType()); } else if (expression instanceof PsiArrayAccessExpression) { return true; } else if (expression instanceof PsiTypeCastExpression typeCastExpression) { return mayBeAccessedElsewhere(typeCastExpression.getOperand()); } else if (expression instanceof PsiConditionalExpression conditionalExpression) { return mayBeAccessedElsewhere(conditionalExpression.getThenExpression()) || mayBeAccessedElsewhere(conditionalExpression.getElseExpression()); } else if (expression instanceof PsiMethodCallExpression methodCallExpression) { final PsiMethod method = methodCallExpression.resolveMethod(); if (method == null) { return true; } if (CloneUtils.isClone(method)) { return false; } @NonNls final String name = method.getName(); if ("copyOf".equals(name) || "copyOfRange".equals(name)) { final PsiClass aClass = method.getContainingClass(); if (aClass != null && CommonClassNames.JAVA_UTIL_ARRAYS.equals(aClass.getQualifiedName())) { return false; } } else if ("toArray".equals(name) && InheritanceUtil.isInheritor(method.getContainingClass(), "java.util.Collection")) { return false; } return true; } else if (expression instanceof PsiLiteralExpression) { return false; } return true; }