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

Unified Diff: lib/enum_generator.dart

Issue 93743006: Use package names as import prefixes when generating code (Closed) Base URL: https://github.com/dart-lang/dart-protoc-plugin.git@master
Patch Set: Addressed review commetns Created 6 years, 12 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/code_generator.dart ('k') | lib/extension_generator.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/enum_generator.dart
diff --git a/lib/enum_generator.dart b/lib/enum_generator.dart
index b09d9b7182a3ec1fc8b702ebc9b6ce33ed2e117b..1f451f1eaeccb807438609aa1dad7f784ae534e1 100644
--- a/lib/enum_generator.dart
+++ b/lib/enum_generator.dart
@@ -11,6 +11,7 @@ class EnumAlias {
}
class EnumGenerator implements ProtobufContainer {
+ final ProtobufContainer _parent;
final String classname;
final String fqname;
final List<EnumValueDescriptorProto> _canonicalValues =
@@ -21,7 +22,8 @@ class EnumGenerator implements ProtobufContainer {
EnumDescriptorProto descriptor,
ProtobufContainer parent,
GenerationContext context)
- : classname = (parent == null || parent is FileGenerator) ?
+ : _parent = parent,
+ classname = (parent == null || parent is FileGenerator) ?
descriptor.name : '${parent.classname}_${descriptor.name}',
fqname = (parent == null || parent.fqname == null) ? descriptor.name :
(parent.fqname == '.' ?
@@ -38,6 +40,8 @@ class EnumGenerator implements ProtobufContainer {
context.register(this);
}
+ String get package => _parent.package;
+
void generate(IndentingWriter out) {
out.addBlock('class ${classname} extends ProtobufEnum {', '}\n', () {
// -----------------------------------------------------------------
« no previous file with comments | « lib/code_generator.dart ('k') | lib/extension_generator.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698