void (@NotNull PsiElement element, @NotNull ActionContext context, @NotNull ModPsiUpdater updater) { final PsiComment comment = (PsiComment)element; final PsiWhiteSpace whitespace; while (true) { final PsiElement prevLeaf = PsiTreeUtil.prevLeaf(element); if (prevLeaf == null || prevLeaf instanceof PsiWhiteSpace && prevLeaf.getText().indexOf('\n') >= 0) { whitespace = (PsiWhiteSpace)prevLeaf; break; } element = prevLeaf; } final PsiElement anchor = element; final Document document = comment.getContainingFile().getViewProvider().getDocument(); final String newline; if (whitespace == null) { newline = "\n"; } else { final String text = whitespace.getText(); newline = text.substring(text.lastIndexOf('\n')); } final PsiElement prev = PsiTreeUtil.prevLeaf(comment); final TextRange commentRange = comment.getTextRange(); final int deleteOffset = prev instanceof PsiWhiteSpace ? prev.getTextRange().getStartOffset() : commentRange.getStartOffset(); document.deleteString(deleteOffset, commentRange.getEndOffset()); final int offset = anchor.getTextRange().getStartOffset(); document.insertString(offset, newline); document.insertString(offset, comment.getText()); updater.moveTo(offset); }