enclosingFunction property

FunctionNode? get enclosingFunction

Returns the FunctionNode enclosing this node, possibly the node itself, or null if not enclosed in any function.

Implementation

FunctionNode? get enclosingFunction {
  Node? node = this;
  while (node != null) {
    if (node is FunctionNode) return node;
    node = node.parent;
  }
  return null;
}