Beispiel #1
0
  protected final void rawInsertAfterMeWithoutNotifications(TreeElement firstNew) {
    firstNew.rawRemoveUpToWithoutNotifications(null, false);
    final CompositeElement p = getTreeParent();
    final TreeElement treeNext = getTreeNext();
    firstNew.setTreePrev(this);
    setTreeNext(firstNew);
    while (true) {
      final TreeElement n = firstNew.getTreeNext();
      assert n != this : "Attempt to create cycle";
      firstNew.setTreeParent(p);
      if (n == null) break;
      firstNew = n;
    }

    if (treeNext == null) {
      if (p != null) {
        firstNew.setTreeParent(p);
        p.setLastChildNode(firstNew);
      }
    } else {
      firstNew.setTreeNext(treeNext);
      treeNext.setTreePrev(firstNew);
    }
    DebugUtil.checkTreeStructure(this);
  }
 @Override
 final void setLastChildNode(TreeElement child) {
   if (myText() != null) {
     LOG.error("Mutating collapsed chameleon");
   }
   super.setLastChildNode(child);
 }
Beispiel #3
0
  // remove nodes from this[including] to end[excluding] from the parent
  protected final void rawRemoveUpToWithoutNotifications(TreeElement end, boolean invalidate) {
    if (this == end) return;

    final CompositeElement parent = getTreeParent();
    final TreeElement startPrev = getTreePrev();
    final TreeElement endPrev = end != null ? end.getTreePrev() : null;

    assert end == null || end.getTreeParent() == parent : "Trying to remove non-child";

    if (end != null) {
      TreeElement element;
      for (element = this; element != end && element != null; element = element.getTreeNext()) ;
      assert element == end : end + " is not successor of " + this + " in the .getTreeNext() chain";
    }
    if (parent != null) {
      if (this == parent.getFirstChildNode()) {
        parent.setFirstChildNode(end);
      }
      if (end == null) {
        parent.setLastChildNode(startPrev);
      }
    }
    if (startPrev != null) {
      startPrev.setTreeNext(end);
    }
    if (end != null) {
      end.setTreePrev(startPrev);
    }

    setTreePrev(null);
    if (endPrev != null) {
      endPrev.setTreeNext(null);
    }

    if (parent != null) {
      for (TreeElement element = this; element != null; element = element.getTreeNext()) {
        element.setTreeParent(null);
        if (invalidate) {
          element.onInvalidated();
        }
      }
    }

    DebugUtil.checkTreeStructure(parent);
    DebugUtil.checkTreeStructure(this);
  }
Beispiel #4
0
  public void rawRemove() {
    final TreeElement next = getTreeNext();
    final CompositeElement parent = getTreeParent();
    final TreeElement prev = getTreePrev();

    if (prev != null) {
      prev.setTreeNext(next);
    } else if (parent != null) {
      parent.setFirstChildNode(next);
    }

    if (next != null) {
      next.setTreePrev(prev);
    } else if (parent != null) {
      parent.setLastChildNode(prev);
    }

    DebugUtil.checkTreeStructure(parent);
    DebugUtil.checkTreeStructure(prev);
    DebugUtil.checkTreeStructure(next);

    invalidate();
  }