PsiElement (PsiMethodCallExpression call) { PsiExpression delimiter = extractDelimiter(call); if (delimiter == null) return null; PsiMethodCallExpression qualifier = getQualifierMethodCall(call); if (qualifier == null) return null; CommentTracker ct = new CommentTracker(); String argList; if (ARRAYS_STREAM.matches(qualifier)) { PsiElement[] args = qualifier.getArgumentList().getChildren(); argList = StreamEx.of(args, 1, args.length - 1).map(ct::text).joining(); } else if (COLLECTION_STREAM.matches(qualifier)) { PsiExpression collection = ExpressionUtils.getEffectiveQualifier(qualifier.getMethodExpression()); if (collection == null) return null; argList = ct.text(collection); } else { return null; } String delimiterText = ct.text(delimiter); if (delimiterText.isEmpty()) { delimiterText = "\"\""; } return ct.replaceAndRestoreComments(call, JAVA_LANG_STRING + ".join(" + delimiterText + "," + argList + ")"); }