boolean (PsiExpression qualifier, PsiExpression iterable, boolean useArraysAsList) { PsiType qualifierType = qualifier.getType(); if (!(qualifierType instanceof PsiClassType)) return false; PsiType type = iterable.getType(); PsiElementFactory factory = JavaPsiFacade.getElementFactory(iterable.getProject()); JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(iterable.getProject()); String text = iterable.getText(); if (type instanceof PsiArrayType) { PsiType componentType = ((PsiArrayType)type).getComponentType(); if (!useArraysAsList || componentType instanceof PsiPrimitiveType) return false; PsiClass listClass = psiFacade.findClass(JAVA_UTIL_LIST, iterable.getResolveScope()); if (listClass == null) return false; if (!listClass.hasTypeParameters()) { // Raw List class - Java 1.4? type = factory.createType(listClass); } else if (listClass.getTypeParameters().length == 1) { type = factory.createType(listClass, componentType); } else { return false; } text = JAVA_UTIL_ARRAYS + ".asList(" + text + ")"; } PsiClass aClass = PsiUtil.resolveClassInType(type); if (aClass == null) return false; String bulkParameterType = getBulkParameterType(); PsiClass commonParent = psiFacade.findClass(bulkParameterType, aClass.getResolveScope()); if (!InheritanceUtil.isInheritorOrSelf(aClass, commonParent, true)) return false; PsiExpression expression = factory.createExpressionFromText(qualifier.getText() + "." + myBulkName + "(" + text + ")", iterable); if (!(expression instanceof PsiMethodCallExpression call)) return false; PsiMethod bulkMethod = call.resolveMethod(); if (bulkMethod == null) return false; PsiParameterList parameters = bulkMethod.getParameterList(); if (parameters.getParametersCount() != 1) return false; PsiType parameterType = Objects.requireNonNull(parameters.getParameter(0)).getType(); parameterType = call.resolveMethodGenerics().getSubstitutor().substitute(parameterType); PsiClass parameterClass = PsiUtil.resolveClassInClassTypeOnly(parameterType); if (parameterClass == null) return false; String qualifiedName = parameterClass.getQualifiedName(); return bulkParameterType.equals(qualifiedName) && parameterType.isAssignableFrom(type); }