File tree Expand file tree Collapse file tree
src/main/java/org/variantsync/diffdetective/diff/difftree Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -335,6 +335,10 @@ public boolean insertAfterChild(final DiffNode child, int index) {
335335
336336 public boolean addBeforeChild (final DiffNode child ) {
337337 if (!child .isAdd ()) {
338+ if (child .beforeParent != null ) {
339+ throw new IllegalArgumentException ("Given child " + child + " already has a before parent (" + child .beforeParent + ")!" );
340+ }
341+
338342 addWithoutDuplicates (beforeChildren , child );
339343 addWithoutDuplicates (childOrder , child );
340344 child .setBeforeParent (this );
@@ -345,6 +349,10 @@ public boolean addBeforeChild(final DiffNode child) {
345349
346350 public boolean addAfterChild (final DiffNode child ) {
347351 if (!child .isRem ()) {
352+ if (child .afterParent != null ) {
353+ throw new IllegalArgumentException ("Given child " + child + " already has an after parent (" + child .afterParent + ")!" );
354+ }
355+
348356 addWithoutDuplicates (afterChildren , child );
349357 addWithoutDuplicates (childOrder , child );
350358 child .setAfterParent (this );
You can’t perform that action at this time.
0 commit comments