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

Side by Side Diff: lib/file_generator.dart

Issue 131943002: Handle protocol buffer messages with no package (Closed) Base URL: https://github.com/dart-lang/dart-protoc-plugin.git@master
Patch Set: Fix bug and updte 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 | « Makefile ('k') | lib/protobuf_field.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 extends 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;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 if (importPath.isAbsolute) { 126 if (importPath.isAbsolute) {
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 && !fileGenerator.package.isEmpty) {
137 out.print(' as ${fileGenerator.packageImportPrefix}'); 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 }
(...skipping 39 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 | « Makefile ('k') | lib/protobuf_field.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698