File tree Expand file tree Collapse file tree
src/main/java/org/variantsync/diffdetective/variation/diff Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -373,9 +373,12 @@ public DiffNode<L> split(Time time) {
373373 other .addChildren (this .removeChildren (time ), time );
374374 getParent (time ).replaceChild (this , other , time );
375375
376- // FIXME? If we allowed access to the backing node,
377- // we could preserve the identity of this projection by moving it to `other`.
378- this .projections [time .ordinal ()] = null ;
376+ // Preserve the projection by changing its `backingNode` to `other`.
377+ if (this .projections [time .ordinal ()] != null ) {
378+ other .projections [time .ordinal ()] = this .projections [time .ordinal ()];
379+ this .projections [time .ordinal ()] = null ;
380+ other .projections [time .ordinal ()].backingNode = other ;
381+ }
379382
380383 return other ;
381384 }
Original file line number Diff line number Diff line change 2121 * @see DiffNode#projection
2222 */
2323public class Projection <L extends Label > extends VariationNode <Projection <L >, L > {
24- private DiffNode <L > backingNode ;
24+ /**
25+ * The {@link DiffNode} which is projected at {@link time}.
26+ * Invariant: {@code backingNode.projection(time) == this}
27+ * <p>
28+ * Note that this field is package private because {@link DiffNode} needs to change it,
29+ * for example in {@link DiffNode#split},
30+ * to preserve the identity of this instance and prevent it from becoming invalid.
31+ * Only {@link DiffNode} is intended to have access to this field.
32+ */
33+ DiffNode <L > backingNode ;
2534 private Time time ;
2635
2736 /**
You can’t perform that action at this time.
0 commit comments