void (PsiCodeBlock codeBlock, PsiBlockStatement statement) { // could just replace one code block with the other, but then we lose some comments and formatting PsiBlockStatement tempStatement = (PsiBlockStatement)codeBlock.add(statement); PsiCodeBlock tempBlock = tempStatement.getCodeBlock(); PsiJavaToken lBrace = tempBlock.getLBrace(); PsiJavaToken rBrace = tempBlock.getRBrace(); if (lBrace != null && rBrace != null) { CommentTracker tracker = new CommentTracker(); for (PsiElement element = lBrace.getNextSibling(); element != null && element != rBrace; element = element.getNextSibling()) { tracker.markUnchanged(element); codeBlock.addBefore(element, tempStatement); } tracker.deleteAndRestoreComments(tempStatement); } }