ownQueueCall function

MethodInvocation? ownQueueCall(
  1. Expression waited
)

The call of the enclosing controller's own queue that waited waits for: method(...).value and method(...).done for a method that returns a SoloJob, and close() and cancelAll().

Implementation

MethodInvocation? ownQueueCall(Expression waited) {
  MethodInvocation? call;
  var jobOf = false;
  if (waited is PropertyAccess &&
      const {'value', 'done'}.contains(waited.propertyName.name)) {
    final target = waited.realTarget.unParenthesized;
    if (target is MethodInvocation) call = target;
    jobOf = true;
  } else if (waited is MethodInvocation &&
      const {'close', 'cancelAll'}.contains(waited.methodName.name)) {
    call = waited;
  }
  if (call == null) return null;
  final target = call.realTarget;
  if (target != null && target is! ThisExpression) return null;
  final method = call.methodName.element;
  if (method is! MethodElement) return null;
  final owner = method.enclosingElement;
  if (owner is! InterfaceElement || !isSolo(owner.thisType)) return null;
  // Both close and cancelAll are members of Solo, so a method of the
  // controller by either name is Solo's or overrides it.
  if (jobOf && !_returnsSoloJob(call, method)) return null;
  return call;
}