public int getLineNumberBeforeUpdate(int offsetBeforeUpdate) {
    createOldFragmentLineSetIfNeeded();
    Document document = getDocument();
    if (offsetBeforeUpdate <= myOldFragmentLineSetStart) {
      return document.getLineNumber(offsetBeforeUpdate);
    }
    int oldFragmentLineSetEnd = myOldFragmentLineSetStart + myOldFragmentLineSet.getLength();
    if (offsetBeforeUpdate <= oldFragmentLineSetEnd) {
      return document.getLineNumber(myOldFragmentLineSetStart) +
             myOldFragmentLineSet.findLineIndex(offsetBeforeUpdate - myOldFragmentLineSetStart);
    }
    int shift = getNewLength() - getOldLength();
    return document.getLineNumber(myOldFragmentLineSetStart) +
           (myOldFragmentLineSetStart == oldFragmentLineSetEnd ? 0 : myOldFragmentLineSet.getLineCount() - 1) +
           document.getLineNumber(offsetBeforeUpdate + shift) - document.getLineNumber(oldFragmentLineSetEnd + shift);
  }
public int getLineNumberBeforeUpdate(int offsetBeforeUpdate)