Chromium Code Reviews| Index: lib/file_generator.dart |
| diff --git a/lib/file_generator.dart b/lib/file_generator.dart |
| index 7cd92cddf0d69c71c2b0c917540c012a918e91f6..4a8fe0d8be1a6e3daccb988a0d1dd9b16cf1b416 100644 |
| --- a/lib/file_generator.dart |
| +++ b/lib/file_generator.dart |
| @@ -28,6 +28,7 @@ class FileGenerator implements ProtobufContainer { |
| } |
| } |
| + String get package => _fileDescriptor.package; |
| String get classname => ''; |
| String get fqname => '.${_fileDescriptor.package}'; |
| @@ -128,7 +129,14 @@ class FileGenerator implements ProtobufContainer { |
| } |
| // Create a relative path from the current file to the import. |
| Uri relativeProtoPath = _relative(importPath, filePath); |
| - out.println("import '${_generatedFilePath(relativeProtoPath)}';"); |
| + // Find the file generator for this import as it contains the |
| + // package name. |
| + FileGenerator fileGenerator = _context.lookupFile(import); |
| + out.println("import '${_generatedFilePath(relativeProtoPath)}'"); |
|
Siggi Cherem (dart-lang)
2013/12/20 18:27:36
remove new line
Søren Gjesse
2014/01/02 08:52:33
Done.
|
| + if (package != fileGenerator.package) { |
| + out.println(' as ${fileGenerator.package}'); |
|
Siggi Cherem (dart-lang)
2013/12/20 18:27:36
and here? (println -> print)?
Søren Gjesse
2014/01/02 08:52:33
Done.
|
| + } |
| + out.println(';'); |
| } |
| out.println(''); |
| @@ -169,12 +177,19 @@ class GenerationContext { |
| final GenerationOptions options; |
| final Map<String, ProtobufContainer> _registry = |
| <String, ProtobufContainer>{}; |
| + final Map<String, FileGenerator> _files = |
| + <String, FileGenerator>{}; |
| GenerationContext(this.options); |
| void register(ProtobufContainer container) { |
| _registry[container.fqname] = container; |
| + if (container is FileGenerator) { |
| + _files[container._fileDescriptor.name] = container; |
| + } |
| } |
| ProtobufContainer operator [](String fqname) => _registry[fqname]; |
| + |
| + FileGenerator lookupFile(String name) => _files[name]; |
| } |