Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 74243d3 commit ab10c28Copy full SHA for ab10c28
1 file changed
javascript/ql/src/semmle/javascript/PrintAst.qll
@@ -200,7 +200,18 @@ private module PrintJavaScript {
200
* Gets the `i`th child of `element`.
201
* Can be overriden in subclasses to get more specific behavior for `getChild()`.
202
*/
203
- ASTNode getChildNode(int childIndex) { result = element.getChild(childIndex) }
+ ASTNode getChildNode(int childIndex) { result = getLocationSortedChild(element, childIndex) }
204
+ }
205
+
206
+ private ASTNode getLocationSortedChild(ASTNode parent, int i) {
207
+ result =
208
+ rank[i](ASTNode child, int childIndex |
209
+ child = parent.getChild(childIndex)
210
+ |
211
+ child
212
+ order by
213
+ child.getLocation().getStartLine(), child.getLocation().getStartColumn(), childIndex
214
+ )
215
}
216
217
/**
0 commit comments