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

Side by Side Diff: pkg/polymer/lib/src/build/script_compactor.dart

Issue 307793002: update polymer, nodebind, and templatebinding (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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 /// Transfomer that combines multiple dart script tags into a single one. 5 /// Transfomer that combines multiple dart script tags into a single one.
6 library polymer.src.build.script_compactor; 6 library polymer.src.build.script_compactor;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:convert'; 9 import 'dart:convert';
10 10
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 var isTwoWay = false; 499 var isTwoWay = false;
500 if (name is String) { 500 if (name is String) {
501 name = name.toLowerCase(); 501 name = name.toLowerCase();
502 isEvent = name.startsWith('on-'); 502 isEvent = name.startsWith('on-');
503 isTwoWay = !isEvent && bindings.isWhole && (isCustomTag || 503 isTwoWay = !isEvent && bindings.isWhole && (isCustomTag ||
504 tag == 'input' && (name == 'value' || name =='checked') || 504 tag == 'input' && (name == 'value' || name =='checked') ||
505 tag == 'select' && (name == 'selectedindex' || name == 'value') || 505 tag == 'select' && (name == 'selectedindex' || name == 'value') ||
506 tag == 'textarea' && name == 'value'); 506 tag == 'textarea' && name == 'value');
507 } 507 }
508 for (var exp in bindings.expressions) { 508 for (var exp in bindings.expressions) {
509 _addExpression(exp, isEvent, isTwoWay); 509 _addExpression(exp, isEvent, isTwoWay, node.sourceSpan);
510 } 510 }
511 }); 511 });
512 } 512 }
513 513
514 void _addExpression(String stringExpression, bool inEvent, bool isTwoWay) { 514 void _addExpression(String stringExpression, bool inEvent, bool isTwoWay,
515 SourceSpan span) {
516
515 if (inEvent) { 517 if (inEvent) {
516 if (!stringExpression.startsWith("@")) { 518 if (stringExpression.startsWith('@')) {
517 if (stringExpression == '') return; 519 logger.warning('event bindings with @ are no longer supported',
518 generator.addGetter(stringExpression); 520 span: span);
519 generator.addSymbol(stringExpression);
520 return; 521 return;
521 } 522 }
522 stringExpression = stringExpression.substring(1); 523
524 if (stringExpression == '') return;
525 generator.addGetter(stringExpression);
526 generator.addSymbol(stringExpression);
523 } 527 }
524 visitor.run(pe.parse(stringExpression), isTwoWay); 528 visitor.run(pe.parse(stringExpression), isTwoWay);
525 } 529 }
526 } 530 }
527 531
528 /// A polymer-expression visitor that records every getter and setter that will 532 /// A polymer-expression visitor that records every getter and setter that will
529 /// be needed to evaluate a single expression at runtime. 533 /// be needed to evaluate a single expression at runtime.
530 class _SubExpressionVisitor extends pe.RecursiveVisitor { 534 class _SubExpressionVisitor extends pe.RecursiveVisitor {
531 final SmokeCodeGenerator generator; 535 final SmokeCodeGenerator generator;
532 bool _includeSetter; 536 bool _includeSetter;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 for (var e in lib.exports) { 698 for (var e in lib.exports) {
695 var exported = e.exportedLibrary.units.expand((u) => u.types).toList(); 699 var exported = e.exportedLibrary.units.expand((u) => u.types).toList();
696 _filter(exported, e.combinators); 700 _filter(exported, e.combinators);
697 result.addAll(exported); 701 result.addAll(exported);
698 } 702 }
699 return result; 703 return result;
700 } 704 }
701 705
702 /// Retrieves all top-level methods that are visible if you were to import 706 /// Retrieves all top-level methods that are visible if you were to import
703 /// [lib]. This includes exported methods from other libraries too. 707 /// [lib]. This includes exported methods from other libraries too.
704 List<ClassElement> _visibleTopLevelMethodsOf(LibraryElement lib) { 708 List<FunctionElement> _visibleTopLevelMethodsOf(LibraryElement lib) {
705 var result = []; 709 var result = [];
706 result.addAll(lib.units.expand((u) => u.functions)); 710 result.addAll(lib.units.expand((u) => u.functions));
707 for (var e in lib.exports) { 711 for (var e in lib.exports) {
708 var exported = e.exportedLibrary.units 712 var exported = e.exportedLibrary.units
709 .expand((u) => u.functions).toList(); 713 .expand((u) => u.functions).toList();
710 _filter(exported, e.combinators); 714 _filter(exported, e.combinators);
711 result.addAll(exported); 715 result.addAll(exported);
712 } 716 }
713 return result; 717 return result;
714 } 718 }
715 719
716 /// Filters [elements] that come from an export, according to its show/hide 720 /// Filters [elements] that come from an export, according to its show/hide
717 /// combinators. This modifies [elements] in place. 721 /// combinators. This modifies [elements] in place.
718 void _filter(List<analyzer.Element> elements, 722 void _filter(List<analyzer.Element> elements,
719 List<NamespaceCombinator> combinators) { 723 List<NamespaceCombinator> combinators) {
720 for (var c in combinators) { 724 for (var c in combinators) {
721 if (c is ShowElementCombinator) { 725 if (c is ShowElementCombinator) {
722 var show = c.shownNames.toSet(); 726 var show = c.shownNames.toSet();
723 elements.retainWhere((e) => show.contains(e.displayName)); 727 elements.retainWhere((e) => show.contains(e.displayName));
724 } else if (c is HideElementCombinator) { 728 } else if (c is HideElementCombinator) {
725 var hide = c.hiddenNames.toSet(); 729 var hide = c.hiddenNames.toSet();
726 elements.removeWhere((e) => hide.contains(e.displayName)); 730 elements.removeWhere((e) => hide.contains(e.displayName));
727 } 731 }
728 } 732 }
729 } 733 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698