parseApps method

Stream<MetaAppConfig> parseApps(
  1. Units units
)

Implementation

Stream<MetaAppConfig> parseApps(Units units) async* {
  if (!path.basename(units.parsed.path).contains(RegExp(r'[._]app\.dart$'))) {
    return;
  }

  final resolved = await units.resolved();

  final classVisitor = AppVisitor();
  resolved.libraryElement.accept2(classVisitor);

  if (!classVisitor.hasApp) {
    return;
  }

  for (final entry in classVisitor.entries) {
    final element = entry.element;
    yield MetaAppConfig(
      className: element.displayName,
      importPath: element.library.uri.toString(),
      element: element,
      constructor:
          entry.constructor.name3 ??
          (throw Exception('Constructor name is null')),
      params: entry.params,
      appAnnotation: entry.annotation,
      isSecure: entry.isSecure,
      annotationsFor:
          ({required List<OnMatch> onMatch, NonMatch? onNonMatch}) =>
              getAnnotations(
                element: element,
                onMatch: onMatch,
                onNonMatch: onNonMatch,
              ),
    );
  }
}