| Index: pkg/compiler/lib/src/patch_parser.dart
|
| diff --git a/pkg/compiler/lib/src/patch_parser.dart b/pkg/compiler/lib/src/patch_parser.dart
|
| index 0f3008475c1095209ef5cf8d8f547788361d14dc..288b210de487291f30d4d47881c77c06114fab59 100644
|
| --- a/pkg/compiler/lib/src/patch_parser.dart
|
| +++ b/pkg/compiler/lib/src/patch_parser.dart
|
| @@ -350,6 +350,7 @@ void patchClass(Compiler compiler,
|
| }
|
| origin.applyPatch(patch);
|
| checkNativeAnnotation(compiler, patch);
|
| + checkJsInteropAnnotation(compiler, patch);
|
| }
|
|
|
| /// Check whether [cls] has a `@Native(...)` annotation, and if so, set its
|
| @@ -359,6 +360,12 @@ checkNativeAnnotation(Compiler compiler, ClassElement cls) {
|
| const NativeAnnotationHandler());
|
| }
|
|
|
| +checkJsInteropAnnotation(Compiler compiler, ClassElement cls) {
|
| + EagerAnnotationHandler.checkAnnotation(compiler, cls,
|
| + const JsInteropAnnotationHandler());
|
| +}
|
| +
|
| +
|
| /// Abstract interface for pre-resolution detection of metadata.
|
| ///
|
| /// The detection is handled in two steps:
|
| @@ -449,6 +456,46 @@ class NativeAnnotationHandler implements EagerAnnotationHandler<String> {
|
| }
|
| }
|
|
|
| +/// Annotation handler for pre-resolution detection of `@JsName(...)`
|
| +/// annotations.
|
| +class JsInteropAnnotationHandler implements EagerAnnotationHandler<String> {
|
| + const JsInteropAnnotationHandler();
|
| +
|
| + String getJsNameAnnotation(MetadataAnnotation annotation) {
|
| + if (annotation.beginToken != null &&
|
| + annotation.beginToken.next.value == 'JsName') {
|
| + // Skipping '@', 'JsName', and '('.
|
| + Token argument = annotation.beginToken.next.next.next;
|
| + return (argument is StringToken) ? argument.value : '';
|
| + }
|
| +
|
| + return null;
|
| + }
|
| +
|
| + String apply(Compiler compiler,
|
| + Element element,
|
| + MetadataAnnotation annotation) {
|
| + if (element.isClass) {
|
| + String jsName = getJsNameAnnotation(annotation);
|
| + if (jsName != null) {
|
| + ClassElementX declaration = element.declaration;
|
| + // We do not track the class names for JsName annotations as we are not
|
| + // concerned about checked mode errors these classes.
|
| + declaration.isJsInterop = true;
|
| + return jsName;
|
| + }
|
| + }
|
| + return null;
|
| + }
|
| +
|
| + @override
|
| + void validate(Compiler compiler,
|
| + Element element,
|
| + MetadataAnnotation annotation,
|
| + ConstantValue constant) {
|
| + }
|
| +}
|
| +
|
| /// Annotation handler for pre-resolution detection of `@patch` annotations.
|
| class PatchAnnotationHandler implements EagerAnnotationHandler<PatchVersion> {
|
| const PatchAnnotationHandler();
|
|
|