void (@NotNull Project project, @NotNull PsiElement startElement, @NotNull ModPsiUpdater updater) { PsiMethodCallExpression callExpression = PsiTreeUtil.getParentOfType(startElement, PsiMethodCallExpression.class); if (callExpression == null) { return; } PsiLambdaExpression psiLambdaExpression = getLambdaSupplier(callExpression); if (psiLambdaExpression == null) return; List<PsiThrowStatement> throwStatements = getThrowStatements(psiLambdaExpression); PsiElement returnStatement = null; for (PsiThrowStatement throwStatement : throwStatements) { CommentTracker tracker = new CommentTracker(); StringBuilder builder = new StringBuilder(); for (PsiElement child : throwStatement.getChildren()) { if (child instanceof PsiKeyword keyword && keyword.getTokenType() == JavaTokenType.THROW_KEYWORD) { builder.append("return"); } else { builder.append(child.getText()); tracker.grabComments(child); } } returnStatement = tracker.replaceAndRestoreComments(throwStatement, builder.toString()); } if (returnStatement == null) { return; } PsiLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(returnStatement, PsiLambdaExpression.class); if (lambdaExpression != null) { final PsiElement body = lambdaExpression.getBody(); if (body != null) { PsiExpression expression = LambdaUtil.extractSingleExpressionFromBody(body); if (expression != null) { body.replace(expression); } } } }