ImmutableCollectionModel (@NotNull PsiMethodCallExpression call) { CollectionType type = CollectionType.create(call); if (type == null) return null; if (!CodeBlockSurrounder.canSurround(call)) return null; String assignedVariable = getAssignedVariable(call); PsiMethod method = call.resolveMethod(); if (method == null) return null; PsiClassType classType = ObjectUtils.tryCast(call.getType(), PsiClassType.class); if (classType == null) return null; PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(call.getProject()).getResolveHelper(); boolean hasNonResolvedTypeParams = Arrays.stream(classType.getParameters()) .map(PsiUtil::resolveClassInClassTypeOnly) .anyMatch(aClass -> isNonResolvedTypeParameter(aClass, call, resolveHelper)); if (hasNonResolvedTypeParams) return null; PsiExpression[] args = call.getArgumentList().getExpressions(); if ("ofEntries".equals(method.getName()) && ContainerUtil.exists(args, arg -> extractPutArgs(arg) == null)) return null; return new ImmutableCollectionModel(call, type, method, assignedVariable); }