void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { if (!(element instanceof PsiComment comment)) { return; } if (comment.getTokenType() == JavaTokenType.END_OF_LINE_COMMENT) { final List<TextRange> ranges = new ArrayList<>(); ranges.add(comment.getTextRange()); PsiElement sibling = PsiTreeUtil.skipWhitespacesForward(comment); while (sibling instanceof PsiComment && ((PsiComment)sibling).getTokenType() == JavaTokenType.END_OF_LINE_COMMENT) { ranges.add(sibling.getTextRange()); sibling = PsiTreeUtil.skipWhitespacesForward(sibling); } final PsiFile file = element.getContainingFile(); final Document document = file.getViewProvider().getDocument(); assert document != null; Collections.reverse(ranges); ranges.forEach(r -> document.deleteString(r.getStartOffset(), r.getStartOffset() + 2)); } else { final TextRange range = element.getTextRange(); final PsiFile file = element.getContainingFile(); final Document document = file.getViewProvider().getDocument(); assert document != null; final int start = range.getStartOffset(); final int end = range.getEndOffset(); document.deleteString(end - 2, end); document.deleteString(start, start + 2); } }