CodeQL library for Swift
codeql/swift-all 6.2.1-dev (changelog, source)
Search

Member predicate Impl::AstNode::getEnclosingCallable

Gets the nearest Callable that contains this AST node, if any. This includes (auto)closures, functions, methods, (de)initializers, and accessors.

For example, in the following code, the AST node for n + 1 has the closure {(n : Int) in n + 1 } as its enclosing callable.

func foo() {
  var f = { (n : Int) in n + 1 }
}
Callable getEnclosingCallable()