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

Unified Diff: lib/protobuf_field.dart

Issue 2086253002: Allow application of external mixins to generated dart protos. (Closed) Base URL: https://github.com/dart-lang/dart-protoc-plugin.git@master
Patch Set: Add dart options for override annotations. These make it possible to annotate generated getters, se… Created 4 years, 5 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/message_generator.dart ('k') | lib/src/dart_options.pb.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/protobuf_field.dart
diff --git a/lib/protobuf_field.dart b/lib/protobuf_field.dart
index 7819dd299162b8f9bb77da51341038dee63c3a57..f7e31590a148db46eb20c0f3f2cb124faf069d1e 100644
--- a/lib/protobuf_field.dart
+++ b/lib/protobuf_field.dart
@@ -55,6 +55,20 @@ class ProtobufField {
bool get isPacked =>
isRepeated && descriptor.options != null && descriptor.options.packed;
+ /// Whether the field has the `overrideGetter` annotation set to true.
+ bool get overridesGetter => _hasBooleanOption(Dart_options.overrideGetter);
+
+ /// Whether the field has the `overrideSetter` annotation set to true.
+ bool get overridesSetter => _hasBooleanOption(Dart_options.overrideSetter);
+
+ /// Whether the field has the `overrideHasMethod` annotation set to true.
+ bool get overridesHasMethod =>
+ _hasBooleanOption(Dart_options.overrideHasMethod);
+
+ /// Whether the field has the `overrideClearMethod` annotation set to true.
+ bool get overridesClearMethod =>
+ _hasBooleanOption(Dart_options.overrideClearMethod);
+
/// True if this field uses the Int64 from the fixnum package.
bool get needsFixnumImport => baseType.unprefixed == "Int64";
@@ -243,6 +257,9 @@ class ProtobufField {
return noDefault;
}
+ bool _hasBooleanOption(Extension extension) =>
+ descriptor?.options?.getExtension(extension) ?? false;
+
get _invalidDefaultValue => "dart-protoc-plugin:"
" invalid default value (${descriptor.defaultValue})"
" found in field $fqname";
« no previous file with comments | « lib/message_generator.dart ('k') | lib/src/dart_options.pb.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698