We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
AstNode.getEnclosingBlock()
1 parent 5204255 commit 8aa1bffCopy full SHA for 8aa1bff
go/ql/lib/semmle/go/AST.qll
@@ -84,6 +84,16 @@ class AstNode extends @node, Locatable {
84
pragma[nomagic]
85
FuncDef getEnclosingFunction() { result = this.getParent().parentInSameFunction*() }
86
87
+ /** Gets the innermost block statement to which this AST node belongs, if any. */
88
+ BlockStmt getEnclosingBlock() {
89
+ exists(AstNode p | p = this.getParent() |
90
+ result = p
91
+ or
92
+ not p instanceof BlockStmt and
93
+ result = p.getEnclosingBlock()
94
+ )
95
+ }
96
+
97
/**
98
* Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs.
99
*/
0 commit comments