Skip to content

Commit df8bc7d

Browse files
committed
refactor: reuse VariationNode.assertConsistency in DiffNode
1 parent 047df57 commit df8bc7d

2 files changed

Lines changed: 8 additions & 16 deletions

File tree

src/main/java/org/variantsync/diffdetective/variation/diff/DiffNode.java

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,9 @@ public static DiffNode<DiffLinesLabel> fromID(int id, String label) {
737737
* @throws AssertionError when an inconsistency is detected.
738738
*/
739739
public void assertConsistency() {
740+
// check that the projections are valid (i.e., node type specific consistency checks)
741+
diffType.forAllTimesOfExistence(time -> this.projection(time).assertConsistency());
742+
740743
// check consistency of children lists and edges
741744
for (final DiffNode<L> c : getAllChildren()) {
742745
Assert.assertTrue(isChild(c), () -> "Child " + c + " of " + this + " is neither a before nor an after child!");
@@ -770,22 +773,6 @@ public void assertConsistency() {
770773
Assert.assertTrue(pb.isNon());
771774
}
772775
}
773-
774-
// Else and Elif nodes have an If or Elif as parent.
775-
if (this.isElse() || this.isElif()) {
776-
Time.forAll(time -> {
777-
if (getParent(time) != null) {
778-
Assert.assertTrue(getParent(time).isIf() || getParent(time).isElif(), time + " parent " + getParent(time) + " of " + this + " is neither IF nor ELIF!");
779-
}
780-
});
781-
}
782-
783-
// Only if and elif nodes have a formula
784-
if (this.isIf() || this.isElif()) {
785-
Assert.assertTrue(this.getFormula() != null, "If or elif without feature mapping!");
786-
} else {
787-
Assert.assertTrue(this.getFormula() == null, "Node with type " + getNodeType() + " has a non null feature mapping");
788-
}
789776
}
790777

791778
/**

src/main/java/org/variantsync/diffdetective/variation/diff/Projection.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,9 @@ public Node getFormula() {
130130
public int getID() {
131131
return getBackingNode().getID();
132132
}
133+
134+
@Override
135+
public String toString() {
136+
return String.format("Projection(%s, %s)", time, getBackingNode());
137+
}
133138
};

0 commit comments

Comments
 (0)