OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** | 5 /** |
6 * This library contains the infrastructure to parse and integrate patch files. | 6 * This library contains the infrastructure to parse and integrate patch files. |
7 * | 7 * |
8 * Three types of elements can be patched: [LibraryElement], [ClassElement], | 8 * Three types of elements can be patched: [LibraryElement], [ClassElement], |
9 * [FunctionElement]. Patches are introduced in patch libraries which are loaded | 9 * [FunctionElement]. Patches are introduced in patch libraries which are loaded |
10 * together with the corresponding origin library. Which libraries that are | 10 * together with the corresponding origin library. Which libraries that are |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 if (meta.beginToken?.next?.lexeme == 'patch') { | 382 if (meta.beginToken?.next?.lexeme == 'patch') { |
383 return true; | 383 return true; |
384 } | 384 } |
385 return null; | 385 return null; |
386 } | 386 } |
387 | 387 |
388 @override | 388 @override |
389 void validate(Compiler compiler, Element element, | 389 void validate(Compiler compiler, Element element, |
390 MetadataAnnotation annotation, ConstantValue constant) { | 390 MetadataAnnotation annotation, ConstantValue constant) { |
391 ResolutionDartType annotationType = | 391 ResolutionDartType annotationType = |
392 constant.getType(compiler.commonElements); | 392 constant.getType(compiler.resolution.commonElements); |
393 if (annotationType.element != | 393 if (annotationType.element != |
394 compiler.commonElements.patchAnnotationClass) { | 394 compiler.resolution.commonElements.patchAnnotationClass) { |
395 DiagnosticReporter reporter = compiler.reporter; | 395 DiagnosticReporter reporter = compiler.reporter; |
396 reporter.internalError(annotation, 'Invalid patch annotation.'); | 396 reporter.internalError(annotation, 'Invalid patch annotation.'); |
397 } | 397 } |
398 } | 398 } |
399 } | 399 } |
400 | 400 |
401 void tryPatchGetter( | 401 void tryPatchGetter( |
402 DiagnosticReporter reporter, Element origin, FunctionElement patch) { | 402 DiagnosticReporter reporter, Element origin, FunctionElement patch) { |
403 if (!origin.isAbstractField) { | 403 if (!origin.isAbstractField) { |
404 reporter.reportError( | 404 reporter.reportError( |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 origin, "Trying to patch a function more than once."); | 498 origin, "Trying to patch a function more than once."); |
499 } | 499 } |
500 origin.applyPatch(patch); | 500 origin.applyPatch(patch); |
501 } | 501 } |
502 | 502 |
503 bool _isMarkedAsPatch(Compiler compiler, Element element) { | 503 bool _isMarkedAsPatch(Compiler compiler, Element element) { |
504 return EagerAnnotationHandler.checkAnnotation( | 504 return EagerAnnotationHandler.checkAnnotation( |
505 compiler, element, const PatchAnnotationHandler()) == | 505 compiler, element, const PatchAnnotationHandler()) == |
506 true; | 506 true; |
507 } | 507 } |
OLD | NEW |