void (@NotNull ActionContext context, @NotNull PsiJavaToken token, @NotNull ModPsiUpdater updater) { final PsiPolyadicExpression expression = SplitConditionUtil.findCondition(token, true, false); final PsiLambdaExpression originalLambdaExpression = PsiTreeUtil.getParentOfType(expression, PsiLambdaExpression.class); LOG.assertTrue(originalLambdaExpression != null); final String lambdaParameterName = originalLambdaExpression.getParameterList().getParameters()[0].getName(); final PsiElement originalLambdaExpressionBody = originalLambdaExpression.getBody(); LOG.assertTrue(originalLambdaExpressionBody != null); final PsiMethodCallExpression methodCallExpression = PsiTreeUtil.getParentOfType(expression, PsiMethodCallExpression.class); LOG.assertTrue(methodCallExpression != null, expression); final PsiExpression qualifierExpression = methodCallExpression.getMethodExpression().getQualifierExpression(); LOG.assertTrue(qualifierExpression != null); final PsiMethodCallExpression newFilterCall = (PsiMethodCallExpression)JavaPsiFacade.getElementFactory(context.project()) .createExpressionFromText("a.filter(" + lambdaParameterName + " -> x)", methodCallExpression); final PsiLambdaExpression newFilterLambda = (PsiLambdaExpression)newFilterCall.getArgumentList().getExpressions()[0]; final PsiExpression filterCallQualifier = newFilterCall.getMethodExpression().getQualifierExpression(); LOG.assertTrue(filterCallQualifier != null); final PsiElement newFilterLambdaBody = newFilterLambda.getBody(); LOG.assertTrue(newFilterLambdaBody != null); final Collection<PsiComment> comments = PsiTreeUtil.getChildrenOfTypeAsList(expression, PsiComment.class); final int separatorOffset = token.getTextOffset(); for (PsiComment comment : comments) { if (comment.getTextOffset() < separatorOffset) { newFilterLambda.getParent().add(comment); } else { originalLambdaExpression.addBefore(comment, originalLambdaExpressionBody); } } PsiExpression rOperands = getROperands(expression, token); PsiExpression lOperands = getLOperands(expression, token); originalLambdaExpressionBody.replace(rOperands); newFilterLambdaBody.replace(lOperands); filterCallQualifier.replace(qualifierExpression); qualifierExpression.replace(newFilterCall); }