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

Unified Diff: lib/message_generator.dart

Issue 210843002: Include the Dart reserved words in the reserved names handling (Closed) Base URL: https://github.com/dart-lang/dart-protoc-plugin.git@master
Patch Set: Minor fix Created 6 years, 9 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 | « no previous file | test/generated_message_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/message_generator.dart
diff --git a/lib/message_generator.dart b/lib/message_generator.dart
index f7ec14f72d074ab3a9a3c212b8a9c2cca2749622..f6cff19ce426d6332839c61b6652150cf8f18311 100644
--- a/lib/message_generator.dart
+++ b/lib/message_generator.dart
@@ -7,6 +7,15 @@ part of protoc;
const String SP = ' ';
class MessageGenerator extends ProtobufContainer {
+ // List of Dart language reserved words in names which cannot be used in a
+ // subclass of GeneratedMessage.
+ static final List<String> reservedWords =
+ ['assert', 'break', 'case', 'catch', 'class', 'const', 'continue',
+ 'default', 'do', 'else', 'enum', 'extends', 'false', 'final',
+ 'finally', 'for', 'if', 'in', 'is', 'new', 'null', 'rethrow', 'return',
+ 'super', 'switch', 'this', 'throw', 'true', 'try', 'var', 'void',
+ 'while', 'with'];
+
// List of names which cannot be used in a subclass of GeneratedMessage.
static final List<String> reservedNames =
['hashCode', 'noSuchMethod','runtimeType', 'toString',
@@ -70,6 +79,7 @@ class MessageGenerator extends ProtobufContainer {
void generate(IndentingWriter out) {
_methodNames.clear();
+ _methodNames.addAll(reservedWords);
_methodNames.addAll(reservedNames);
for (EnumGenerator e in _enumGenerators) {
« no previous file with comments | « no previous file | test/generated_message_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698