OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library dev_compiler.src.js_interop; | |
6 | |
7 import 'package:analyzer/src/generated/ast.dart'; | 5 import 'package:analyzer/src/generated/ast.dart'; |
8 import 'package:analyzer/src/generated/element.dart'; | 6 import 'package:analyzer/src/generated/element.dart'; |
9 import 'package:analyzer/src/generated/constant.dart'; | 7 import 'package:analyzer/src/generated/constant.dart'; |
10 | 8 |
11 bool _isJsLibType(String expectedName, Element e) => | 9 bool _isJsLibType(String expectedName, Element e) => |
12 e?.name == expectedName && _isJsLib(e.library); | 10 e?.name == expectedName && _isJsLib(e.library); |
13 | 11 |
14 /// Returns true if [e] represents any library from `package:js` or is the | 12 /// Returns true if [e] represents any library from `package:js` or is the |
15 /// internal `dart:_js_helper` library. | 13 /// internal `dart:_js_helper` library. |
16 bool _isJsLib(LibraryElement e) { | 14 bool _isJsLib(LibraryElement e) { |
(...skipping 24 matching lines...) Expand all Loading... |
41 /// instead of `@JS` from `package:js`). | 39 /// instead of `@JS` from `package:js`). |
42 bool isJSExportNameAnnotation(DartObjectImpl value) { | 40 bool isJSExportNameAnnotation(DartObjectImpl value) { |
43 var e = value?.type?.element; | 41 var e = value?.type?.element; |
44 if (e?.name != 'JSExportName') return false; | 42 if (e?.name != 'JSExportName') return false; |
45 var uri = e.source.uri; | 43 var uri = e.source.uri; |
46 return uri.scheme == 'dart' && uri.path == '_foreign_helper'; | 44 return uri.scheme == 'dart' && uri.path == '_foreign_helper'; |
47 } | 45 } |
48 | 46 |
49 bool isJsPeerInterface(DartObjectImpl value) => | 47 bool isJsPeerInterface(DartObjectImpl value) => |
50 value.type.name == 'JsPeerInterface'; | 48 value.type.name == 'JsPeerInterface'; |
OLD | NEW |