add getEnclosingPredicate utility predicate

This commit is contained in:
Erik Krogh Kristensen
2021-05-29 08:25:56 +00:00
committed by GitHub
parent fb50ba407d
commit 5dcc161f2d

View File

@@ -56,6 +56,15 @@ class AstNode extends TAstNode {
* Gets the primary QL class for the ast node.
*/
string getAPrimaryQlClass() { result = "???" }
/**
* Gets the predicate that contains this AST node.
*/
pragma[noinline]
Predicate getEnclosingPredicate() {
not this instanceof Predicate and
toGenerated(result) = toGenerated(this).getParent+()
}
}
/** A toplevel QL program, i.e. a file. */