Index: lib/src/codegen/js_interop.dart |
diff --git a/lib/src/codegen/js_interop.dart b/lib/src/codegen/js_interop.dart |
index 73a03deb1bfa25b7b1fbf553bb59bcf754d12aa4..54fc8fccb35aaa5f30985d2637ceb3c38d5cb302 100644 |
--- a/lib/src/codegen/js_interop.dart |
+++ b/lib/src/codegen/js_interop.dart |
@@ -35,14 +35,25 @@ bool isJsSpreadInvocation(MethodInvocation i) => |
bool isJSAnnotation(DartObjectImpl value) => |
_isJsLibType('JS', value.type.element); |
-/// Whether [value] is a `@JSExportName` (internal annotation used in SDK |
-/// instead of `@JS` from `package:js`). |
-bool isJSExportNameAnnotation(DartObjectImpl value) { |
+bool _isBuiltinAnnotation( |
+ DartObjectImpl value, String libraryName, String annotationName) { |
var e = value?.type?.element; |
- if (e?.name != 'JSExportName') return false; |
+ if (e?.name != annotationName) return false; |
var uri = e.source.uri; |
- return uri.scheme == 'dart' && uri.path == '_foreign_helper'; |
+ var path = uri.pathSegments[0]; |
+ return uri.scheme == 'dart' && path == libraryName; |
} |
+/// Whether [value] is a `@JSExportName` (internal annotation used in SDK |
+/// instead of `@JS` from `package:js`). |
+bool isJSExportNameAnnotation(DartObjectImpl value) => |
+ _isBuiltinAnnotation(value, '_foreign_helper', 'JSExportName'); |
+ |
+bool isJsName(DartObjectImpl value) => |
+ _isBuiltinAnnotation(value, '_js_helper', 'JSName'); |
+ |
bool isJsPeerInterface(DartObjectImpl value) => |
- value.type.name == 'JsPeerInterface'; |
+ _isBuiltinAnnotation(value, '_js_helper', 'JsPeerInterface'); |
+ |
+bool isNativeAnnotation(DartObjectImpl value) => |
+ _isBuiltinAnnotation(value, '_js_helper', 'Native'); |