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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 } | 429 } |
430 | 430 |
431 /// Annotation handler for pre-resolution detection of `@patch` annotations. | 431 /// Annotation handler for pre-resolution detection of `@patch` annotations. |
432 class PatchAnnotationHandler implements EagerAnnotationHandler<PatchVersion> { | 432 class PatchAnnotationHandler implements EagerAnnotationHandler<PatchVersion> { |
433 const PatchAnnotationHandler(); | 433 const PatchAnnotationHandler(); |
434 | 434 |
435 PatchVersion getPatchVersion(MetadataAnnotation annotation) { | 435 PatchVersion getPatchVersion(MetadataAnnotation annotation) { |
436 if (annotation.beginToken != null) { | 436 if (annotation.beginToken != null) { |
437 if (annotation.beginToken.next.value == 'patch') { | 437 if (annotation.beginToken.next.value == 'patch') { |
438 return const PatchVersion(null); | 438 return const PatchVersion(null); |
439 } else if (annotation.beginToken.next.value == 'patch_old') { | 439 } else if (annotation.beginToken.next.value == 'patch_full') { |
440 return const PatchVersion('old'); | 440 return const PatchVersion('full'); |
441 } else if (annotation.beginToken.next.value == 'patch_new') { | 441 } else if (annotation.beginToken.next.value == 'patch_lazy') { |
442 return const PatchVersion('new'); | 442 return const PatchVersion('lazy'); |
443 } | 443 } |
444 } | 444 } |
445 return null; | 445 return null; |
446 } | 446 } |
447 | 447 |
448 @override | 448 @override |
449 PatchVersion apply(Compiler compiler, | 449 PatchVersion apply(Compiler compiler, |
450 Element element, | 450 Element element, |
451 MetadataAnnotation annotation) { | 451 MetadataAnnotation annotation) { |
452 return getPatchVersion(annotation); | 452 return getPatchVersion(annotation); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 | 568 |
569 class PatchVersion { | 569 class PatchVersion { |
570 final String tag; | 570 final String tag; |
571 | 571 |
572 const PatchVersion(this.tag); | 572 const PatchVersion(this.tag); |
573 | 573 |
574 bool isActive(String patchTag) => tag == null || tag == patchTag; | 574 bool isActive(String patchTag) => tag == null || tag == patchTag; |
575 | 575 |
576 String toString() => 'PatchVersion($tag)'; | 576 String toString() => 'PatchVersion($tag)'; |
577 } | 577 } |
OLD | NEW |