private int getEndOffsetUpperEstimate() {
    int endOffsetUpperEstimate = EditorUtil.getNotFoldedLineEndOffset(myEditor, myEvent.getMandatoryEndOffset());
    int line = myDocument.getLineNumber(endOffsetUpperEstimate);
    if (line < myDocument.getLineCount() - 1) {
      endOffsetUpperEstimate = myDocument.getLineStartOffset(line + 1);
    }
    return endOffsetUpperEstimate;
  }
private int getEndOffsetUpperEstimate()