Index: lib/file_generator.dart |
diff --git a/lib/file_generator.dart b/lib/file_generator.dart |
index a53c46fd24571ca9ebd7752494bba1b5ff130f63..ed5ab7e90f8a25a278222c38a1b741da7516f796 100644 |
--- a/lib/file_generator.dart |
+++ b/lib/file_generator.dart |
@@ -25,6 +25,8 @@ class FileGenerator extends ProtobufContainer { |
final List<EnumGenerator> enumGenerators = <EnumGenerator>[]; |
final List<MessageGenerator> messageGenerators = <MessageGenerator>[]; |
final List<ExtensionGenerator> extensionGenerators = <ExtensionGenerator>[]; |
+ final List<ClientApiGenerator> clientApiGenerators = <ClientApiGenerator>[]; |
+ final List<ServiceGenerator> serviceGenerators = <ServiceGenerator>[]; |
FileGenerator(this._fileDescriptor, this._parent, this._context) { |
_context.register(this); |
@@ -43,6 +45,10 @@ class FileGenerator extends ProtobufContainer { |
extensionGenerators.add( |
new ExtensionGenerator(extension, this, _context)); |
} |
+ for (ServiceDescriptorProto service in _fileDescriptor.service) { |
+ serviceGenerators.add(new ServiceGenerator(service, this, _context)); |
+ clientApiGenerators.add(new ClientApiGenerator(service, this, _context)); |
+ } |
} |
String get package => _fileDescriptor.package; |
@@ -87,12 +93,17 @@ class FileGenerator extends ProtobufContainer { |
String libraryName = _generateLibraryName(filePath); |
+ // Print header and imports. We only add the dart:async import if there |
+ // are services in the FileDescriptorProto. |
out.println( |
'///\n' |
'// Generated code. Do not modify.\n' |
'///\n' |
- 'library $libraryName;\n' |
- '\n' |
+ 'library $libraryName;\n'); |
+ if (_fileDescriptor.service.isNotEmpty) { |
+ out.println("import 'dart:async'\n;"); |
+ } |
+ out.println( |
"import 'package:fixnum/fixnum.dart';\n" |
"import 'package:protobuf/protobuf.dart';" |
); |
@@ -151,6 +162,13 @@ class FileGenerator extends ProtobufContainer { |
out.println('}'); |
}); |
} |
+ |
+ for (ClientApiGenerator c in clientApiGenerators) { |
+ c.generate(out); |
+ } |
+ for (ServiceGenerator s in serviceGenerators) { |
+ s.generate(out); |
+ } |
} |
bool get needsMapMixinImport { |