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

Side by Side Diff: pkg/polymer/lib/src/declaration.dart

Issue 165373007: remove workaround for MethodMirror.metadata (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 part of polymer; 5 part of polymer;
6 6
7 /** 7 /**
8 * **Warning**: this class is experiental and subject to change. 8 * **Warning**: this class is experiental and subject to change.
9 * 9 *
10 * The implementation for the `polymer-element` element. 10 * The implementation for the `polymer-element` element.
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 * observe the associated properties. 483 * observe the associated properties.
484 */ 484 */
485 void explodeObservers(ClassMirror cls) { 485 void explodeObservers(ClassMirror cls) {
486 if (cls == _htmlElementType) return; 486 if (cls == _htmlElementType) return;
487 487
488 explodeObservers(cls.superclass); 488 explodeObservers(cls.superclass);
489 for (var method in cls.declarations.values) { 489 for (var method in cls.declarations.values) {
490 if (method is! MethodMirror || method.isStatic 490 if (method is! MethodMirror || method.isStatic
491 || !method.isRegularMethod) continue; 491 || !method.isRegularMethod) continue;
492 492
493 for (var meta in _safeGetMetadata(method)) { 493 for (var meta in method.metadata) {
494 if (meta.reflectee is! ObserveProperty) continue; 494 if (meta.reflectee is! ObserveProperty) continue;
495 495
496 if (_observe == null) _observe = new HashMap(); 496 if (_observe == null) _observe = new HashMap();
497 497
498 for (String name in meta.reflectee.names) { 498 for (String name in meta.reflectee.names) {
499 _observe.putIfAbsent(new PropertyPath(name), () => []) 499 _observe.putIfAbsent(new PropertyPath(name), () => [])
500 .add(method.simpleName); 500 .add(method.simpleName);
501 } 501 }
502 } 502 }
503 } 503 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 // bug introduced between Chrome 31 and 32. After 32 592 // bug introduced between Chrome 31 and 32. After 32
593 // JsClassMirror.declarations on Object calls 593 // JsClassMirror.declarations on Object calls
594 // JsClassMirror.typeVariables, which tries to get the _jsConstructor's 594 // JsClassMirror.typeVariables, which tries to get the _jsConstructor's
595 // .prototype["<>"]. This ends up getting the "" property instead, maybe 595 // .prototype["<>"]. This ends up getting the "" property instead, maybe
596 // because "<>" doesn't exist, and gets ";" which then blows up because 596 // because "<>" doesn't exist, and gets ";" which then blows up because
597 // the code later on expects a List of ints. 597 // the code later on expects a List of ints.
598 } while (cls != _objectType); 598 } while (cls != _objectType);
599 return null; 599 return null;
600 } 600 }
601 601
602 List _safeGetMetadata(MethodMirror method) {
603 // TODO(jmesserly): dart2js blows up getting metadata from methods in some
604 // cases. Why does this happen? It seems like the culprit might be named
605 // arguments. Unfortunately even calling method.parameters also
606 // triggers the bug in computeFunctionRti. For now we guard against it
607 // with this check.
608 try {
609 return method.metadata;
610 } catch (e) {
611 return [];
612 }
613 }
614
615 bool _hasSetter(ClassMirror cls, MethodMirror getter) { 602 bool _hasSetter(ClassMirror cls, MethodMirror getter) {
616 var setterName = new Symbol('${MirrorSystem.getName(getter.simpleName)}='); 603 var setterName = new Symbol('${MirrorSystem.getName(getter.simpleName)}=');
617 var mirror = cls.declarations[setterName]; 604 var mirror = cls.declarations[setterName];
618 return mirror is MethodMirror && mirror.isSetter; 605 return mirror is MethodMirror && mirror.isSetter;
619 } 606 }
620 607
621 608
622 /** Attribute prefix used for declarative event handlers. */ 609 /** Attribute prefix used for declarative event handlers. */
623 const _EVENT_PREFIX = 'on-'; 610 const _EVENT_PREFIX = 'on-';
624 611
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 706
720 // Dart note: we need this function because we have additional renames JS does 707 // Dart note: we need this function because we have additional renames JS does
721 // not have. The JS renames are simply case differences, whereas we have ones 708 // not have. The JS renames are simply case differences, whereas we have ones
722 // like doubleclick -> dblclick and stripping the webkit prefix. 709 // like doubleclick -> dblclick and stripping the webkit prefix.
723 String _eventNameFromType(String eventType) { 710 String _eventNameFromType(String eventType) {
724 final result = _reverseEventTranslations[eventType]; 711 final result = _reverseEventTranslations[eventType];
725 return result != null ? result : eventType; 712 return result != null ? result : eventType;
726 } 713 }
727 714
728 final _ATTRIBUTES_REGEX = new RegExp(r'\s|,'); 715 final _ATTRIBUTES_REGEX = new RegExp(r'\s|,');
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698