Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions go/ql/lib/semmle/go/AST.qll
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
Loading