void (int lineCount) { List<PsiComment> endComments = new ArrayList<>(); CharSequence text = myDoc.getCharsSequence(); for (int i = 0; i < lineCount; i++) { myIndicator.checkCanceled(); myIndicator.setFraction(0.05 * i / lineCount); int line = myLine + i; int lineEnd = myDoc.getLineEndOffset(line); int lastNonSpaceOffset = StringUtil.skipWhitespaceBackward(text, lineEnd); if (lastNonSpaceOffset > myDoc.getLineStartOffset(line)) { PsiComment comment = getCommentElement(myFile.findElementAt(lastNonSpaceOffset - 1)); if (comment != null) { int nextStart = CharArrayUtil.shiftForward(text, myDoc.getLineStartOffset(line + 1), " \t\n"); if (nextStart < text.length() && myDoc.getLineNumber(nextStart) <= myLine + lineCount && !isLineComment(getCommentElement(myFile.findElementAt(nextStart)))) { endComments.add(comment); } } } } boolean changed = false; for (int i = 0; i < endComments.size(); i++) { myIndicator.checkCanceled(); myIndicator.setFraction(0.05 + 0.05 * i / endComments.size()); PsiComment comment = endComments.get(i); changed |= tryConvertEndOfLineComment(comment); } if (changed) { myManager.doPostponedOperationsAndUnblockDocument(myDoc); } }