void (@NotNull PsiComment comment) { if (!myRange.contains(comment.getTextRange())) { return; } final String origText = comment.getText(); final int commentStart = origText.indexOf('#'); if (commentStart != -1 && (commentStart + 1) < origText.length()) { final char charAfterDash = origText.charAt(commentStart + 1); if (charAfterDash == '!' && comment.getTextRange().getStartOffset() == 0) { return; // shebang } if (charAfterDash == '#' || charAfterDash == ':') { return; // doc comment } final String commentTextWithoutDash = origText.substring(commentStart + 1); final String newText; if (isTrailingComment(comment)) { newText = "# " + StringUtil.trimLeading(commentTextWithoutDash); } else if (!StringUtil.isWhiteSpace(charAfterDash)) { newText = "# " + commentTextWithoutDash; } else { return; } if (!newText.equals(origText)) { myDelta += newText.length() - origText.length(); final PyElementGenerator elementGenerator = PyElementGenerator.getInstance(myProject); final PsiComment newComment = elementGenerator.createFromText(LanguageLevel.forElement(comment), PsiComment.class, newText); myCommentReplacements.add(Couple.of(comment, newComment)); } } }