addImportsTo method

void addImportsTo(
  1. Set<FileGenerator> imports,
  2. Set<FileGenerator> enumImports
)

Adds dependencies of generate to imports.

For each .pb.dart file that the generated code needs to import, add its generator.

Implementation

void addImportsTo(
    Set<FileGenerator> imports, Set<FileGenerator> enumImports) {
  checkResolved();
  for (final field in _fieldList) {
    final typeGen = field.baseType.generator;
    if (typeGen is EnumGenerator) {
      enumImports.add(typeGen.fileGen!);
    } else if (typeGen != null) {
      imports.add(typeGen.fileGen!);
    }
  }
  for (final m in _messageGenerators) {
    m.addImportsTo(imports, enumImports);
  }
  for (final x in _extensionGenerators) {
    x.addImportsTo(imports, enumImports);
  }
}