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); }
// remove nodes from this[including] to end[excluding] from the parent public void rawRemoveUpTo(@Nullable TreeElement end) { CompositeElement parent = getTreeParent(); rawRemoveUpToWithoutNotifications(end, true); if (parent != null) { parent.subtreeChanged(); } }