visitProvideExisting method

  1. @override
void visitProvideExisting(
  1. int index,
  2. TokenElement token,
  3. Expression tokenExpression,
  4. Reference type,
  5. Expression redirect,
  6. bool isMulti,
)
override

Implement redirecting to redirect when token is requested.

Implementation

@override
void visitProvideExisting(
  int index,
  TokenElement token,
  Expression tokenExpression,
  Reference type,
  Expression redirect,
  bool isMulti,
) {
  final methodName = '_getExisting\$$index';
  _methodCache.add(Method((b) => b
    ..name = methodName
    ..returns = type
    ..body = refer('this.get').call([redirect]).code));

  if (isMulti) {
    _addToMulti(token, tokenExpression, methodName);
  } else {
    _addToBody(tokenExpression, methodName);
  }
}