Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(490)

Side by Side Diff: lib/file_generator.dart

Issue 128003003: Fix issue with importing packages where the package name included a dot (Closed) Base URL: https://github.com/dart-lang/dart-protoc-plugin.git@master
Patch Set: Update pubspec version Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/extension_generator.dart ('k') | lib/message_generator.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 class FileGenerator implements ProtobufContainer { 7 class FileGenerator extends ProtobufContainer {
8 final FileDescriptorProto _fileDescriptor; 8 final FileDescriptorProto _fileDescriptor;
9 final ProtobufContainer _parent; 9 final ProtobufContainer _parent;
10 final GenerationContext _context; 10 final GenerationContext _context;
11 11
12 final List<EnumGenerator> enumGenerators = <EnumGenerator>[]; 12 final List<EnumGenerator> enumGenerators = <EnumGenerator>[];
13 final List<MessageGenerator> messageGenerators = <MessageGenerator>[]; 13 final List<MessageGenerator> messageGenerators = <MessageGenerator>[];
14 final List<ExtensionGenerator> extensionGenerators = <ExtensionGenerator>[]; 14 final List<ExtensionGenerator> extensionGenerators = <ExtensionGenerator>[];
15 15
16 FileGenerator(this._fileDescriptor, this._parent, this._context) { 16 FileGenerator(this._fileDescriptor, this._parent, this._context) {
17 _context.register(this); 17 _context.register(this);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 // protoc should never generate an import with an absolute path. 127 // protoc should never generate an import with an absolute path.
128 throw("FAILURE: Import with absolute path is not supported"); 128 throw("FAILURE: Import with absolute path is not supported");
129 } 129 }
130 // Create a relative path from the current file to the import. 130 // Create a relative path from the current file to the import.
131 Uri relativeProtoPath = _relative(importPath, filePath); 131 Uri relativeProtoPath = _relative(importPath, filePath);
132 // Find the file generator for this import as it contains the 132 // Find the file generator for this import as it contains the
133 // package name. 133 // package name.
134 FileGenerator fileGenerator = _context.lookupFile(import); 134 FileGenerator fileGenerator = _context.lookupFile(import);
135 out.print("import '${_generatedFilePath(relativeProtoPath)}'"); 135 out.print("import '${_generatedFilePath(relativeProtoPath)}'");
136 if (package != fileGenerator.package) { 136 if (package != fileGenerator.package) {
137 out.print(' as ${fileGenerator.package}'); 137 out.print(' as ${fileGenerator.packageImportPrefix}');
138 } 138 }
139 out.println(';'); 139 out.println(';');
140 } 140 }
141 out.println(''); 141 out.println('');
142 142
143 // Initialize Field. 143 // Initialize Field.
144 for (MessageGenerator m in messageGenerators) { 144 for (MessageGenerator m in messageGenerators) {
145 m.initializeFields(); 145 m.initializeFields();
146 } 146 }
147 147
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 _registry[container.fqname] = container; 186 _registry[container.fqname] = container;
187 if (container is FileGenerator) { 187 if (container is FileGenerator) {
188 _files[container._fileDescriptor.name] = container; 188 _files[container._fileDescriptor.name] = container;
189 } 189 }
190 } 190 }
191 191
192 ProtobufContainer operator [](String fqname) => _registry[fqname]; 192 ProtobufContainer operator [](String fqname) => _registry[fqname];
193 193
194 FileGenerator lookupFile(String name) => _files[name]; 194 FileGenerator lookupFile(String name) => _files[name];
195 } 195 }
OLDNEW
« no previous file with comments | « lib/extension_generator.dart ('k') | lib/message_generator.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698