visitProvideValue method

  1. @override
void visitProvideValue(
  1. int index,
  2. TokenElement? token,
  3. Expression tokenExpression,
  4. Reference returnType,
  5. Expression value,
  6. bool isMulti,
)
override

Implement providing value when token is requested.

Implementation

@override
void visitProvideValue(
  int index,
  TokenElement? token,
  Expression tokenExpression,
  Reference returnType,
  Expression value,
  bool isMulti,
) {
  final methodName = '_get${returnType.symbol}\$$index';
  _methodCache.add(
    Method(
      (b) => b
        ..name = methodName
        ..returns = returnType
        ..body = value.code,
    ),
  );

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