void (PsiCodeBlock codeBlock, PsiExpressionStatement statement) { PsiExpressionStatement wrappedStatement = (PsiExpressionStatement)codeBlock.add(statement); CommentTracker tracker = new CommentTracker(); tracker.markUnchanged(wrappedStatement.getExpression()); PsiElementFactory factory = JavaPsiFacade.getElementFactory(codeBlock.getProject()); PsiYieldStatement yieldStatement = (PsiYieldStatement)factory.createStatementFromText("yield 0;", statement); yieldStatement = (PsiYieldStatement)tracker.replaceAndRestoreComments(wrappedStatement, yieldStatement); PsiExpression yieldExpression = yieldStatement.getExpression(); assert yieldExpression != null : DebugUtil.psiToString(yieldStatement, true); yieldExpression.replace(statement.getExpression()); }