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

Side by Side Diff: lib/src/compiler/js_interop.dart

Issue 1977893002: implement @JS classes (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: enable more tests Created 4 years, 7 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
« no previous file with comments | « lib/src/compiler/code_generator.dart ('k') | test/browser/language_tests.js » ('j') | 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) 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 import 'package:analyzer/dart/ast/ast.dart'; 5 import 'package:analyzer/dart/ast/ast.dart';
6 import 'package:analyzer/src/generated/constant.dart'; 6 import 'package:analyzer/src/generated/constant.dart';
7 import 'package:analyzer/dart/element/element.dart'; 7 import 'package:analyzer/dart/element/element.dart';
8 8
9 import 'element_helpers.dart'; 9 import 'element_helpers.dart';
10 10
(...skipping 22 matching lines...) Expand all
33 bool isJsSpreadInvocation(MethodInvocation i) => 33 bool isJsSpreadInvocation(MethodInvocation i) =>
34 _isJsLibType('spread', i.methodName?.bestElement); 34 _isJsLibType('spread', i.methodName?.bestElement);
35 35
36 // TODO(jmesserly): Move JsPeerInterface to package:js (see issue #135). 36 // TODO(jmesserly): Move JsPeerInterface to package:js (see issue #135).
37 // TODO(jacobr): The 'JS' annotation is the new, publically accessible one. 37 // TODO(jacobr): The 'JS' annotation is the new, publically accessible one.
38 // The 'JsName' annotation is the old one using internally by dart2js and 38 // The 'JsName' annotation is the old one using internally by dart2js and
39 // html libraries. These two concepts will probably merge eventually. 39 // html libraries. These two concepts will probably merge eventually.
40 bool isJSAnnotation(DartObjectImpl value) => 40 bool isJSAnnotation(DartObjectImpl value) =>
41 _isJsLibType('JS', value.type.element) || isJsName(value); 41 _isJsLibType('JS', value.type.element) || isJsName(value);
42 42
43 /// Returns [true] if [e] is the `JS` annotation from `package:js`.
44 bool isPublicJSAnnotation(DartObjectImpl value) =>
45 _isJsLibType('JS', value.type.element);
46
47 bool isJSAnonymousAnnotation(DartObjectImpl value) =>
48 _isJsLibType('_Anonymous', value.type.element);
49
43 bool _isBuiltinAnnotation( 50 bool _isBuiltinAnnotation(
44 DartObjectImpl value, String libraryName, String annotationName) { 51 DartObjectImpl value, String libraryName, String annotationName) {
45 var e = value?.type?.element; 52 var e = value?.type?.element;
46 if (e?.name != annotationName) return false; 53 if (e?.name != annotationName) return false;
47 var uri = e.source.uri; 54 var uri = e.source.uri;
48 var path = uri.pathSegments[0]; 55 var path = uri.pathSegments[0];
49 return uri.scheme == 'dart' && path == libraryName; 56 return uri.scheme == 'dart' && path == libraryName;
50 } 57 }
51 58
52 /// Whether [value] is a `@JSExportName` (internal annotation used in SDK 59 /// Whether [value] is a `@JSExportName` (internal annotation used in SDK
(...skipping 12 matching lines...) Expand all
65 72
66 /// Returns the name value of the `JSExportName` annotation (when compiling 73 /// Returns the name value of the `JSExportName` annotation (when compiling
67 /// the SDK), or `null` if there's none. This is used to control the name 74 /// the SDK), or `null` if there's none. This is used to control the name
68 /// under which functions are compiled and exported. 75 /// under which functions are compiled and exported.
69 String getJSExportName(Element e) { 76 String getJSExportName(Element e) {
70 if (e.source.isInSystemLibrary) { 77 if (e.source.isInSystemLibrary) {
71 return getAnnotationName(e, isJSExportNameAnnotation) ?? e.name; 78 return getAnnotationName(e, isJSExportNameAnnotation) ?? e.name;
72 } 79 }
73 return e.name; 80 return e.name;
74 } 81 }
OLDNEW
« no previous file with comments | « lib/src/compiler/code_generator.dart ('k') | test/browser/language_tests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698