Ruby printAst: fix order for synth children of real parents

Real parents can have synthesized children, so always assigning index 0 leads to nondeterminism in graph output.
This commit is contained in:
Nora Dimitrijević
2025-05-01 11:26:42 -04:00
parent aa80b83874
commit 2511f52161
2 changed files with 19 additions and 17 deletions

View File

@@ -121,15 +121,17 @@ class PrintRegularAstNode extends PrintAstNode, TPrintRegularAstNode {
}
private int getSynthAstNodeIndex() {
this.parentIsSynthesized() and
exists(AstNode parent |
shouldPrintAstEdge(parent, _, astNode) and
parent.isSynthesized() and
synthChild(parent, result, astNode)
)
or
not this.parentIsSynthesized() and
result = 0
if
exists(AstNode parent |
shouldPrintAstEdge(parent, _, astNode) and
synthChild(parent, _, astNode)
)
then
exists(AstNode parent |
shouldPrintAstEdge(parent, _, astNode) and
synthChild(parent, result, astNode)
)
else result = 0
}
override int getOrder() {