build method

String build(
  1. Iterable<DartObject> annotations
)

Implementation

String build(Iterable<DartObject> annotations) {
  final result = StringBuffer();
  for (final annotation in annotations) {
    final classes = annotation.getField('classes');
    if (classes == null || classes.isNull) {
      continue;
    }
    Set<String> imports = {};
    for (final name in classes.toListValue()!) {
      imports.addAll(WrapperVisitor.getImports(
          name.toTypeValue()?.element as InterfaceElement));
    }
    result.writeln(imports.toList().join('\n'));
    result.writeln('');
    for (final name in classes.toListValue()!) {
      final type = name.toTypeValue();
      final classElement = type?.element as InterfaceElement;
      final visitor = WrapperVisitor(classElement);
      result.writeln(visitor.toString());
    }
  }
  return result.toString();
}