void (@NotNull Project project, PsiElement element) { if (element instanceof PsiMethodCallExpression collectCall) { PsiExpression qualifierExpression = collectCall.getMethodExpression().getQualifierExpression(); if (qualifierExpression == null) return; PsiExpression[] collectArgs = collectCall.getArgumentList().getExpressions(); if (collectArgs.length != 1) return; PsiMethodCallExpression collectorCall = tryCast(skipParenthesizedExprDown(collectArgs[0]), PsiMethodCallExpression.class); if (collectorCall == null) return; PsiExpression[] collectorArgs = collectorCall.getArgumentList().getExpressions(); String result = MessageFormat.format(myStreamSequence, Arrays.stream(collectorArgs).map(PsiExpression::getText).toArray()); PsiElementFactory factory = JavaPsiFacade.getElementFactory(project); PsiMethodCallExpression mock = (PsiMethodCallExpression)factory.createExpressionFromText(result, collectCall); if (mock.getMethodExpression().getQualifierExpression() == null) { ExpressionUtils.bindCallTo(collectCall, Objects.requireNonNull(mock.getMethodExpression().getReferenceName())); collectCall.getArgumentList().replace(mock.getArgumentList()); } else { PsiExpression replacement = factory.createExpressionFromText(qualifierExpression.getText() + "." + result, collectCall); collectCall = (PsiMethodCallExpression)collectCall.replace(replacement); } addBoxingIfNecessary(factory, collectCall); } }