mirror of
https://github.com/github/codeql.git
synced 2026-02-20 00:43:44 +01:00
AST: add getChild/getParent method
This commit is contained in:
@@ -36,4 +36,10 @@ class AstNode extends @ast_node {
|
||||
|
||||
/** Gets the location of this node. */
|
||||
final Location getLocation() { result = range.getLocation() }
|
||||
|
||||
/** Gets a child node of this `AstNode`. */
|
||||
final AstNode getAChild() { range.child(_, result) }
|
||||
|
||||
/** Gets the parent of this `AstNode`, if this node is not a root node. */
|
||||
final AstNode getParent() { result.getAChild() = this }
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ module AstNode {
|
||||
abstract string toString();
|
||||
|
||||
Location getLocation() { result = generated.getLocation() }
|
||||
|
||||
predicate child(string label, AstNode::Range child) { none() }
|
||||
}
|
||||
|
||||
// TODO: Remove
|
||||
|
||||
Reference in New Issue
Block a user