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

Unified Diff: lib/src/transformer/utils.dart

Issue 615913004: Add @jsify annotation. Support automatically proxying Lists and Maps to Dart in Proxies. Support co… (Closed) Base URL: https://github.com/dart-lang/js-interop.git@master
Patch Set: Created 6 years, 2 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
Index: lib/src/transformer/utils.dart
diff --git a/lib/src/transformer/utils.dart b/lib/src/transformer/utils.dart
index 32e55cc0612ba3c9d93d5d414284cbdbc001cb7c..84dc398d2599ac448f773e8739f41bc324def7d5 100644
--- a/lib/src/transformer/utils.dart
+++ b/lib/src/transformer/utils.dart
@@ -33,6 +33,29 @@ LibraryElement getImplLib(LibraryElement jsLib) =>
.exportedLibraries
.singleWhere((l) => l.name == 'js.impl');
+bool hasAnnotation(Element element, ClassElement annotation) {
+
+ for (var metadata in element.metadata) {
+ var metaElement = metadata.element;
+ var exp;
+ var type;
+ if (metaElement is PropertyAccessorElement) {
+ exp = metaElement.variable;
+ type = exp.evaluationResult.value.type;
+ } else if (metaElement is ConstructorElement) {
+ exp = metaElement;
+ type = metaElement.enclosingElement.type;
+ } else {
+ throw new UnimplementedError('Unsupported annotation: ${metadata}');
+ }
+ if (exp == annotation) return true;
+ if (type.isSubtypeOf(annotation.type)) {
+ return true;
+ }
+ }
+ return false;
+}
+
JsProxy getProxyAnnotation(ClassElement interface, ClassElement jsProxyClass) {
var node = interface.node;
for (Annotation a in node.metadata) {

Powered by Google App Engine
This is Rietveld 408576698