generateServerFile method
Returns the contents of the .pbserver.dart file for this .proto file.
Implementation
String generateServerFile(
[OutputConfiguration config = const DefaultOutputConfiguration()]) {
if (!_linked) throw StateError('not linked');
final out = makeWriter();
_writeHeading(out,
extraIgnores: {'deprecated_member_use_from_same_package'});
final importWriter = ImportWriter();
if (serviceGenerators.isNotEmpty) {
importWriter.addImport(_asyncImportUrl, prefix: asyncImportPrefix);
importWriter.addImport(_coreImportUrl, prefix: coreImportPrefix);
importWriter.addImport(_protobufImportUrl, prefix: protobufImportPrefix);
}
// Import .pb.dart files needed for requests and responses.
final imports = <FileGenerator>{};
for (final x in serviceGenerators) {
x.addImportsTo(imports);
}
for (final target in imports) {
_addImport(importWriter, config, target, '.pb.dart');
}
// Import .pbjson.dart file needed for $json and $messageJson.
if (serviceGenerators.isNotEmpty) {
_addImport(importWriter, config, this, '.pbjson.dart');
}
final url = config.resolveImport(protoFileUri, protoFileUri, '.pb.dart');
importWriter.addExport(url.toString());
if (importWriter.hasImports) {
out.println(importWriter.emit());
}
for (final s in serviceGenerators) {
s.generate(out);
}
return out.toString();
}