OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of protoc; | 5 part of protoc; |
6 | 6 |
7 abstract class ProtobufContainer { | 7 abstract class ProtobufContainer { |
8 String get package; | 8 String get package; |
9 String get classname; | 9 String get classname; |
10 String get fqname; | 10 String get fqname; |
| 11 String get packageImportPrefix => package.replaceAll('.', r'$'); |
11 } | 12 } |
12 | 13 |
13 class CodeGenerator implements ProtobufContainer { | 14 class CodeGenerator extends ProtobufContainer { |
14 final Stream<List<int>> _streamIn; | 15 final Stream<List<int>> _streamIn; |
15 final IOSink _streamOut; | 16 final IOSink _streamOut; |
16 final IOSink _streamErr; | 17 final IOSink _streamErr; |
17 | 18 |
18 CodeGenerator(this._streamIn, this._streamOut, this._streamErr); | 19 CodeGenerator(this._streamIn, this._streamOut, this._streamErr); |
19 | 20 |
20 void generate() { | 21 void generate() { |
21 _streamIn | 22 _streamIn |
22 .fold(new BytesBuilder(), (builder, data) => builder..add(data)) | 23 .fold(new BytesBuilder(), (builder, data) => builder..add(data)) |
23 .then((builder) => builder.takeBytes()) | 24 .then((builder) => builder.takeBytes()) |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 if (errors.length > 0) { | 101 if (errors.length > 0) { |
101 response.error = errors.join('\n'); | 102 response.error = errors.join('\n'); |
102 return null; | 103 return null; |
103 } else { | 104 } else { |
104 return new GenerationOptions._(fieldNameOptions); | 105 return new GenerationOptions._(fieldNameOptions); |
105 } | 106 } |
106 } | 107 } |
107 | 108 |
108 String fieldNameOption(String fqname) => fieldNameOptions[fqname]; | 109 String fieldNameOption(String fqname) => fieldNameOptions[fqname]; |
109 } | 110 } |
OLD | NEW |