TypeConversionDescriptor (PsiMethod method, PsiExpression context) { LOG.assertTrue("append".equals(method.getName())); final PsiParameterList list = method.getParameterList(); if (list.getParametersCount() != 1) return null; final PsiType parameterType = list.getParameters()[0].getType(); if (parameterType instanceof PsiEllipsisType) { return new TypeConversionDescriptor("$q$.append('_params*)", "java.util.stream.Stream.concat($q$, java.util.Arrays.asList($params$).stream())"); } else if (parameterType instanceof PsiClassType) { final PsiClass psiClass = PsiTypesUtil.getPsiClass(parameterType); if (psiClass != null && CommonClassNames.JAVA_LANG_ITERABLE.equals(psiClass.getQualifiedName())) { PsiMethodCallExpression methodCall = (PsiMethodCallExpression)(context instanceof PsiMethodCallExpression ? context : context.getParent()); final PsiExpression expression = methodCall.getArgumentList().getExpressions()[0]; boolean isCollection = InheritanceUtil.isInheritor(PsiTypesUtil.getPsiClass(expression.getType()), CommonClassNames.JAVA_UTIL_COLLECTION); final String argTemplate = isCollection ? "$arg$.stream()" : "java.util.stream.StreamSupport.stream($arg$.spliterator(), false)"; return new TypeConversionDescriptor("$q$.append($arg$)", "java.util.stream.Stream.concat($q$," + argTemplate + ")"); } } return null; }