functionOf function
FunctionExpression?
functionOf(
- Expression argument
The function argument stands for: a literal, the declaration of the
local function it names or the literal a final local variable it names
holds; null for anything else.
Implementation
FunctionExpression? functionOf(Expression argument) {
final node = argument.unParenthesized;
if (node is FunctionExpression) return node;
if (node is! SimpleIdentifier) return null;
final element = node.element;
final named =
element is LocalFunctionElement ||
(element is LocalVariableElement && element.isFinal);
if (!named) return null;
final finder = _FunctionFinder(element!);
node.root.accept(finder);
return finder.found;
}