示例#1
0
  public final int getStartOffsetInParent() {
    if (myParent == null) return -1;
    int offsetInParent = myStartOffsetInParent;
    if (offsetInParent != -1) return offsetInParent;

    synchronized (START_OFFSET_LOCK) {
      TreeElement cur = this;
      offsetInParent = myStartOffsetInParent;
      if (offsetInParent != -1) return offsetInParent;

      ApplicationManager.getApplication().assertReadAccessAllowed();

      while (true) {
        TreeElement prev = cur.getTreePrev();
        if (prev == null) break;
        cur = prev;
        offsetInParent = cur.myStartOffsetInParent;
        if (offsetInParent != -1) break;
      }

      if (offsetInParent == -1) {
        cur.myStartOffsetInParent = offsetInParent = 0;
      }

      while (cur != this) {
        TreeElement next = cur.getTreeNext();
        offsetInParent += cur.getTextLength();
        next.myStartOffsetInParent = offsetInParent;
        cur = next;
      }
      return offsetInParent;
    }
  }
示例#2
0
 protected static void clearRelativeOffsets(TreeElement element) {
   TreeElement cur = element;
   while (cur != null && cur.myStartOffsetInParent != -1) {
     cur.myStartOffsetInParent = -1;
     cur = cur.getTreeNext();
   }
 }
示例#3
0
  @Override
  public Object clone() {
    TreeElement clone = (TreeElement) super.clone();
    synchronized (PsiLock.LOCK) {
      clone.myNextSibling = null;
      clone.myPrevSibling = null;
      clone.myParent = null;
      clone.myStartOffsetInParent = -1;
    }

    return clone;
  }