void (@NotNull Project project, @NotNull PsiMethodCallExpression call, @NotNull Context context) { PsiExpression receiver = context.myOrElseCall.getMethodExpression().getQualifierExpression(); if (receiver == null) return; String methodWithArg = context.myIsSimple ? ".orElse(" + context.myDefaultExpression.getText() + ")" : ".orElseGet(()->" + context.myDefaultExpression.getText() + ")"; String expressionText; expressionText = receiver.getText() + methodWithArg; PsiStatement finalStatement = JavaPsiFacade.getElementFactory(project).createStatementFromText("return " + expressionText + ";", receiver); PsiStatement current = PsiTreeUtil.getParentOfType(context.myOrElseCall, PsiStatement.class, false); if (current == null) return; PsiElement result = new CommentTracker().replaceAndRestoreComments(current, finalStatement); new CommentTracker().deleteAndRestoreComments(context.myNextStatement); LambdaCanBeMethodReferenceInspection.replaceAllLambdasWithMethodReferences(result); }