boolean (@NotNull PsiMethodCallExpression call, @NotNull PsiExpression expression, PsiType expressionType) { if (!StreamApiUtil.isSupportedStreamElement(expressionType) || !InlineStreamMapAction.Holder.NEXT_METHODS.contains(call.getMethodExpression().getReferenceName()) || call.getMethodExpression().getQualifierExpression() == null) { return false; } PsiMethod method = call.resolveMethod(); if (method == null || method.getParameterList().getParametersCount() != 1 || !InheritanceUtil.isInheritor(method.getContainingClass(), CommonClassNames.JAVA_UTIL_STREAM_BASE_STREAM)) { return false; } if (method.getName().startsWith("flatMap")) { PsiType outType = StreamApiUtil.getStreamElementType(call.getType()); // flatMap from primitive type works only if the stream element type matches if (expressionType instanceof PsiPrimitiveType && !expressionType.equals(outType)) return false; } return true; }