void () { if (!(myReturnStatement.getParent() instanceof PsiCodeBlock)) { myReturnStatement = BlockUtils.expandSingleStatementToBlockStatement(myReturnStatement); } PsiStatement[] newStatements = ContainerUtil.map2Array( myReplacements, PsiStatement.class, text -> myFactory.createStatementFromText(text, null)); if (newStatements.length > 0) { BlockUtils.addBefore(myReturnStatement, newStatements); } PsiCodeBlock block = tryCast(myReturnStatement.getParent(), PsiCodeBlock.class); new CommentTracker().deleteAndRestoreComments(myReturnStatement); PsiElement place = cleanUpEmptyBlocks(block); stripUnnecessaryBlocks(place); }