boolean (PsiExpression expression) { expression = PsiUtil.skipParenthesizedExprDown(expression); if (expression instanceof PsiNewExpression) { PsiExpressionList args = ((PsiNewExpression)expression).getArgumentList(); if (args == null || args.isEmpty()) return false; PsiMethod ctor = ((PsiNewExpression)expression).resolveMethod(); if (ctor == null) return false; PsiClass aClass = ctor.getContainingClass(); if (aClass == null) return false; String name = aClass.getQualifiedName(); if (name == null || !name.startsWith("java.util.")) return false; for (PsiParameter parameter : ctor.getParameterList().getParameters()) { PsiType type = parameter.getType(); if (PsiTypesUtil.classNameEquals(type, CommonClassNames.JAVA_UTIL_COLLECTION) || PsiTypesUtil.classNameEquals(type, CommonClassNames.JAVA_UTIL_MAP)) { return true; } } } if (expression instanceof PsiMethodCallExpression call) { @NonNls String name = call.getMethodExpression().getReferenceName(); PsiExpressionList argumentList = call.getArgumentList(); if(name != null && name.startsWith("new") && !argumentList.isEmpty()) { PsiMethod method = call.resolveMethod(); if (method == null) return false; PsiClass aClass = method.getContainingClass(); if (aClass == null) return false; String qualifiedName = aClass.getQualifiedName(); if (qualifiedName == null || !GUAVA_UTILITY_CLASSES.contains(qualifiedName)) return false; for (PsiParameter parameter : method.getParameterList().getParameters()) { PsiType type = parameter.getType(); if (type instanceof PsiEllipsisType) { return true; } if (PsiTypesUtil.classNameEquals(type, CommonClassNames.JAVA_LANG_ITERABLE) || PsiTypesUtil.classNameEquals(type, CommonClassNames.JAVA_UTIL_ITERATOR)) { return true; } } } } return false; }