Member predicate Impl::AstNode::getEnclosingFunction
Gets the nearest function definition that contains this AST node, if any. This includes functions, methods, (de)initializers, and accessors, but not closures.
For example, in the following code, the AST node for n + 1
has foo
as its
enclosing function (via getEnclosingFunction
), whereas its enclosing callable is
the closure {(n : Int) in n + 1 }
(via getEnclosingCallable
):
func foo() {
var f = { (n : Int) in n + 1 }
}