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

Side by Side Diff: pkg/smoke/lib/codegen/generator.dart

Issue 303003003: Fix 19029: handle special case when on-handler is empty in polymer, add better (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 /// Library to generate code that can initialize the `StaticConfiguration` in 5 /// Library to generate code that can initialize the `StaticConfiguration` in
6 /// `package:smoke/static.dart`. 6 /// `package:smoke/static.dart`.
7 /// 7 ///
8 /// This library doesn't have any specific logic to extract information from 8 /// This library doesn't have any specific logic to extract information from
9 /// Dart source code. To extract code using the analyzer, take a look at the 9 /// Dart source code. To extract code using the analyzer, take a look at the
10 /// `smoke.codegen.recorder` library. 10 /// `smoke.codegen.recorder` library.
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 int get hashCode => super.hashCode; 451 int get hashCode => super.hashCode;
452 } 452 }
453 453
454 /// Default set of imports added by [SmokeCodeGenerator]. 454 /// Default set of imports added by [SmokeCodeGenerator].
455 const DEFAULT_IMPORTS = const [ 455 const DEFAULT_IMPORTS = const [
456 "import 'package:smoke/smoke.dart' show Declaration, PROPERTY, METHOD;", 456 "import 'package:smoke/smoke.dart' show Declaration, PROPERTY, METHOD;",
457 "import 'package:smoke/static.dart' show " 457 "import 'package:smoke/static.dart' show "
458 "useGeneratedCode, StaticConfiguration;", 458 "useGeneratedCode, StaticConfiguration;",
459 ]; 459 ];
460 460
461 _symbol(String name) => 461 _symbol(String name) {
462 name.contains('[') ? "const Symbol('$name')" : '#$name'; 462 if (!_publicSymbolPattern.hasMatch(name)) {
463 throw new StateError('invalid symbol name: "$name"');
464 }
465 return _literalSymbolPattern.hasMatch(name)
466 ? '#$name' : "const Symbol('$name')";
467 }
468
469 // TODO(sigmund): is this included in some library we can import? I derived the
470 // definitions below from sdk/lib/internal/symbol.dart.
471
472 /// Reserved words in Dart.
473 const String _reservedWordRE =
474 r'(?:assert|break|c(?:a(?:se|tch)|lass|on(?:st|tinue))|d(?:efault|o)|'
475 r'e(?:lse|num|xtends)|f(?:alse|inal(?:ly)?|or)|i[fns]|n(?:ew|ull)|'
476 r'ret(?:hrow|urn)|s(?:uper|witch)|t(?:h(?:is|row)|r(?:ue|y))|'
477 r'v(?:ar|oid)|w(?:hile|ith))';
478
479 /// Public identifier: a valid identifier (not a reserved word) that doesn't
480 /// start with '_'.
481 const String _publicIdentifierRE =
482 r'(?!' '$_reservedWordRE' r'\b(?!\$))[a-zA-Z$][\w$]*';
483
484 /// Pattern that matches operators only.
485 final RegExp _literalSymbolPattern = new RegExp(
486 '^(?:$_publicIdentifierRE(?:\$|[.](?!\$)))+?\$');
487
488 /// Operator names allowed as symbols. The name of the oeprators is the same as
489 /// the operator itself except for unary minus, where the name is "unary-".
490 const String _operatorRE =
491 r'(?:[\-+*/%&|^]|\[\]=?|==|~/?|<[<=]?|>[>=]?|unary-)';
492
493 /// Pattern that matches public symbols.
494 final RegExp _publicSymbolPattern = new RegExp(
495 '^(?:$_operatorRE\$|$_publicIdentifierRE(?:=?\$|[.](?!\$)))+?\$');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698