void (@NotNull ActionContext context, @NotNull PsiReturnStatement returnStatement, @NotNull ModPsiUpdater updater) { PsiExpression returnValue = returnStatement.getReturnValue(); if (returnValue == null) { return; } TextRange range = returnStatement.getFirstChild().getTextRange(); // Work on document level to preserve formatting Document document = returnStatement.getContainingFile().getViewProvider().getDocument(); document.replaceString(range.getStartOffset(), range.getEndOffset(), PsiKeyword.YIELD); }