jobContextOf function
FormalParameterElement?
jobContextOf(
- FunctionExpression node
The context of node when it is a job body: its first parameter, if that
is typed JobContext or a subtype.
Implementation
FormalParameterElement? jobContextOf(FunctionExpression node) {
final parameters = node.parameters?.parameters;
if (parameters == null || parameters.isEmpty) return null;
// A wildcard names no context: nothing in the body can call on it.
if (parameters.first.name?.lexeme == '_') return null;
final element = parameters.first.declaredFragment?.element;
return isJobContext(element?.type) ? element : null;
}