mirror of
https://github.com/github/codeql.git
synced 2026-02-11 20:51:06 +01:00
Merge pull request #21254 from owen-mc/go/astnode-get-enclosing-block
Go: Add `AstNode.getEnclosingBlock()`
This commit is contained in:
@@ -84,6 +84,16 @@ class AstNode extends @node, Locatable {
|
||||
pragma[nomagic]
|
||||
FuncDef getEnclosingFunction() { result = this.getParent().parentInSameFunction*() }
|
||||
|
||||
/** Gets the innermost block statement to which this AST node belongs, if any. */
|
||||
BlockStmt getEnclosingBlock() {
|
||||
exists(AstNode p | p = this.getParent() |
|
||||
result = p
|
||||
or
|
||||
not p instanceof BlockStmt and
|
||||
result = p.getEnclosingBlock()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user