Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit 533980d

Browse files
committed
chore(codegen): Factored reserved keyword logic into a library
1 parent 1c9559e commit 533980d

File tree

3 files changed

+14
-20
lines changed

3 files changed

+14
-20
lines changed

lib/tools/parser_generator/dart_code_gen.dart

+3-10
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
library dart_code_gen;
22

3-
import '../../core/parser/parser_library.dart'; // For ParserBackend.
3+
import 'package:angular/tools/reserved_dart_keywords.dart';
4+
import 'package:angular/core/parser/parser_library.dart'; // For ParserBackend.
45
import 'source.dart';
56

7+
68
Code VALUE_CODE = new Code("value");
79

810
class Code implements ParserAST {
@@ -64,15 +66,6 @@ class GetterSetterGenerator {
6466
static RegExp LAST_PATH_PART = new RegExp(r'(.*)\.(.*)');
6567
static RegExp NON_WORDS = new RegExp(r'\W');
6668

67-
// From https://www.dartlang.org/docs/spec/latest/dart-language-specification.html#h.huusvrzea3q
68-
static List<String> RESERVED_DART_KEYWORDS = [
69-
"assert", "break", "case", "catch", "class", "const", "continue",
70-
"default", "do", "else", "enum", "extends", "false", "final",
71-
"finally", "for", "if", "in", "is", "new", "null", "rethrow",
72-
"return", "super", "switch", "this", "throw", "true", "try",
73-
"var", "void", "while", "with"];
74-
isReserved(String key) => RESERVED_DART_KEYWORDS.contains(key);
75-
7669

7770
String functions = "// GETTER AND SETTER FUNCTIONS\n\n";
7871
var _keyToGetterFnName = {};

lib/tools/parser_getter_setter/generator.dart

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
import 'package:angular/core/parser/parser_library.dart';
2-
3-
// TODO(deboer): Remove this duplicated code.
4-
// From https://www.dartlang.org/docs/spec/latest/dart-language-specification.html#h.huusvrzea3q
5-
List<String> RESERVED_DART_KEYWORDS = [
6-
"assert", "break", "case", "catch", "class", "const", "continue",
7-
"default", "do", "else", "enum", "extends", "false", "final",
8-
"finally", "for", "if", "in", "is", "new", "null", "rethrow",
9-
"return", "super", "switch", "this", "throw", "true", "try",
10-
"var", "void", "while", "with"];
11-
isReserved(String key) => RESERVED_DART_KEYWORDS.contains(key);
2+
import 'package:angular/tools/reserved_dart_keywords.dart';
123

134
class _AST implements ParserAST {
145
bool get assignable => true;

lib/tools/reserved_dart_keywords.dart

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
library reserved_dart_keywords;
2+
3+
// From https://www.dartlang.org/docs/spec/latest/dart-language-specification.html#h.huusvrzea3q
4+
List<String> RESERVED_DART_KEYWORDS = [
5+
"assert", "break", "case", "catch", "class", "const", "continue",
6+
"default", "do", "else", "enum", "extends", "false", "final",
7+
"finally", "for", "if", "in", "is", "new", "null", "rethrow",
8+
"return", "super", "switch", "this", "throw", "true", "try",
9+
"var", "void", "while", "with"];
10+
isReserved(String key) => RESERVED_DART_KEYWORDS.contains(key);

0 commit comments

Comments
 (0)