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

Unified Diff: lib/src/codegen/js_interop.dart

Issue 1424133007: Compile package:js.{rest, spread} helpers (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Use freshly released version 0.6.0-beta.6 of package:js ran formatter Created 5 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
« no previous file with comments | « lib/src/codegen/js_codegen.dart ('k') | lib/src/compiler.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/codegen/js_interop.dart
diff --git a/lib/src/codegen/js_interop.dart b/lib/src/codegen/js_interop.dart
new file mode 100644
index 0000000000000000000000000000000000000000..4e9cbad9d367a8cd1b19acfa20549a45f25c12c1
--- /dev/null
+++ b/lib/src/codegen/js_interop.dart
@@ -0,0 +1,31 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library dev_compiler.src.js_interop;
+
+import 'package:analyzer/src/generated/ast.dart';
+import 'package:analyzer/src/generated/element.dart';
+import 'package:analyzer/src/generated/constant.dart';
+
+bool _isJsLibType(String expectedName, Element e) =>
+ e?.name == expectedName && _isJsLib(e.library);
+
+bool _isJsLib(LibraryElement e) {
+ var libName = e?.name;
+ return libName == 'js' ||
+ libName == 'js.varargs' ||
+ libName == 'dart._js_helper';
+}
+
+bool isJsRestAnnotation(DartObjectImpl value) =>
+ _isJsLibType('_Rest', value.type.element);
+
+bool isJsSpreadInvocation(MethodInvocation i) =>
+ _isJsLibType('spread', i.methodName?.bestElement);
+
+// TODO(jmesserly): Move JsName, JsPeerInterface to package:js (see issue #135).
+bool isJsNameAnnotation(DartObjectImpl value) => value.type.name == 'JsName';
+
+bool isJsPeerInterface(DartObjectImpl value) =>
+ value.type.name == 'JsPeerInterface';
« no previous file with comments | « lib/src/codegen/js_codegen.dart ('k') | lib/src/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698