boolean (PsiExpression expression) { expression = PsiUtil.skipParenthesizedExprDown(expression); if (expression instanceof PsiNewExpression) { PsiExpressionList argumentList = ((PsiNewExpression)expression).getArgumentList(); if (argumentList == null || argumentList.isEmpty() || ((PsiNewExpression)expression).getAnonymousClass() != null) return false; PsiMethod constructor = ((PsiNewExpression)expression).resolveConstructor(); if (constructor == null) return false; PsiClass aClass = constructor.getContainingClass(); if (aClass != null && (aClass.getQualifiedName() == null || !aClass.getQualifiedName().startsWith("java.util."))) return false; if (!com.intellij.psi.util.InheritanceUtil.isInheritor(aClass, CommonClassNames.JAVA_UTIL_COLLECTION) && !com.intellij.psi.util.InheritanceUtil.isInheritor(aClass, CommonClassNames.JAVA_UTIL_MAP)) { return false; } Predicate<PsiType> allowedParameterType = t -> t instanceof PsiPrimitiveType || com.intellij.psi.util.InheritanceUtil.isInheritor(t, CommonClassNames.JAVA_LANG_CLASS); return Stream.of(constructor.getParameterList().getParameters()).map(PsiParameter::getType).allMatch(allowedParameterType); } if (expression instanceof PsiMethodCallExpression call) { if (ENUM_SET_NONE_OF.test(call)) return true; @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 && !method.getParameterList().isEmpty()) { PsiClass aClass = method.getContainingClass(); if (aClass != null) { String qualifiedName = aClass.getQualifiedName(); if (qualifiedName != null && GUAVA_UTILITY_CLASSES.contains(qualifiedName)) { return ContainerUtil.and(method.getParameterList().getParameters(), p -> p.getType() instanceof PsiPrimitiveType); } } } } } return false; }