Context (PsiMethodCallExpression call) { PsiExpressionList argumentList = call.getArgumentList(); if (argumentList.getExpressionCount() != 1) return null; PsiExpression firstArg = argumentList.getExpressions()[0]; PsiMethodCallExpression argument = tryCast(skipParenthesizedExprDown(firstArg), PsiMethodCallExpression.class); if (!COLLECTORS_TO_LIST.matches(argument)) return null; PsiExpressionList arguments = tryCast(PsiUtil.skipParenthesizedExprUp(call.getParent()), PsiExpressionList.class); if (arguments == null) return null; if (arguments.getExpressionCount() != 2) return null; PsiMethodCallExpression maybeJoinCall = tryCast(PsiUtil.skipParenthesizedExprUp(arguments.getParent()), PsiMethodCallExpression.class); if (!STRING_JOIN.matches(maybeJoinCall)) return null; PsiExpression[] argumentExpressions = arguments.getExpressions(); if (skipParenthesizedExprDown(argumentExpressions[1]) != call) return null; PsiExpression delimiter = argumentExpressions[0]; if (delimiter == null) return null; if(!InheritanceUtil.isInheritor(delimiter.getType(), JAVA_LANG_CHAR_SEQUENCE)) return null; PsiMethodCallExpression stream = getQualifierMethodCall(call); if (stream == null) return null; PsiType elementType = StreamApiUtil.getStreamElementType(stream.getType()); if (!InheritanceUtil.isInheritor(elementType, JAVA_LANG_CHAR_SEQUENCE)) return null; return new Context(maybeJoinCall, delimiter, argument); }