| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 // TODO(johnniwinther): Make this a separate library. | 5 // TODO(johnniwinther): Make this a separate library. |
| 6 part of dart2js.kernel.element_map; | 6 part of dart2js.kernel.element_map; |
| 7 | 7 |
| 8 class KernelAnnotationProcessor implements AnnotationProcessor { | 8 class KernelAnnotationProcessor implements AnnotationProcessor { |
| 9 final KernelToElementMapForImpactImpl elementMap; | 9 final KernelToElementMapForImpactImpl elementMap; |
| 10 final NativeBasicDataBuilder _nativeBasicDataBuilder; | 10 final NativeBasicDataBuilder _nativeBasicDataBuilder; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 if (!function.isExternal && | 122 if (!function.isExternal && |
| 123 !function.isAbstract && | 123 !function.isAbstract && |
| 124 !function.isConstructor && | 124 !function.isConstructor && |
| 125 !function.isStatic) { | 125 !function.isStatic) { |
| 126 reporter.reportErrorMessage( | 126 reporter.reportErrorMessage( |
| 127 function, | 127 function, |
| 128 MessageKind.JS_INTEROP_CLASS_NON_EXTERNAL_MEMBER, | 128 MessageKind.JS_INTEROP_CLASS_NON_EXTERNAL_MEMBER, |
| 129 {'cls': cls.name, 'member': member.name}); | 129 {'cls': cls.name, 'member': member.name}); |
| 130 } | 130 } |
| 131 | 131 |
| 132 if (function is ConstructorEntity && | 132 checkFunctionParameters(function); |
| 133 function.isFactoryConstructor && | 133 }); |
| 134 isAnonymous) { | 134 elementEnvironment.forEachConstructor(cls, |
| 135 if (function.parameterStructure.requiredParameters > 0) { | 135 (ConstructorEntity constructor) { |
| 136 String memberName = getJsInteropName( |
| 137 library, elementEnvironment.getMemberMetadata(constructor)); |
| 138 if (memberName != null) { |
| 139 _nativeBasicDataBuilder.markAsJsInteropMember( |
| 140 constructor, memberName); |
| 141 } |
| 142 |
| 143 if (!constructor.isExternal) { |
| 144 reporter.reportErrorMessage( |
| 145 constructor, |
| 146 MessageKind.JS_INTEROP_CLASS_NON_EXTERNAL_MEMBER, |
| 147 {'cls': cls.name, 'member': constructor.name}); |
| 148 } |
| 149 if (constructor.isFactoryConstructor && isAnonymous) { |
| 150 if (constructor.parameterStructure.requiredParameters > 0) { |
| 136 reporter.reportErrorMessage( | 151 reporter.reportErrorMessage( |
| 137 function, | 152 constructor, |
| 138 MessageKind | 153 MessageKind |
| 139 .JS_OBJECT_LITERAL_CONSTRUCTOR_WITH_POSITIONAL_ARGUMENTS, | 154 .JS_OBJECT_LITERAL_CONSTRUCTOR_WITH_POSITIONAL_ARGUMENTS, |
| 140 {'cls': cls.name}); | 155 {'cls': cls.name}); |
| 141 } | 156 } |
| 142 } else { | 157 } else { |
| 143 checkFunctionParameters(function); | 158 checkFunctionParameters(constructor); |
| 144 } | 159 } |
| 145 }); | 160 }); |
| 146 } | 161 } |
| 147 }); | 162 }); |
| 148 if (isJsLibrary) { | 163 if (isJsLibrary) { |
| 149 // TODO(johnniwinther): Remove this when fasta supports library metadata. | 164 // TODO(johnniwinther): Remove this when fasta supports library metadata. |
| 150 // For now, assume the empty name. | 165 // For now, assume the empty name. |
| 151 libraryName ??= ''; | 166 libraryName ??= ''; |
| 152 _nativeBasicDataBuilder.markAsJsInteropLibrary(library, | 167 _nativeBasicDataBuilder.markAsJsInteropLibrary(library, |
| 153 name: libraryName); | 168 name: libraryName); |
| 154 } | 169 } |
| 155 } | 170 } |
| 156 | 171 |
| 157 @override | 172 @override |
| 158 void processJsInteropAnnotations( | 173 void processJsInteropAnnotations( |
| 159 NativeBasicData nativeBasicData, NativeDataBuilder nativeDataBuilder) { | 174 NativeBasicData nativeBasicData, NativeDataBuilder nativeDataBuilder) { |
| 160 // Nothing to do; all is computed in [extractJsInteropAnnotations]. | 175 // Nothing to do; all is computed in [extractJsInteropAnnotations]. |
| 161 } | 176 } |
| 162 } | 177 } |
| OLD | NEW |