parseDependenciesList method

DependencyInvocation<ExecutableElement> parseDependenciesList(
  1. ExecutableElement element,
  2. List<DartObject> dependencies
)

Returns parsed dependencies for the provided element.

Instead of looking at the parameters, dependencies is used.

Implementation

DependencyInvocation<ExecutableElement> parseDependenciesList(
  ExecutableElement element,
  List<DartObject> dependencies,
) {
  final positional = <DependencyElement>[];
  for (final object in dependencies) {
    var tokenObject = object;
    final reader = ConstantReader(object);
    var metadata = const <DartObject>[];
    if (reader.isList) {
      tokenObject = reader.listValue.first;
      metadata = reader.listValue.sublist(1);
    }
    bool hasMeta(TypeChecker checker) =>
        metadata.any((m) => checker.isExactlyType(m.type!));
    final isOptional = hasMeta($Optional);
    positional.add(
      DependencyElement(
        _tokenReader.parseTokenObject(tokenObject),
        host: hasMeta($Host),
        optional: isOptional,
        self: hasMeta($Self),
        skipSelf: hasMeta($SkipSelf),
      ),
    );
  }
  return DependencyInvocation(element, positional);
}