ValidationInfo (final PsiMethod method) { final PsiParameter[] parameters = method.getParameterList().getParameters(); final PsiType[] parameterTypes = ContainerUtil.map2Array(Arrays.asList(parameters), new PsiType[parameters.length], parameter -> parameter.getType()); final PsiType returnType = method.getReturnType(); if (StreamApiConstants.FAKE_FIND_MATCHED.equals(myStreamApiMethodName)) { if (!PsiTypes.booleanType().equals(returnType)) { return null; } } else { final PsiClass stream = JavaPsiFacade.getInstance(method.getProject()).findClass(StreamApiConstants.JAVA_UTIL_STREAM_STREAM, method.getResolveScope()); if (stream == null) { return null; } final PsiMethod[] methods = stream.findMethodsByName(myStreamApiMethodName, false); LOG.assertTrue(methods.length != 0); PsiMethod representative = methods[0]; final PsiType expectedReturnType = representative.getReturnType(); if (expectedReturnType instanceof PsiClassType) { final PsiClass resolvedClass = ((PsiClassType)expectedReturnType).resolve(); if (resolvedClass == null) { return null; } else { if (StreamApiConstants.JAVA_UTIL_STREAM_STREAM.equals(resolvedClass.getQualifiedName())) { if (!(returnType instanceof PsiArrayType)) { if (!(returnType instanceof PsiClassType)) { return null; } final PsiClass methodReturnType = ((PsiClassType)returnType).resolve(); if (methodReturnType == null || !InheritanceUtil.isInheritor(methodReturnType, CommonClassNames.JAVA_LANG_ITERABLE)) { return null; } } } } } else if (PsiTypes.booleanType().equals(expectedReturnType)) { if (!PsiTypes.booleanType().equals(returnType)) { return null; } } } return validate(parameterTypes, returnType, null, method); }