Skip to content

Commit

Permalink
GH-4915 Fixed setting parent in ValueExprTripleRef#replaceChildNode (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
hmottestad authored Feb 20, 2024
2 parents eab3e2c + fa9496b commit c259fdf
Showing 1 changed file with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,9 @@ public class ValueExprTripleRef extends AbstractQueryModelNode implements ValueE

public ValueExprTripleRef(String extName, Var s, Var p, Var o) {
this.exprVarName = extName;
subjectVar = s;
predicateVar = p;
objectVar = o;

subjectVar.setParentNode(this);
predicateVar.setParentNode(this);
objectVar.setParentNode(this);
setSubjectVar(s);
setPredicateVar(p);
setObjectVar(o);
}

public String getExtVarName() {
Expand All @@ -45,6 +41,21 @@ public Var getObjectVar() {
return objectVar;
}

private void setSubjectVar(Var s) {
subjectVar = s;
subjectVar.setParentNode(this);
}

private void setPredicateVar(Var p) {
predicateVar = p;
predicateVar.setParentNode(this);
}

private void setObjectVar(Var o) {
objectVar = o;
objectVar.setParentNode(this);
}

@Override
public <X extends Exception> void visitChildren(QueryModelVisitor<X> visitor) throws X {
if (subjectVar != null) {
Expand Down Expand Up @@ -84,17 +95,16 @@ public ValueExprTripleRef clone() {
@Override
public <X extends Exception> void visit(QueryModelVisitor<X> visitor) throws X {
visitor.meetOther(this);
// visitChildren(visitor);
}

@Override
public void replaceChildNode(QueryModelNode current, QueryModelNode replacement) {
if (subjectVar == current) {
subjectVar = (Var) replacement;
setSubjectVar((Var) replacement);
} else if (predicateVar == current) {
predicateVar = (Var) replacement;
setPredicateVar((Var) replacement);
} else if (objectVar == current) {
objectVar = (Var) replacement;
setObjectVar((Var) replacement);
} else {
super.replaceChildNode(current, replacement);
}
Expand Down

0 comments on commit c259fdf

Please sign in to comment.