OLD | NEW |
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 library analyzer.src.task.dart; | 5 library analyzer.src.task.dart; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
10 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 /** | 239 /** |
240 * The flag specifying that [RESOLVED_UNIT12] has been been computed for this | 240 * The flag specifying that [RESOLVED_UNIT12] has been been computed for this |
241 * compilation unit (without requiring that the AST for it still be in cache). | 241 * compilation unit (without requiring that the AST for it still be in cache). |
242 * | 242 * |
243 * The result is only available for [LibrarySpecificUnit]s. | 243 * The result is only available for [LibrarySpecificUnit]s. |
244 */ | 244 */ |
245 final ResultDescriptor<bool> CREATED_RESOLVED_UNIT12 = | 245 final ResultDescriptor<bool> CREATED_RESOLVED_UNIT12 = |
246 new ResultDescriptor<bool>('CREATED_RESOLVED_UNIT12', false); | 246 new ResultDescriptor<bool>('CREATED_RESOLVED_UNIT12', false); |
247 | 247 |
248 /** | 248 /** |
249 * The flag specifying that [RESOLVED_UNIT13] has been been computed for this | |
250 * compilation unit (without requiring that the AST for it still be in cache). | |
251 * | |
252 * The result is only available for [LibrarySpecificUnit]s. | |
253 */ | |
254 final ResultDescriptor<bool> CREATED_RESOLVED_UNIT13 = | |
255 new ResultDescriptor<bool>('CREATED_RESOLVED_UNIT13', false); | |
256 | |
257 /** | |
258 * The flag specifying that [RESOLVED_UNIT2] has been been computed for this | 249 * The flag specifying that [RESOLVED_UNIT2] has been been computed for this |
259 * compilation unit (without requiring that the AST for it still be in cache). | 250 * compilation unit (without requiring that the AST for it still be in cache). |
260 * | 251 * |
261 * The result is only available for [LibrarySpecificUnit]s. | 252 * The result is only available for [LibrarySpecificUnit]s. |
262 */ | 253 */ |
263 final ResultDescriptor<bool> CREATED_RESOLVED_UNIT2 = | 254 final ResultDescriptor<bool> CREATED_RESOLVED_UNIT2 = |
264 new ResultDescriptor<bool>('CREATED_RESOLVED_UNIT2', false); | 255 new ResultDescriptor<bool>('CREATED_RESOLVED_UNIT2', false); |
265 | 256 |
266 /** | 257 /** |
267 * The flag specifying that [RESOLVED_UNIT3] has been been computed for this | 258 * The flag specifying that [RESOLVED_UNIT3] has been been computed for this |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 * | 510 * |
520 * The result is only available for [Source]s representing a library. | 511 * The result is only available for [Source]s representing a library. |
521 */ | 512 */ |
522 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT6 = | 513 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT6 = |
523 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT6', null, | 514 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT6', null, |
524 cachingPolicy: ELEMENT_CACHING_POLICY); | 515 cachingPolicy: ELEMENT_CACHING_POLICY); |
525 | 516 |
526 /** | 517 /** |
527 * The partial [LibraryElement] associated with a library. | 518 * The partial [LibraryElement] associated with a library. |
528 * | 519 * |
529 * [LIBRARY_ELEMENT6] plus propagated types for propagable variables. | 520 * [LIBRARY_ELEMENT6] plus [RESOLVED_UNIT7] for all library units. |
530 * | 521 * |
531 * The result is only available for [Source]s representing a library. | 522 * The result is only available for [Source]s representing a library. |
532 */ | 523 */ |
533 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT7 = | 524 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT7 = |
534 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT7', null, | 525 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT7', null, |
535 cachingPolicy: ELEMENT_CACHING_POLICY); | 526 cachingPolicy: ELEMENT_CACHING_POLICY); |
536 | 527 |
537 /** | 528 /** |
538 * The partial [LibraryElement] associated with a library. | 529 * The partial [LibraryElement] associated with a library. |
539 * | 530 * |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 /** | 619 /** |
629 * The list of [PendingError]s for a compilation unit. | 620 * The list of [PendingError]s for a compilation unit. |
630 * | 621 * |
631 * The result is only available for [LibrarySpecificUnit]s. | 622 * The result is only available for [LibrarySpecificUnit]s. |
632 */ | 623 */ |
633 final ListResultDescriptor<PendingError> PENDING_ERRORS = | 624 final ListResultDescriptor<PendingError> PENDING_ERRORS = |
634 new ListResultDescriptor<PendingError>( | 625 new ListResultDescriptor<PendingError>( |
635 'PENDING_ERRORS', const <PendingError>[]); | 626 'PENDING_ERRORS', const <PendingError>[]); |
636 | 627 |
637 /** | 628 /** |
638 * A list of the [VariableElement]s whose type should be known to propagate | |
639 * the type of another variable (the target). | |
640 * | |
641 * The result is only available for [VariableElement]s. | |
642 */ | |
643 final ListResultDescriptor<VariableElement> PROPAGABLE_VARIABLE_DEPENDENCIES = | |
644 new ListResultDescriptor<VariableElement>( | |
645 'PROPAGABLE_VARIABLE_DEPENDENCIES', null); | |
646 | |
647 /** | |
648 * A list of the [VariableElement]s defined in a unit whose type might be | |
649 * propagated. This includes variables defined at the library level as well as | |
650 * static and instance members inside classes. | |
651 * | |
652 * The result is only available for [LibrarySpecificUnit]s. | |
653 */ | |
654 final ListResultDescriptor<VariableElement> PROPAGABLE_VARIABLES_IN_UNIT = | |
655 new ListResultDescriptor<VariableElement>( | |
656 'PROPAGABLE_VARIABLES_IN_UNIT', null); | |
657 | |
658 /** | |
659 * An propagable variable ([VariableElement]) whose type has been propagated. | |
660 * | |
661 * The result is only available for [VariableElement]s. | |
662 */ | |
663 final ResultDescriptor<VariableElement> PROPAGATED_VARIABLE = | |
664 new ResultDescriptor<VariableElement>('PROPAGATED_VARIABLE', null, | |
665 cachingPolicy: ELEMENT_CACHING_POLICY); | |
666 | |
667 /** | |
668 * The flag specifying that [LIBRARY_ELEMENT2] is ready for a library and its | 629 * The flag specifying that [LIBRARY_ELEMENT2] is ready for a library and its |
669 * import/export closure. | 630 * import/export closure. |
670 * | 631 * |
671 * The result is only available for [Source]s representing a library. | 632 * The result is only available for [Source]s representing a library. |
672 */ | 633 */ |
673 final ResultDescriptor<bool> READY_LIBRARY_ELEMENT2 = | 634 final ResultDescriptor<bool> READY_LIBRARY_ELEMENT2 = |
674 new ResultDescriptor<bool>('READY_LIBRARY_ELEMENT2', false); | 635 new ResultDescriptor<bool>('READY_LIBRARY_ELEMENT2', false); |
675 | 636 |
676 /** | 637 /** |
677 * The flag specifying that [LIBRARY_ELEMENT6] is ready for a library and its | 638 * The flag specifying that [LIBRARY_ELEMENT6] is ready for a library and its |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 * at all declaration sites have been bound to the element defined by the | 730 * at all declaration sites have been bound to the element defined by the |
770 * declaration, except for the constants defined in an 'enum' declaration. | 731 * declaration, except for the constants defined in an 'enum' declaration. |
771 * | 732 * |
772 * The result is only available for [LibrarySpecificUnit]s. | 733 * The result is only available for [LibrarySpecificUnit]s. |
773 */ | 734 */ |
774 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT1 = | 735 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT1 = |
775 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT1', null, | 736 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT1', null, |
776 cachingPolicy: AST_REUSABLE_CACHING_POLICY); | 737 cachingPolicy: AST_REUSABLE_CACHING_POLICY); |
777 | 738 |
778 /** | 739 /** |
779 * The partially resolved [CompilationUnit] associated with a compilation unit. | 740 * The resolved [CompilationUnit] associated with a compilation unit in which |
780 * | 741 * the types of class members have been inferred in addition to everything that |
781 * In addition to what is true of a [RESOLVED_UNIT9], tasks that use this value | 742 * is true of a [RESOLVED_UNIT9]. |
782 * as an input can assume that the initializers of instance variables have been | |
783 * re-resolved. | |
784 * | 743 * |
785 * The result is only available for [LibrarySpecificUnit]s. | 744 * The result is only available for [LibrarySpecificUnit]s. |
786 */ | 745 */ |
787 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT10 = | 746 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT10 = |
788 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT10', null, | 747 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT10', null, |
789 cachingPolicy: AST_CACHING_POLICY); | 748 cachingPolicy: AST_CACHING_POLICY); |
790 | 749 |
791 /** | 750 /** |
792 * The resolved [CompilationUnit] associated with a compilation unit in which | 751 * The resolved [CompilationUnit] associated with a compilation unit, with |
793 * the types of class members have been inferred in addition to everything that | 752 * constants not yet resolved. |
794 * is true of a [RESOLVED_UNIT10]. | |
795 * | 753 * |
796 * The result is only available for [LibrarySpecificUnit]s. | 754 * The result is only available for [LibrarySpecificUnit]s. |
797 */ | 755 */ |
798 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT11 = | 756 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT11 = |
799 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT11', null, | 757 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT11', null, |
800 cachingPolicy: AST_CACHING_POLICY); | 758 cachingPolicy: AST_CACHING_POLICY); |
801 | 759 |
802 /** | 760 /** |
803 * The resolved [CompilationUnit] associated with a compilation unit, with | 761 * The resolved [CompilationUnit] associated with a compilation unit, with |
804 * constants not yet resolved. | 762 * constants resolved. |
805 * | 763 * |
806 * The result is only available for [LibrarySpecificUnit]s. | 764 * The result is only available for [LibrarySpecificUnit]s. |
807 */ | 765 */ |
808 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT12 = | 766 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT12 = |
809 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT12', null, | 767 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT12', null, |
810 cachingPolicy: AST_CACHING_POLICY); | 768 cachingPolicy: AST_CACHING_POLICY); |
811 | 769 |
812 /** | 770 /** |
813 * The resolved [CompilationUnit] associated with a compilation unit, with | |
814 * constants resolved. | |
815 * | |
816 * The result is only available for [LibrarySpecificUnit]s. | |
817 */ | |
818 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT13 = | |
819 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT13', null, | |
820 cachingPolicy: AST_CACHING_POLICY); | |
821 | |
822 /** | |
823 * The partially resolved [CompilationUnit] associated with a compilation unit. | 771 * The partially resolved [CompilationUnit] associated with a compilation unit. |
824 * | 772 * |
825 * In addition to what is true of a [RESOLVED_UNIT1], tasks that use this value | 773 * In addition to what is true of a [RESOLVED_UNIT1], tasks that use this value |
826 * as an input can assume that its directives have been resolved. | 774 * as an input can assume that its directives have been resolved. |
827 * | 775 * |
828 * The result is only available for [LibrarySpecificUnit]s. | 776 * The result is only available for [LibrarySpecificUnit]s. |
829 */ | 777 */ |
830 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT2 = | 778 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT2 = |
831 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT2', null, | 779 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT2', null, |
832 cachingPolicy: AST_CACHING_POLICY); | 780 cachingPolicy: AST_CACHING_POLICY); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 * The result is only available for [LibrarySpecificUnit]s. | 843 * The result is only available for [LibrarySpecificUnit]s. |
896 */ | 844 */ |
897 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT7 = | 845 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT7 = |
898 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT7', null, | 846 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT7', null, |
899 cachingPolicy: AST_CACHING_POLICY); | 847 cachingPolicy: AST_CACHING_POLICY); |
900 | 848 |
901 /** | 849 /** |
902 * The partially resolved [CompilationUnit] associated with a compilation unit. | 850 * The partially resolved [CompilationUnit] associated with a compilation unit. |
903 * | 851 * |
904 * In addition to what is true of a [RESOLVED_UNIT7], tasks that use this value | 852 * In addition to what is true of a [RESOLVED_UNIT7], tasks that use this value |
905 * as an input can assume that the types of final variables have been | 853 * as an input can assume that the types of static variables have been inferred. |
906 * propagated. | |
907 * | 854 * |
908 * The result is only available for [LibrarySpecificUnit]s. | 855 * The result is only available for [LibrarySpecificUnit]s. |
909 */ | 856 */ |
910 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT8 = | 857 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT8 = |
911 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT8', null, | 858 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT8', null, |
912 cachingPolicy: AST_CACHING_POLICY); | 859 cachingPolicy: AST_CACHING_POLICY); |
913 | 860 |
914 /** | 861 /** |
915 * The partially resolved [CompilationUnit] associated with a compilation unit. | 862 * The partially resolved [CompilationUnit] associated with a compilation unit. |
916 * | 863 * |
917 * In addition to what is true of a [RESOLVED_UNIT8], tasks that use this value | 864 * In addition to what is true of a [RESOLVED_UNIT8], tasks that use this value |
918 * as an input can assume that the types of static variables have been inferred. | 865 * as an input can assume that the initializers of instance variables have been |
| 866 * re-resolved. |
919 * | 867 * |
920 * The result is only available for [LibrarySpecificUnit]s. | 868 * The result is only available for [LibrarySpecificUnit]s. |
921 */ | 869 */ |
922 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT9 = | 870 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT9 = |
923 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT9', null, | 871 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT9', null, |
924 cachingPolicy: AST_CACHING_POLICY); | 872 cachingPolicy: AST_CACHING_POLICY); |
925 | 873 |
926 /** | 874 /** |
927 * List of all `RESOLVED_UNITx` results. | 875 * List of all `RESOLVED_UNITx` results. |
928 */ | 876 */ |
929 final List<ResultDescriptor<CompilationUnit>> RESOLVED_UNIT_RESULTS = | 877 final List<ResultDescriptor<CompilationUnit>> RESOLVED_UNIT_RESULTS = |
930 <ResultDescriptor<CompilationUnit>>[ | 878 <ResultDescriptor<CompilationUnit>>[ |
931 RESOLVED_UNIT1, | 879 RESOLVED_UNIT1, |
932 RESOLVED_UNIT2, | 880 RESOLVED_UNIT2, |
933 RESOLVED_UNIT3, | 881 RESOLVED_UNIT3, |
934 RESOLVED_UNIT4, | 882 RESOLVED_UNIT4, |
935 RESOLVED_UNIT5, | 883 RESOLVED_UNIT5, |
936 RESOLVED_UNIT6, | 884 RESOLVED_UNIT6, |
937 RESOLVED_UNIT7, | 885 RESOLVED_UNIT7, |
938 RESOLVED_UNIT8, | 886 RESOLVED_UNIT8, |
939 RESOLVED_UNIT9, | 887 RESOLVED_UNIT9, |
940 RESOLVED_UNIT10, | 888 RESOLVED_UNIT10, |
941 RESOLVED_UNIT11, | 889 RESOLVED_UNIT11, |
942 RESOLVED_UNIT12, | 890 RESOLVED_UNIT12, |
943 RESOLVED_UNIT13, | |
944 RESOLVED_UNIT | 891 RESOLVED_UNIT |
945 ]; | 892 ]; |
946 | 893 |
947 /** | 894 /** |
948 * The errors produced while scanning a compilation unit. | 895 * The errors produced while scanning a compilation unit. |
949 * | 896 * |
950 * The list will be empty if there were no errors, but will not be `null`. | 897 * The list will be empty if there were no errors, but will not be `null`. |
951 * | 898 * |
952 * The result is only available for [Source]s representing a compilation unit. | 899 * The result is only available for [Source]s representing a compilation unit. |
953 */ | 900 */ |
(...skipping 1342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2296 * Create a [ComputeLibraryCycleTask] based on the | 2243 * Create a [ComputeLibraryCycleTask] based on the |
2297 * given [target] in the given [context]. | 2244 * given [target] in the given [context]. |
2298 */ | 2245 */ |
2299 static ComputeLibraryCycleTask createTask( | 2246 static ComputeLibraryCycleTask createTask( |
2300 AnalysisContext context, AnalysisTarget target) { | 2247 AnalysisContext context, AnalysisTarget target) { |
2301 return new ComputeLibraryCycleTask(context, target); | 2248 return new ComputeLibraryCycleTask(context, target); |
2302 } | 2249 } |
2303 } | 2250 } |
2304 | 2251 |
2305 /** | 2252 /** |
2306 * A task that computes the [PROPAGABLE_VARIABLE_DEPENDENCIES] for a variable. | |
2307 */ | |
2308 class ComputePropagableVariableDependenciesTask | |
2309 extends InferStaticVariableTask { | |
2310 /** | |
2311 * The name of the [RESOLVED_UNIT7] input. | |
2312 */ | |
2313 static const String UNIT_INPUT = 'UNIT_INPUT'; | |
2314 | |
2315 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | |
2316 'ComputePropagableVariableDependenciesTask', | |
2317 createTask, | |
2318 buildInputs, | |
2319 <ResultDescriptor>[PROPAGABLE_VARIABLE_DEPENDENCIES]); | |
2320 | |
2321 ComputePropagableVariableDependenciesTask( | |
2322 InternalAnalysisContext context, VariableElement variable) | |
2323 : super(context, variable); | |
2324 | |
2325 @override | |
2326 TaskDescriptor get descriptor => DESCRIPTOR; | |
2327 | |
2328 @override | |
2329 void internalPerform() { | |
2330 // | |
2331 // Prepare inputs. | |
2332 // | |
2333 CompilationUnit unit = getRequiredInput(UNIT_INPUT); | |
2334 // | |
2335 // Compute dependencies. | |
2336 // | |
2337 VariableDeclaration declaration = getDeclaration(unit); | |
2338 VariableGatherer gatherer = new VariableGatherer(_isPropagable); | |
2339 declaration.initializer.accept(gatherer); | |
2340 // | |
2341 // Record outputs. | |
2342 // | |
2343 outputs[PROPAGABLE_VARIABLE_DEPENDENCIES] = gatherer.results.toList(); | |
2344 } | |
2345 | |
2346 /** | |
2347 * Return `true` if the given [variable] is a variable whose type can be | |
2348 * propagated. | |
2349 */ | |
2350 bool _isPropagable(VariableElement variable) => | |
2351 variable is PropertyInducingElement && | |
2352 (variable.isConst || variable.isFinal) && | |
2353 variable.hasImplicitType && | |
2354 variable.initializer != null; | |
2355 | |
2356 /** | |
2357 * Return a map from the names of the inputs of this kind of task to the task | |
2358 * input descriptors describing those inputs for a task with the | |
2359 * given [target]. | |
2360 */ | |
2361 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | |
2362 if (target is VariableElement) { | |
2363 CompilationUnitElementImpl unit = target | |
2364 .getAncestor((Element element) => element is CompilationUnitElement); | |
2365 return <String, TaskInput>{ | |
2366 UNIT_INPUT: RESOLVED_UNIT7 | |
2367 .of(new LibrarySpecificUnit(unit.librarySource, unit.source)) | |
2368 }; | |
2369 } | |
2370 throw new AnalysisException( | |
2371 'Cannot build inputs for a ${target.runtimeType}'); | |
2372 } | |
2373 | |
2374 /** | |
2375 * Create a [ComputePropagableVariableDependenciesTask] based on the | |
2376 * given [target] in the given [context]. | |
2377 */ | |
2378 static ComputePropagableVariableDependenciesTask createTask( | |
2379 AnalysisContext context, AnalysisTarget target) { | |
2380 return new ComputePropagableVariableDependenciesTask(context, target); | |
2381 } | |
2382 } | |
2383 | |
2384 /** | |
2385 * A task that builds [REQUIRED_CONSTANTS] for a unit. | 2253 * A task that builds [REQUIRED_CONSTANTS] for a unit. |
2386 */ | 2254 */ |
2387 class ComputeRequiredConstantsTask extends SourceBasedAnalysisTask { | 2255 class ComputeRequiredConstantsTask extends SourceBasedAnalysisTask { |
2388 /** | 2256 /** |
2389 * The name of the [RESOLVED_UNIT] input. | 2257 * The name of the [RESOLVED_UNIT] input. |
2390 */ | 2258 */ |
2391 static const String UNIT_INPUT = 'UNIT_INPUT'; | 2259 static const String UNIT_INPUT = 'UNIT_INPUT'; |
2392 | 2260 |
2393 /** | 2261 /** |
2394 * The task descriptor describing this kind of task. | 2262 * The task descriptor describing this kind of task. |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2999 // Ignores can be on the line or just preceding the error. | 2867 // Ignores can be on the line or just preceding the error. |
3000 return ignoreInfo.ignoredAt(errorCode, errorLine) || | 2868 return ignoreInfo.ignoredAt(errorCode, errorLine) || |
3001 ignoreInfo.ignoredAt(errorCode, errorLine - 1); | 2869 ignoreInfo.ignoredAt(errorCode, errorLine - 1); |
3002 } | 2870 } |
3003 | 2871 |
3004 return errors.where((AnalysisError e) => !isIgnored(e)).toList(); | 2872 return errors.where((AnalysisError e) => !isIgnored(e)).toList(); |
3005 } | 2873 } |
3006 } | 2874 } |
3007 | 2875 |
3008 /** | 2876 /** |
3009 * A task that builds [RESOLVED_UNIT13] for a unit. | 2877 * A task that builds [RESOLVED_UNIT12] for a unit. |
3010 */ | 2878 */ |
3011 class EvaluateUnitConstantsTask extends SourceBasedAnalysisTask { | 2879 class EvaluateUnitConstantsTask extends SourceBasedAnalysisTask { |
3012 /** | 2880 /** |
3013 * The name of the [RESOLVED_UNIT12] input. | 2881 * The name of the [RESOLVED_UNIT11] input. |
3014 */ | 2882 */ |
3015 static const String UNIT_INPUT = 'UNIT_INPUT'; | 2883 static const String UNIT_INPUT = 'UNIT_INPUT'; |
3016 | 2884 |
3017 /** | 2885 /** |
3018 * The name of the [CONSTANT_VALUE] input. | 2886 * The name of the [CONSTANT_VALUE] input. |
3019 */ | 2887 */ |
3020 static const String CONSTANT_VALUES = 'CONSTANT_VALUES'; | 2888 static const String CONSTANT_VALUES = 'CONSTANT_VALUES'; |
3021 | 2889 |
3022 /** | 2890 /** |
3023 * The task descriptor describing this kind of task. | 2891 * The task descriptor describing this kind of task. |
3024 */ | 2892 */ |
3025 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 2893 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
3026 'EvaluateUnitConstantsTask', | 2894 'EvaluateUnitConstantsTask', |
3027 createTask, | 2895 createTask, |
3028 buildInputs, | 2896 buildInputs, |
3029 <ResultDescriptor>[CREATED_RESOLVED_UNIT13, RESOLVED_UNIT13]); | 2897 <ResultDescriptor>[CREATED_RESOLVED_UNIT12, RESOLVED_UNIT12]); |
3030 | 2898 |
3031 EvaluateUnitConstantsTask(AnalysisContext context, LibrarySpecificUnit target) | 2899 EvaluateUnitConstantsTask(AnalysisContext context, LibrarySpecificUnit target) |
3032 : super(context, target); | 2900 : super(context, target); |
3033 | 2901 |
3034 @override | 2902 @override |
3035 TaskDescriptor get descriptor => DESCRIPTOR; | 2903 TaskDescriptor get descriptor => DESCRIPTOR; |
3036 | 2904 |
3037 @override | 2905 @override |
3038 void internalPerform() { | 2906 void internalPerform() { |
3039 // No actual work needs to be performed; the task manager will ensure that | 2907 // No actual work needs to be performed; the task manager will ensure that |
3040 // all constants are evaluated before this method is called. | 2908 // all constants are evaluated before this method is called. |
3041 CompilationUnit unit = getRequiredInput(UNIT_INPUT); | 2909 CompilationUnit unit = getRequiredInput(UNIT_INPUT); |
3042 outputs[RESOLVED_UNIT13] = unit; | 2910 outputs[RESOLVED_UNIT12] = unit; |
3043 outputs[CREATED_RESOLVED_UNIT13] = true; | 2911 outputs[CREATED_RESOLVED_UNIT12] = true; |
3044 } | 2912 } |
3045 | 2913 |
3046 /** | 2914 /** |
3047 * Return a map from the names of the inputs of this kind of task to the task | 2915 * Return a map from the names of the inputs of this kind of task to the task |
3048 * input descriptors describing those inputs for a task with the | 2916 * input descriptors describing those inputs for a task with the |
3049 * given [target]. | 2917 * given [target]. |
3050 */ | 2918 */ |
3051 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 2919 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
3052 LibrarySpecificUnit unit = target; | 2920 LibrarySpecificUnit unit = target; |
3053 return <String, TaskInput>{ | 2921 return <String, TaskInput>{ |
3054 'libraryElement': LIBRARY_ELEMENT9.of(unit.library), | 2922 'libraryElement': LIBRARY_ELEMENT9.of(unit.library), |
3055 UNIT_INPUT: RESOLVED_UNIT12.of(unit), | 2923 UNIT_INPUT: RESOLVED_UNIT11.of(unit), |
3056 CONSTANT_VALUES: | 2924 CONSTANT_VALUES: |
3057 COMPILATION_UNIT_CONSTANTS.of(unit).toListOf(CONSTANT_VALUE), | 2925 COMPILATION_UNIT_CONSTANTS.of(unit).toListOf(CONSTANT_VALUE), |
3058 'constantExpressionsDependencies': | 2926 'constantExpressionsDependencies': |
3059 CONSTANT_EXPRESSIONS_DEPENDENCIES.of(unit).toListOf(CONSTANT_VALUE) | 2927 CONSTANT_EXPRESSIONS_DEPENDENCIES.of(unit).toListOf(CONSTANT_VALUE) |
3060 }; | 2928 }; |
3061 } | 2929 } |
3062 | 2930 |
3063 /** | 2931 /** |
3064 * Create an [EvaluateUnitConstantsTask] based on the given [target] in | 2932 * Create an [EvaluateUnitConstantsTask] based on the given [target] in |
3065 * the given [context]. | 2933 * the given [context]. |
3066 */ | 2934 */ |
3067 static EvaluateUnitConstantsTask createTask( | 2935 static EvaluateUnitConstantsTask createTask( |
3068 AnalysisContext context, AnalysisTarget target) { | 2936 AnalysisContext context, AnalysisTarget target) { |
3069 return new EvaluateUnitConstantsTask(context, target); | 2937 return new EvaluateUnitConstantsTask(context, target); |
3070 } | 2938 } |
3071 } | 2939 } |
3072 | 2940 |
3073 /** | 2941 /** |
3074 * A task that builds [USED_IMPORTED_ELEMENTS] for a unit. | 2942 * A task that builds [USED_IMPORTED_ELEMENTS] for a unit. |
3075 */ | 2943 */ |
3076 class GatherUsedImportedElementsTask extends SourceBasedAnalysisTask { | 2944 class GatherUsedImportedElementsTask extends SourceBasedAnalysisTask { |
3077 /** | 2945 /** |
3078 * The name of the [RESOLVED_UNIT12] input. | 2946 * The name of the [RESOLVED_UNIT11] input. |
3079 */ | 2947 */ |
3080 static const String UNIT_INPUT = 'UNIT_INPUT'; | 2948 static const String UNIT_INPUT = 'UNIT_INPUT'; |
3081 | 2949 |
3082 /** | 2950 /** |
3083 * The task descriptor describing this kind of task. | 2951 * The task descriptor describing this kind of task. |
3084 */ | 2952 */ |
3085 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 2953 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
3086 'GatherUsedImportedElementsTask', | 2954 'GatherUsedImportedElementsTask', |
3087 createTask, | 2955 createTask, |
3088 buildInputs, | 2956 buildInputs, |
(...skipping 23 matching lines...) Expand all Loading... |
3112 outputs[USED_IMPORTED_ELEMENTS] = visitor.usedElements; | 2980 outputs[USED_IMPORTED_ELEMENTS] = visitor.usedElements; |
3113 } | 2981 } |
3114 | 2982 |
3115 /** | 2983 /** |
3116 * Return a map from the names of the inputs of this kind of task to the task | 2984 * Return a map from the names of the inputs of this kind of task to the task |
3117 * input descriptors describing those inputs for a task with the | 2985 * input descriptors describing those inputs for a task with the |
3118 * given [target]. | 2986 * given [target]. |
3119 */ | 2987 */ |
3120 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 2988 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
3121 LibrarySpecificUnit unit = target; | 2989 LibrarySpecificUnit unit = target; |
3122 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT12.of(unit)}; | 2990 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT11.of(unit)}; |
3123 } | 2991 } |
3124 | 2992 |
3125 /** | 2993 /** |
3126 * Create a [GatherUsedImportedElementsTask] based on the given [target] in | 2994 * Create a [GatherUsedImportedElementsTask] based on the given [target] in |
3127 * the given [context]. | 2995 * the given [context]. |
3128 */ | 2996 */ |
3129 static GatherUsedImportedElementsTask createTask( | 2997 static GatherUsedImportedElementsTask createTask( |
3130 AnalysisContext context, AnalysisTarget target) { | 2998 AnalysisContext context, AnalysisTarget target) { |
3131 return new GatherUsedImportedElementsTask(context, target); | 2999 return new GatherUsedImportedElementsTask(context, target); |
3132 } | 3000 } |
3133 } | 3001 } |
3134 | 3002 |
3135 /** | 3003 /** |
3136 * A task that builds [USED_LOCAL_ELEMENTS] for a unit. | 3004 * A task that builds [USED_LOCAL_ELEMENTS] for a unit. |
3137 */ | 3005 */ |
3138 class GatherUsedLocalElementsTask extends SourceBasedAnalysisTask { | 3006 class GatherUsedLocalElementsTask extends SourceBasedAnalysisTask { |
3139 /** | 3007 /** |
3140 * The name of the [RESOLVED_UNIT12] input. | 3008 * The name of the [RESOLVED_UNIT11] input. |
3141 */ | 3009 */ |
3142 static const String UNIT_INPUT = 'UNIT_INPUT'; | 3010 static const String UNIT_INPUT = 'UNIT_INPUT'; |
3143 | 3011 |
3144 /** | 3012 /** |
3145 * The task descriptor describing this kind of task. | 3013 * The task descriptor describing this kind of task. |
3146 */ | 3014 */ |
3147 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 3015 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
3148 'GatherUsedLocalElementsTask', | 3016 'GatherUsedLocalElementsTask', |
3149 createTask, | 3017 createTask, |
3150 buildInputs, | 3018 buildInputs, |
(...skipping 23 matching lines...) Expand all Loading... |
3174 outputs[USED_LOCAL_ELEMENTS] = visitor.usedElements; | 3042 outputs[USED_LOCAL_ELEMENTS] = visitor.usedElements; |
3175 } | 3043 } |
3176 | 3044 |
3177 /** | 3045 /** |
3178 * Return a map from the names of the inputs of this kind of task to the task | 3046 * Return a map from the names of the inputs of this kind of task to the task |
3179 * input descriptors describing those inputs for a task with the | 3047 * input descriptors describing those inputs for a task with the |
3180 * given [target]. | 3048 * given [target]. |
3181 */ | 3049 */ |
3182 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 3050 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
3183 LibrarySpecificUnit unit = target; | 3051 LibrarySpecificUnit unit = target; |
3184 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT12.of(unit)}; | 3052 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT11.of(unit)}; |
3185 } | 3053 } |
3186 | 3054 |
3187 /** | 3055 /** |
3188 * Create a [GatherUsedLocalElementsTask] based on the given [target] in | 3056 * Create a [GatherUsedLocalElementsTask] based on the given [target] in |
3189 * the given [context]. | 3057 * the given [context]. |
3190 */ | 3058 */ |
3191 static GatherUsedLocalElementsTask createTask( | 3059 static GatherUsedLocalElementsTask createTask( |
3192 AnalysisContext context, AnalysisTarget target) { | 3060 AnalysisContext context, AnalysisTarget target) { |
3193 return new GatherUsedLocalElementsTask(context, target); | 3061 return new GatherUsedLocalElementsTask(context, target); |
3194 } | 3062 } |
3195 } | 3063 } |
3196 | 3064 |
3197 /** | 3065 /** |
3198 * A task that generates [HINTS] for a unit. | 3066 * A task that generates [HINTS] for a unit. |
3199 */ | 3067 */ |
3200 class GenerateHintsTask extends SourceBasedAnalysisTask { | 3068 class GenerateHintsTask extends SourceBasedAnalysisTask { |
3201 /** | 3069 /** |
3202 * The name of the [RESOLVED_UNIT12] input. | 3070 * The name of the [RESOLVED_UNIT11] input. |
3203 */ | 3071 */ |
3204 static const String RESOLVED_UNIT_INPUT = 'RESOLVED_UNIT'; | 3072 static const String RESOLVED_UNIT_INPUT = 'RESOLVED_UNIT'; |
3205 | 3073 |
3206 /** | 3074 /** |
3207 * The name of a list of [USED_LOCAL_ELEMENTS] for each library unit input. | 3075 * The name of a list of [USED_LOCAL_ELEMENTS] for each library unit input. |
3208 */ | 3076 */ |
3209 static const String USED_LOCAL_ELEMENTS_INPUT = 'USED_LOCAL_ELEMENTS'; | 3077 static const String USED_LOCAL_ELEMENTS_INPUT = 'USED_LOCAL_ELEMENTS'; |
3210 | 3078 |
3211 /** | 3079 /** |
3212 * The name of a list of [USED_IMPORTED_ELEMENTS] for each library unit input. | 3080 * The name of a list of [USED_IMPORTED_ELEMENTS] for each library unit input. |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3490 * A task that ensures that all of the inferable instance members in a | 3358 * A task that ensures that all of the inferable instance members in a |
3491 * compilation unit have had their type inferred. | 3359 * compilation unit have had their type inferred. |
3492 */ | 3360 */ |
3493 class InferInstanceMembersInUnitTask extends SourceBasedAnalysisTask { | 3361 class InferInstanceMembersInUnitTask extends SourceBasedAnalysisTask { |
3494 /** | 3362 /** |
3495 * The name of the [TYPE_PROVIDER] input. | 3363 * The name of the [TYPE_PROVIDER] input. |
3496 */ | 3364 */ |
3497 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; | 3365 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; |
3498 | 3366 |
3499 /** | 3367 /** |
3500 * The name of the input whose value is the [RESOLVED_UNIT9] for the | 3368 * The name of the input whose value is the [RESOLVED_UNIT8] for the |
3501 * compilation unit. | 3369 * compilation unit. |
3502 */ | 3370 */ |
3503 static const String UNIT_INPUT = 'UNIT_INPUT'; | 3371 static const String UNIT_INPUT = 'UNIT_INPUT'; |
3504 | 3372 |
3505 /** | 3373 /** |
3506 * The task descriptor describing this kind of task. | 3374 * The task descriptor describing this kind of task. |
3507 */ | 3375 */ |
3508 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 3376 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
3509 'InferInstanceMembersInUnitTask', | 3377 'InferInstanceMembersInUnitTask', |
3510 createTask, | 3378 createTask, |
3511 buildInputs, | 3379 buildInputs, |
3512 <ResultDescriptor>[CREATED_RESOLVED_UNIT11, RESOLVED_UNIT11]); | 3380 <ResultDescriptor>[CREATED_RESOLVED_UNIT10, RESOLVED_UNIT10]); |
3513 | 3381 |
3514 /** | 3382 /** |
3515 * Initialize a newly created task to build a library element for the given | 3383 * Initialize a newly created task to build a library element for the given |
3516 * [unit] in the given [context]. | 3384 * [unit] in the given [context]. |
3517 */ | 3385 */ |
3518 InferInstanceMembersInUnitTask( | 3386 InferInstanceMembersInUnitTask( |
3519 InternalAnalysisContext context, LibrarySpecificUnit unit) | 3387 InternalAnalysisContext context, LibrarySpecificUnit unit) |
3520 : super(context, unit); | 3388 : super(context, unit); |
3521 | 3389 |
3522 @override | 3390 @override |
(...skipping 11 matching lines...) Expand all Loading... |
3534 // | 3402 // |
3535 if (context.analysisOptions.strongMode) { | 3403 if (context.analysisOptions.strongMode) { |
3536 InstanceMemberInferrer inferrer = new InstanceMemberInferrer( | 3404 InstanceMemberInferrer inferrer = new InstanceMemberInferrer( |
3537 typeProvider, new InheritanceManager(unit.element.library), | 3405 typeProvider, new InheritanceManager(unit.element.library), |
3538 typeSystem: context.typeSystem); | 3406 typeSystem: context.typeSystem); |
3539 inferrer.inferCompilationUnit(unit.element); | 3407 inferrer.inferCompilationUnit(unit.element); |
3540 } | 3408 } |
3541 // | 3409 // |
3542 // Record outputs. | 3410 // Record outputs. |
3543 // | 3411 // |
3544 outputs[RESOLVED_UNIT11] = unit; | 3412 outputs[RESOLVED_UNIT10] = unit; |
3545 outputs[CREATED_RESOLVED_UNIT11] = true; | 3413 outputs[CREATED_RESOLVED_UNIT10] = true; |
3546 } | 3414 } |
3547 | 3415 |
3548 /** | 3416 /** |
3549 * Return a map from the names of the inputs of this kind of task to the task | 3417 * Return a map from the names of the inputs of this kind of task to the task |
3550 * input descriptors describing those inputs for a task with the given | 3418 * input descriptors describing those inputs for a task with the given |
3551 * [libSource]. | 3419 * [libSource]. |
3552 */ | 3420 */ |
3553 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 3421 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
3554 LibrarySpecificUnit unit = target; | 3422 LibrarySpecificUnit unit = target; |
3555 return <String, TaskInput>{ | 3423 return <String, TaskInput>{ |
3556 UNIT_INPUT: RESOLVED_UNIT10.of(unit), | 3424 UNIT_INPUT: RESOLVED_UNIT9.of(unit), |
3557 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), | 3425 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), |
3558 // In strong mode, add additional dependencies to enforce inference | 3426 // In strong mode, add additional dependencies to enforce inference |
3559 // ordering. | 3427 // ordering. |
3560 | 3428 |
3561 // Require that field re-resolution be complete for all units in the | 3429 // Require that field re-resolution be complete for all units in the |
3562 // current library cycle. | 3430 // current library cycle. |
3563 'orderLibraryCycleTasks': LIBRARY_CYCLE_UNITS.of(unit.library).toList( | 3431 'orderLibraryCycleTasks': LIBRARY_CYCLE_UNITS.of(unit.library).toList( |
3564 (CompilationUnitElement unit) => CREATED_RESOLVED_UNIT10.of( | 3432 (CompilationUnitElement unit) => CREATED_RESOLVED_UNIT9.of( |
3565 new LibrarySpecificUnit( | 3433 new LibrarySpecificUnit( |
3566 (unit as CompilationUnitElementImpl).librarySource, | 3434 (unit as CompilationUnitElementImpl).librarySource, |
3567 unit.source))), | 3435 unit.source))), |
3568 // Require that full inference be complete for all dependencies of the | 3436 // Require that full inference be complete for all dependencies of the |
3569 // current library cycle. | 3437 // current library cycle. |
3570 'orderLibraryCycles': LIBRARY_CYCLE_DEPENDENCIES.of(unit.library).toList( | 3438 'orderLibraryCycles': LIBRARY_CYCLE_DEPENDENCIES.of(unit.library).toList( |
3571 (CompilationUnitElement unit) => CREATED_RESOLVED_UNIT11.of( | 3439 (CompilationUnitElement unit) => CREATED_RESOLVED_UNIT10.of( |
3572 new LibrarySpecificUnit( | 3440 new LibrarySpecificUnit( |
3573 (unit as CompilationUnitElementImpl).librarySource, | 3441 (unit as CompilationUnitElementImpl).librarySource, |
3574 unit.source))) | 3442 unit.source))) |
3575 }; | 3443 }; |
3576 } | 3444 } |
3577 | 3445 |
3578 /** | 3446 /** |
3579 * Create a [InferInstanceMembersInUnitTask] based on the given [target] in | 3447 * Create a [InferInstanceMembersInUnitTask] based on the given [target] in |
3580 * the given [context]. | 3448 * the given [context]. |
3581 */ | 3449 */ |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3665 */ | 3533 */ |
3666 static const String ERRORS_LIST_INPUT = 'INFERRED_VARIABLES_INPUT'; | 3534 static const String ERRORS_LIST_INPUT = 'INFERRED_VARIABLES_INPUT'; |
3667 | 3535 |
3668 /** | 3536 /** |
3669 * The task descriptor describing this kind of task. | 3537 * The task descriptor describing this kind of task. |
3670 */ | 3538 */ |
3671 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 3539 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
3672 'InferStaticVariableTypesInUnitTask', | 3540 'InferStaticVariableTypesInUnitTask', |
3673 createTask, | 3541 createTask, |
3674 buildInputs, <ResultDescriptor>[ | 3542 buildInputs, <ResultDescriptor>[ |
3675 CREATED_RESOLVED_UNIT9, | 3543 CREATED_RESOLVED_UNIT8, |
3676 RESOLVED_UNIT9, | 3544 RESOLVED_UNIT8, |
3677 STATIC_VARIABLE_RESOLUTION_ERRORS_IN_UNIT | 3545 STATIC_VARIABLE_RESOLUTION_ERRORS_IN_UNIT |
3678 ]); | 3546 ]); |
3679 | 3547 |
3680 /** | 3548 /** |
3681 * Initialize a newly created task to build a library element for the given | 3549 * Initialize a newly created task to build a library element for the given |
3682 * [unit] in the given [context]. | 3550 * [unit] in the given [context]. |
3683 */ | 3551 */ |
3684 InferStaticVariableTypesInUnitTask( | 3552 InferStaticVariableTypesInUnitTask( |
3685 InternalAnalysisContext context, LibrarySpecificUnit unit) | 3553 InternalAnalysisContext context, LibrarySpecificUnit unit) |
3686 : super(context, unit); | 3554 : super(context, unit); |
3687 | 3555 |
3688 @override | 3556 @override |
3689 TaskDescriptor get descriptor => DESCRIPTOR; | 3557 TaskDescriptor get descriptor => DESCRIPTOR; |
3690 | 3558 |
3691 @override | 3559 @override |
3692 void internalPerform() { | 3560 void internalPerform() { |
3693 // | 3561 // |
3694 // Prepare inputs. | 3562 // Prepare inputs. |
3695 // | 3563 // |
3696 CompilationUnit unit = getRequiredInput(UNIT_INPUT); | 3564 CompilationUnit unit = getRequiredInput(UNIT_INPUT); |
3697 List<List<AnalysisError>> errorLists = getRequiredInput(ERRORS_LIST_INPUT); | 3565 List<List<AnalysisError>> errorLists = getRequiredInput(ERRORS_LIST_INPUT); |
3698 // | 3566 // |
3699 // Record outputs. There is no additional work to be done at this time | 3567 // Record outputs. There is no additional work to be done at this time |
3700 // because the work has implicitly been done by virtue of the task model | 3568 // because the work has implicitly been done by virtue of the task model |
3701 // preparing all of the inputs. | 3569 // preparing all of the inputs. |
3702 // | 3570 // |
3703 outputs[RESOLVED_UNIT9] = unit; | 3571 outputs[RESOLVED_UNIT8] = unit; |
3704 outputs[CREATED_RESOLVED_UNIT9] = true; | 3572 outputs[CREATED_RESOLVED_UNIT8] = true; |
3705 outputs[STATIC_VARIABLE_RESOLUTION_ERRORS_IN_UNIT] = | 3573 outputs[STATIC_VARIABLE_RESOLUTION_ERRORS_IN_UNIT] = |
3706 AnalysisError.mergeLists(errorLists); | 3574 AnalysisError.mergeLists(errorLists); |
3707 } | 3575 } |
3708 | 3576 |
3709 /** | 3577 /** |
3710 * Return a map from the names of the inputs of this kind of task to the task | 3578 * Return a map from the names of the inputs of this kind of task to the task |
3711 * input descriptors describing those inputs for a task with the given | 3579 * input descriptors describing those inputs for a task with the given |
3712 * [libSource]. | 3580 * [libSource]. |
3713 */ | 3581 */ |
3714 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 3582 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
3715 LibrarySpecificUnit unit = target; | 3583 LibrarySpecificUnit unit = target; |
3716 return <String, TaskInput>{ | 3584 return <String, TaskInput>{ |
3717 'inferredTypes': INFERABLE_STATIC_VARIABLES_IN_UNIT | 3585 'inferredTypes': INFERABLE_STATIC_VARIABLES_IN_UNIT |
3718 .of(unit) | 3586 .of(unit) |
3719 .toListOf(INFERRED_STATIC_VARIABLE), | 3587 .toListOf(INFERRED_STATIC_VARIABLE), |
3720 ERRORS_LIST_INPUT: INFERABLE_STATIC_VARIABLES_IN_UNIT | 3588 ERRORS_LIST_INPUT: INFERABLE_STATIC_VARIABLES_IN_UNIT |
3721 .of(unit) | 3589 .of(unit) |
3722 .toListOf(STATIC_VARIABLE_RESOLUTION_ERRORS), | 3590 .toListOf(STATIC_VARIABLE_RESOLUTION_ERRORS), |
3723 UNIT_INPUT: RESOLVED_UNIT8.of(unit) | 3591 UNIT_INPUT: RESOLVED_UNIT7.of(unit) |
3724 }; | 3592 }; |
3725 } | 3593 } |
3726 | 3594 |
3727 /** | 3595 /** |
3728 * Create a [InferStaticVariableTypesInUnitTask] based on the given [target] | 3596 * Create a [InferStaticVariableTypesInUnitTask] based on the given [target] |
3729 * in the given [context]. | 3597 * in the given [context]. |
3730 */ | 3598 */ |
3731 static InferStaticVariableTypesInUnitTask createTask( | 3599 static InferStaticVariableTypesInUnitTask createTask( |
3732 AnalysisContext context, AnalysisTarget target) { | 3600 AnalysisContext context, AnalysisTarget target) { |
3733 return new InferStaticVariableTypesInUnitTask(context, target); | 3601 return new InferStaticVariableTypesInUnitTask(context, target); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3841 */ | 3709 */ |
3842 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 3710 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
3843 VariableElement variable = target; | 3711 VariableElement variable = target; |
3844 LibrarySpecificUnit unit = | 3712 LibrarySpecificUnit unit = |
3845 new LibrarySpecificUnit(variable.library.source, variable.source); | 3713 new LibrarySpecificUnit(variable.library.source, variable.source); |
3846 return <String, TaskInput>{ | 3714 return <String, TaskInput>{ |
3847 DEPENDENCIES_INPUT: INFERABLE_STATIC_VARIABLE_DEPENDENCIES | 3715 DEPENDENCIES_INPUT: INFERABLE_STATIC_VARIABLE_DEPENDENCIES |
3848 .of(variable) | 3716 .of(variable) |
3849 .toListOf(INFERRED_STATIC_VARIABLE), | 3717 .toListOf(INFERRED_STATIC_VARIABLE), |
3850 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), | 3718 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), |
3851 UNIT_INPUT: RESOLVED_UNIT8.of(unit), | 3719 UNIT_INPUT: RESOLVED_UNIT7.of(unit), |
3852 // In strong mode, add additional dependencies to enforce inference | 3720 // In strong mode, add additional dependencies to enforce inference |
3853 // ordering. | 3721 // ordering. |
3854 | 3722 |
3855 // Require that full inference be complete for all dependencies of the | 3723 // Require that full inference be complete for all dependencies of the |
3856 // current library cycle. | 3724 // current library cycle. |
3857 'orderLibraryCycles': LIBRARY_CYCLE_DEPENDENCIES.of(unit.library).toList( | 3725 'orderLibraryCycles': LIBRARY_CYCLE_DEPENDENCIES.of(unit.library).toList( |
3858 (CompilationUnitElement unit) => CREATED_RESOLVED_UNIT11.of( | 3726 (CompilationUnitElement unit) => CREATED_RESOLVED_UNIT10.of( |
3859 new LibrarySpecificUnit( | 3727 new LibrarySpecificUnit( |
3860 (unit as CompilationUnitElementImpl).librarySource, | 3728 (unit as CompilationUnitElementImpl).librarySource, |
3861 unit.source))) | 3729 unit.source))) |
3862 }; | 3730 }; |
3863 } | 3731 } |
3864 | 3732 |
3865 /** | 3733 /** |
3866 * Create a [InferStaticVariableTypeTask] based on the given [target] in the | 3734 * Create a [InferStaticVariableTypeTask] based on the given [target] in the |
3867 * given [context]. | 3735 * given [context]. |
3868 */ | 3736 */ |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4308 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; | 4176 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; |
4309 | 4177 |
4310 /** | 4178 /** |
4311 * The task descriptor describing this kind of task. | 4179 * The task descriptor describing this kind of task. |
4312 */ | 4180 */ |
4313 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 4181 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
4314 'PartiallyResolveUnitReferencesTask', | 4182 'PartiallyResolveUnitReferencesTask', |
4315 createTask, | 4183 createTask, |
4316 buildInputs, <ResultDescriptor>[ | 4184 buildInputs, <ResultDescriptor>[ |
4317 INFERABLE_STATIC_VARIABLES_IN_UNIT, | 4185 INFERABLE_STATIC_VARIABLES_IN_UNIT, |
4318 PROPAGABLE_VARIABLES_IN_UNIT, | |
4319 CREATED_RESOLVED_UNIT7, | 4186 CREATED_RESOLVED_UNIT7, |
4320 RESOLVED_UNIT7 | 4187 RESOLVED_UNIT7 |
4321 ]); | 4188 ]); |
4322 | 4189 |
4323 PartiallyResolveUnitReferencesTask( | 4190 PartiallyResolveUnitReferencesTask( |
4324 InternalAnalysisContext context, AnalysisTarget target) | 4191 InternalAnalysisContext context, AnalysisTarget target) |
4325 : super(context, target); | 4192 : super(context, target); |
4326 | 4193 |
4327 @override | 4194 @override |
4328 TaskDescriptor get descriptor => DESCRIPTOR; | 4195 TaskDescriptor get descriptor => DESCRIPTOR; |
(...skipping 14 matching lines...) Expand all Loading... |
4343 unitElement.source, typeProvider, AnalysisErrorListener.NULL_LISTENER); | 4210 unitElement.source, typeProvider, AnalysisErrorListener.NULL_LISTENER); |
4344 unit.accept(visitor); | 4211 unit.accept(visitor); |
4345 // | 4212 // |
4346 // Record outputs. | 4213 // Record outputs. |
4347 // | 4214 // |
4348 if (context.analysisOptions.strongMode) { | 4215 if (context.analysisOptions.strongMode) { |
4349 outputs[INFERABLE_STATIC_VARIABLES_IN_UNIT] = visitor.staticVariables; | 4216 outputs[INFERABLE_STATIC_VARIABLES_IN_UNIT] = visitor.staticVariables; |
4350 } else { | 4217 } else { |
4351 outputs[INFERABLE_STATIC_VARIABLES_IN_UNIT] = VariableElement.EMPTY_LIST; | 4218 outputs[INFERABLE_STATIC_VARIABLES_IN_UNIT] = VariableElement.EMPTY_LIST; |
4352 } | 4219 } |
4353 outputs[PROPAGABLE_VARIABLES_IN_UNIT] = visitor.propagableVariables; | |
4354 outputs[RESOLVED_UNIT7] = unit; | 4220 outputs[RESOLVED_UNIT7] = unit; |
4355 outputs[CREATED_RESOLVED_UNIT7] = true; | 4221 outputs[CREATED_RESOLVED_UNIT7] = true; |
4356 } | 4222 } |
4357 | 4223 |
4358 /** | 4224 /** |
4359 * Return a map from the names of the inputs of this kind of task to the task | 4225 * Return a map from the names of the inputs of this kind of task to the task |
4360 * input descriptors describing those inputs for a task with the | 4226 * input descriptors describing those inputs for a task with the |
4361 * given [target]. | 4227 * given [target]. |
4362 */ | 4228 */ |
4363 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 4229 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
4364 LibrarySpecificUnit unit = target; | 4230 LibrarySpecificUnit unit = target; |
4365 return <String, TaskInput>{ | 4231 return <String, TaskInput>{ |
4366 'fullyBuiltLibraryElements': READY_LIBRARY_ELEMENT6.of(unit.library), | 4232 'fullyBuiltLibraryElements': READY_LIBRARY_ELEMENT6.of(unit.library), |
4367 LIBRARY_INPUT: LIBRARY_ELEMENT6.of(unit.library), | 4233 LIBRARY_INPUT: LIBRARY_ELEMENT6.of(unit.library), |
4368 UNIT_INPUT: RESOLVED_UNIT6.of(unit), | 4234 UNIT_INPUT: RESOLVED_UNIT6.of(unit), |
4369 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), | 4235 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), |
4370 // In strong mode, add additional dependencies to enforce inference | 4236 // In strong mode, add additional dependencies to enforce inference |
4371 // ordering. | 4237 // ordering. |
4372 | 4238 |
4373 // Require that full inference be complete for all dependencies of the | 4239 // Require that full inference be complete for all dependencies of the |
4374 // current library cycle. | 4240 // current library cycle. |
4375 'orderLibraryCycles': LIBRARY_CYCLE_DEPENDENCIES.of(unit.library).toList( | 4241 'orderLibraryCycles': LIBRARY_CYCLE_DEPENDENCIES.of(unit.library).toList( |
4376 (CompilationUnitElement unit) => CREATED_RESOLVED_UNIT11.of( | 4242 (CompilationUnitElement unit) => CREATED_RESOLVED_UNIT10.of( |
4377 new LibrarySpecificUnit( | 4243 new LibrarySpecificUnit( |
4378 (unit as CompilationUnitElementImpl).librarySource, | 4244 (unit as CompilationUnitElementImpl).librarySource, |
4379 unit.source))) | 4245 unit.source))) |
4380 }; | 4246 }; |
4381 } | 4247 } |
4382 | 4248 |
4383 /** | 4249 /** |
4384 * Create a [PartiallyResolveUnitReferencesTask] based on the given [target] | 4250 * Create a [PartiallyResolveUnitReferencesTask] based on the given [target] |
4385 * in the given [context]. | 4251 * in the given [context]. |
4386 */ | 4252 */ |
4387 static PartiallyResolveUnitReferencesTask createTask( | 4253 static PartiallyResolveUnitReferencesTask createTask( |
4388 AnalysisContext context, AnalysisTarget target) { | 4254 AnalysisContext context, AnalysisTarget target) { |
4389 return new PartiallyResolveUnitReferencesTask(context, target); | 4255 return new PartiallyResolveUnitReferencesTask(context, target); |
4390 } | 4256 } |
4391 } | 4257 } |
4392 | 4258 |
4393 /** | 4259 /** |
4394 * An artificial task that does nothing except to force propagated types for | |
4395 * all propagable variables in the import/export closure a library. | |
4396 */ | |
4397 class PropagateVariableTypesInLibraryClosureTask | |
4398 extends SourceBasedAnalysisTask { | |
4399 /** | |
4400 * The name of the [LIBRARY_ELEMENT7] input. | |
4401 */ | |
4402 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; | |
4403 | |
4404 /** | |
4405 * The task descriptor describing this kind of task. | |
4406 */ | |
4407 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | |
4408 'PropagateVariableTypesInLibraryClosureTask', | |
4409 createTask, | |
4410 buildInputs, | |
4411 <ResultDescriptor>[LIBRARY_ELEMENT8]); | |
4412 | |
4413 PropagateVariableTypesInLibraryClosureTask( | |
4414 InternalAnalysisContext context, AnalysisTarget target) | |
4415 : super(context, target); | |
4416 | |
4417 @override | |
4418 TaskDescriptor get descriptor => DESCRIPTOR; | |
4419 | |
4420 @override | |
4421 void internalPerform() { | |
4422 LibraryElement library = getRequiredInput(LIBRARY_INPUT); | |
4423 outputs[LIBRARY_ELEMENT8] = library; | |
4424 } | |
4425 | |
4426 /** | |
4427 * Return a map from the names of the inputs of this kind of task to the task | |
4428 * input descriptors describing those inputs for a task with the | |
4429 * given [target]. | |
4430 */ | |
4431 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | |
4432 Source source = target; | |
4433 return <String, TaskInput>{ | |
4434 'readyForClosure': READY_LIBRARY_ELEMENT7.of(source), | |
4435 LIBRARY_INPUT: LIBRARY_ELEMENT7.of(source), | |
4436 }; | |
4437 } | |
4438 | |
4439 /** | |
4440 * Create a [PropagateVariableTypesInLibraryClosureTask] based on the given | |
4441 * [target] in the given [context]. | |
4442 */ | |
4443 static PropagateVariableTypesInLibraryClosureTask createTask( | |
4444 AnalysisContext context, AnalysisTarget target) { | |
4445 return new PropagateVariableTypesInLibraryClosureTask(context, target); | |
4446 } | |
4447 } | |
4448 | |
4449 /** | |
4450 * An artificial task that does nothing except to force propagated types for | |
4451 * all propagable variables in the defining and part units of a library. | |
4452 */ | |
4453 class PropagateVariableTypesInLibraryTask extends SourceBasedAnalysisTask { | |
4454 /** | |
4455 * The name of the [LIBRARY_ELEMENT6] input. | |
4456 */ | |
4457 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; | |
4458 | |
4459 /** | |
4460 * The task descriptor describing this kind of task. | |
4461 */ | |
4462 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | |
4463 'PropagateVariableTypesInLibraryTask', | |
4464 createTask, | |
4465 buildInputs, | |
4466 <ResultDescriptor>[LIBRARY_ELEMENT7]); | |
4467 | |
4468 PropagateVariableTypesInLibraryTask( | |
4469 InternalAnalysisContext context, AnalysisTarget target) | |
4470 : super(context, target); | |
4471 | |
4472 @override | |
4473 TaskDescriptor get descriptor => DESCRIPTOR; | |
4474 | |
4475 @override | |
4476 void internalPerform() { | |
4477 LibraryElement library = getRequiredInput(LIBRARY_INPUT); | |
4478 outputs[LIBRARY_ELEMENT7] = library; | |
4479 } | |
4480 | |
4481 /** | |
4482 * Return a map from the names of the inputs of this kind of task to the task | |
4483 * input descriptors describing those inputs for a task with the | |
4484 * given [target]. | |
4485 */ | |
4486 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | |
4487 Source source = target; | |
4488 return <String, TaskInput>{ | |
4489 'propagatedVariableTypesInUnits': | |
4490 LIBRARY_SPECIFIC_UNITS.of(source).toListOf(RESOLVED_UNIT8), | |
4491 LIBRARY_INPUT: LIBRARY_ELEMENT6.of(source), | |
4492 }; | |
4493 } | |
4494 | |
4495 /** | |
4496 * Create a [PropagateVariableTypesInLibraryTask] based on the given [target] | |
4497 * in the given [context]. | |
4498 */ | |
4499 static PropagateVariableTypesInLibraryTask createTask( | |
4500 AnalysisContext context, AnalysisTarget target) { | |
4501 return new PropagateVariableTypesInLibraryTask(context, target); | |
4502 } | |
4503 } | |
4504 | |
4505 /** | |
4506 * A task that ensures that all of the propagable variables in a compilation | |
4507 * unit have had their type propagated. | |
4508 */ | |
4509 class PropagateVariableTypesInUnitTask extends SourceBasedAnalysisTask { | |
4510 /** | |
4511 * The name of the input whose value is the [RESOLVED_UNIT7] for the | |
4512 * compilation unit. | |
4513 */ | |
4514 static const String UNIT_INPUT = 'UNIT_INPUT'; | |
4515 | |
4516 /** | |
4517 * The task descriptor describing this kind of task. | |
4518 */ | |
4519 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | |
4520 'PropagateVariableTypesInUnitTask', | |
4521 createTask, | |
4522 buildInputs, | |
4523 <ResultDescriptor>[CREATED_RESOLVED_UNIT8, RESOLVED_UNIT8]); | |
4524 | |
4525 PropagateVariableTypesInUnitTask( | |
4526 InternalAnalysisContext context, LibrarySpecificUnit unit) | |
4527 : super(context, unit); | |
4528 | |
4529 @override | |
4530 TaskDescriptor get descriptor => DESCRIPTOR; | |
4531 | |
4532 @override | |
4533 void internalPerform() { | |
4534 // | |
4535 // Prepare inputs. | |
4536 // | |
4537 CompilationUnit unit = getRequiredInput(UNIT_INPUT); | |
4538 // | |
4539 // Record outputs. There is no additional work to be done at this time | |
4540 // because the work has implicitly been done by virtue of the task model | |
4541 // preparing all of the inputs. | |
4542 // | |
4543 outputs[RESOLVED_UNIT8] = unit; | |
4544 outputs[CREATED_RESOLVED_UNIT8] = true; | |
4545 } | |
4546 | |
4547 /** | |
4548 * Return a map from the names of the inputs of this kind of task to the task | |
4549 * input descriptors describing those inputs for a task with the given | |
4550 * [target]. | |
4551 */ | |
4552 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | |
4553 LibrarySpecificUnit unit = target; | |
4554 return <String, TaskInput>{ | |
4555 'variables': | |
4556 PROPAGABLE_VARIABLES_IN_UNIT.of(unit).toListOf(PROPAGATED_VARIABLE), | |
4557 UNIT_INPUT: RESOLVED_UNIT7.of(unit) | |
4558 }; | |
4559 } | |
4560 | |
4561 /** | |
4562 * Create a [PropagateVariableTypesInUnitTask] based on the given [target] | |
4563 * in the given [context]. | |
4564 */ | |
4565 static PropagateVariableTypesInUnitTask createTask( | |
4566 AnalysisContext context, AnalysisTarget target) { | |
4567 return new PropagateVariableTypesInUnitTask(context, target); | |
4568 } | |
4569 } | |
4570 | |
4571 /** | |
4572 * A task that computes the propagated type of an propagable variable and | |
4573 * stores it in the element model. | |
4574 */ | |
4575 class PropagateVariableTypeTask extends InferStaticVariableTask { | |
4576 /** | |
4577 * The name of the [TYPE_PROVIDER] input. | |
4578 */ | |
4579 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; | |
4580 | |
4581 /** | |
4582 * The name of the [RESOLVED_UNIT7] input. | |
4583 */ | |
4584 static const String UNIT_INPUT = 'UNIT_INPUT'; | |
4585 | |
4586 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | |
4587 'PropagateVariableTypeTask', | |
4588 createTask, | |
4589 buildInputs, | |
4590 <ResultDescriptor>[PROPAGATED_VARIABLE]); | |
4591 | |
4592 PropagateVariableTypeTask( | |
4593 InternalAnalysisContext context, VariableElement variable) | |
4594 : super(context, variable); | |
4595 | |
4596 @override | |
4597 TaskDescriptor get descriptor => DESCRIPTOR; | |
4598 | |
4599 @override | |
4600 bool get handlesDependencyCycles => true; | |
4601 | |
4602 @override | |
4603 void internalPerform() { | |
4604 // | |
4605 // Prepare inputs. | |
4606 // | |
4607 PropertyInducingElementImpl variable = target; | |
4608 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); | |
4609 CompilationUnit unit = getRequiredInput(UNIT_INPUT); | |
4610 | |
4611 // If we're not in a dependency cycle, and we have no type annotation, | |
4612 // re-resolve the right hand side and do propagation. | |
4613 if (dependencyCycle == null && variable.hasImplicitType) { | |
4614 VariableDeclaration declaration = getDeclaration(unit); | |
4615 // | |
4616 // Re-resolve the variable's initializer with the propagated types of | |
4617 // other variables. | |
4618 // | |
4619 Expression initializer = declaration.initializer; | |
4620 ResolutionContext resolutionContext = ResolutionContextBuilder.contextFor( | |
4621 initializer, AnalysisErrorListener.NULL_LISTENER); | |
4622 ResolverVisitor visitor = new ResolverVisitor(variable.library, | |
4623 variable.source, typeProvider, AnalysisErrorListener.NULL_LISTENER, | |
4624 nameScope: resolutionContext.scope); | |
4625 if (resolutionContext.enclosingClassDeclaration != null) { | |
4626 visitor.prepareToResolveMembersInClass( | |
4627 resolutionContext.enclosingClassDeclaration); | |
4628 } | |
4629 visitor.initForIncrementalResolution(); | |
4630 initializer.accept(visitor); | |
4631 // | |
4632 // Record the type of the variable. | |
4633 // | |
4634 DartType newType = initializer.bestType; | |
4635 if (newType != null && !newType.isBottom && !newType.isDynamic) { | |
4636 variable.propagatedType = newType; | |
4637 } | |
4638 } | |
4639 // | |
4640 // Record outputs. | |
4641 // | |
4642 outputs[PROPAGATED_VARIABLE] = variable; | |
4643 } | |
4644 | |
4645 /** | |
4646 * Return a map from the names of the inputs of this kind of task to the task | |
4647 * input descriptors describing those inputs for a task with the given | |
4648 * [target]. | |
4649 */ | |
4650 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | |
4651 VariableElement variable = target; | |
4652 if (variable.library == null) { | |
4653 StringBuffer buffer = new StringBuffer(); | |
4654 buffer.write( | |
4655 'PropagateVariableTypeTask building inputs for a variable with no libr
ary. Variable name = "'); | |
4656 buffer.write(variable.name); | |
4657 buffer.write('". Path = '); | |
4658 (variable as ElementImpl).appendPathTo(buffer); | |
4659 throw new AnalysisException(buffer.toString()); | |
4660 } | |
4661 LibrarySpecificUnit unit = | |
4662 new LibrarySpecificUnit(variable.library.source, variable.source); | |
4663 return <String, TaskInput>{ | |
4664 'dependencies': PROPAGABLE_VARIABLE_DEPENDENCIES | |
4665 .of(variable) | |
4666 .toListOf(PROPAGATED_VARIABLE), | |
4667 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), | |
4668 UNIT_INPUT: RESOLVED_UNIT7.of(unit), | |
4669 }; | |
4670 } | |
4671 | |
4672 /** | |
4673 * Create a [PropagateVariableTypeTask] based on the given [target] in the | |
4674 * given [context]. | |
4675 */ | |
4676 static PropagateVariableTypeTask createTask( | |
4677 AnalysisContext context, AnalysisTarget target) { | |
4678 return new PropagateVariableTypeTask(context, target); | |
4679 } | |
4680 } | |
4681 | |
4682 /** | |
4683 * A task that ensures that [LIBRARY_ELEMENT2] is ready for the target library | 4260 * A task that ensures that [LIBRARY_ELEMENT2] is ready for the target library |
4684 * source and its import/export closure. | 4261 * source and its import/export closure. |
4685 */ | 4262 */ |
4686 class ReadyLibraryElement2Task extends SourceBasedAnalysisTask { | 4263 class ReadyLibraryElement2Task extends SourceBasedAnalysisTask { |
4687 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 4264 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
4688 'ReadyLibraryElement2Task', | 4265 'ReadyLibraryElement2Task', |
4689 createTask, | 4266 createTask, |
4690 buildInputs, | 4267 buildInputs, |
4691 <ResultDescriptor>[READY_LIBRARY_ELEMENT2]); | 4268 <ResultDescriptor>[READY_LIBRARY_ELEMENT2]); |
4692 | 4269 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4762 static ReadyLibraryElement5Task createTask( | 4339 static ReadyLibraryElement5Task createTask( |
4763 AnalysisContext context, AnalysisTarget target) { | 4340 AnalysisContext context, AnalysisTarget target) { |
4764 return new ReadyLibraryElement5Task(context, target); | 4341 return new ReadyLibraryElement5Task(context, target); |
4765 } | 4342 } |
4766 } | 4343 } |
4767 | 4344 |
4768 /** | 4345 /** |
4769 * A task that ensures that [LIBRARY_ELEMENT7] is ready for the target library | 4346 * A task that ensures that [LIBRARY_ELEMENT7] is ready for the target library |
4770 * source and its import/export closure. | 4347 * source and its import/export closure. |
4771 */ | 4348 */ |
4772 class ReadyLibraryElement6Task extends SourceBasedAnalysisTask { | 4349 class ReadyLibraryElement7Task extends SourceBasedAnalysisTask { |
4773 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 4350 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
4774 'ReadyLibraryElement6Task', | 4351 'ReadyLibraryElement7Task', |
4775 createTask, | 4352 createTask, |
4776 buildInputs, | 4353 buildInputs, |
4777 <ResultDescriptor>[READY_LIBRARY_ELEMENT7]); | 4354 <ResultDescriptor>[READY_LIBRARY_ELEMENT7]); |
4778 | 4355 |
4779 ReadyLibraryElement6Task( | 4356 ReadyLibraryElement7Task( |
4780 InternalAnalysisContext context, AnalysisTarget target) | 4357 InternalAnalysisContext context, AnalysisTarget target) |
4781 : super(context, target); | 4358 : super(context, target); |
4782 | 4359 |
4783 @override | 4360 @override |
4784 TaskDescriptor get descriptor => DESCRIPTOR; | 4361 TaskDescriptor get descriptor => DESCRIPTOR; |
4785 | 4362 |
4786 @override | 4363 @override |
4787 bool get handlesDependencyCycles => true; | 4364 bool get handlesDependencyCycles => true; |
4788 | 4365 |
4789 @override | 4366 @override |
4790 void internalPerform() { | 4367 void internalPerform() { |
4791 outputs[READY_LIBRARY_ELEMENT7] = true; | 4368 outputs[READY_LIBRARY_ELEMENT7] = true; |
4792 } | 4369 } |
4793 | 4370 |
4794 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 4371 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
4795 Source source = target; | 4372 Source source = target; |
4796 return <String, TaskInput>{ | 4373 return <String, TaskInput>{ |
4797 'thisLibraryElementReady': LIBRARY_ELEMENT7.of(source), | 4374 'thisLibraryElementReady': LIBRARY_ELEMENT7.of(source), |
4798 'directlyImportedLibrariesReady': | 4375 'directlyImportedLibrariesReady': |
4799 IMPORTED_LIBRARIES.of(source).toListOf(READY_LIBRARY_ELEMENT7), | 4376 IMPORTED_LIBRARIES.of(source).toListOf(READY_LIBRARY_ELEMENT7), |
4800 'directlyExportedLibrariesReady': | 4377 'directlyExportedLibrariesReady': |
4801 EXPORTED_LIBRARIES.of(source).toListOf(READY_LIBRARY_ELEMENT7), | 4378 EXPORTED_LIBRARIES.of(source).toListOf(READY_LIBRARY_ELEMENT7), |
4802 }; | 4379 }; |
4803 } | 4380 } |
4804 | 4381 |
4805 static ReadyLibraryElement6Task createTask( | 4382 static ReadyLibraryElement7Task createTask( |
4806 AnalysisContext context, AnalysisTarget target) { | 4383 AnalysisContext context, AnalysisTarget target) { |
4807 return new ReadyLibraryElement6Task(context, target); | 4384 return new ReadyLibraryElement7Task(context, target); |
4808 } | 4385 } |
4809 } | 4386 } |
4810 | 4387 |
4811 /** | 4388 /** |
4812 * A task that ensures that [RESOLVED_UNIT] is ready for every unit of the | 4389 * A task that ensures that [RESOLVED_UNIT] is ready for every unit of the |
4813 * target library source and its import/export closure. | 4390 * target library source and its import/export closure. |
4814 */ | 4391 */ |
4815 class ReadyResolvedUnitTask extends SourceBasedAnalysisTask { | 4392 class ReadyResolvedUnitTask extends SourceBasedAnalysisTask { |
4816 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 4393 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
4817 'ReadyResolvedUnitTask', | 4394 'ReadyResolvedUnitTask', |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5286 CompilationUnitElementImpl unit = target | 4863 CompilationUnitElementImpl unit = target |
5287 .getAncestor((Element element) => element is CompilationUnitElement); | 4864 .getAncestor((Element element) => element is CompilationUnitElement); |
5288 librarySource = unit.librarySource; | 4865 librarySource = unit.librarySource; |
5289 } else if (target is ElementAnnotationImpl) { | 4866 } else if (target is ElementAnnotationImpl) { |
5290 librarySource = target.librarySource; | 4867 librarySource = target.librarySource; |
5291 } else { | 4868 } else { |
5292 throw new AnalysisException( | 4869 throw new AnalysisException( |
5293 'Cannot build inputs for a ${target.runtimeType}'); | 4870 'Cannot build inputs for a ${target.runtimeType}'); |
5294 } | 4871 } |
5295 return <String, TaskInput>{ | 4872 return <String, TaskInput>{ |
5296 'createdResolvedUnit': CREATED_RESOLVED_UNIT12 | 4873 'createdResolvedUnit': CREATED_RESOLVED_UNIT11 |
5297 .of(new LibrarySpecificUnit(librarySource, target.source)) | 4874 .of(new LibrarySpecificUnit(librarySource, target.source)) |
5298 }; | 4875 }; |
5299 } | 4876 } |
5300 | 4877 |
5301 /** | 4878 /** |
5302 * Create a [ResolveConstantExpressionTask] based on the given [target] in | 4879 * Create a [ResolveConstantExpressionTask] based on the given [target] in |
5303 * the given [context]. | 4880 * the given [context]. |
5304 */ | 4881 */ |
5305 static ResolveConstantExpressionTask createTask( | 4882 static ResolveConstantExpressionTask createTask( |
5306 AnalysisContext context, AnalysisTarget target) { | 4883 AnalysisContext context, AnalysisTarget target) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5376 * Create a [ResolveDirectiveElementsTask] based on the given [target] in | 4953 * Create a [ResolveDirectiveElementsTask] based on the given [target] in |
5377 * the given [context]. | 4954 * the given [context]. |
5378 */ | 4955 */ |
5379 static ResolveDirectiveElementsTask createTask( | 4956 static ResolveDirectiveElementsTask createTask( |
5380 AnalysisContext context, AnalysisTarget target) { | 4957 AnalysisContext context, AnalysisTarget target) { |
5381 return new ResolveDirectiveElementsTask(context, target); | 4958 return new ResolveDirectiveElementsTask(context, target); |
5382 } | 4959 } |
5383 } | 4960 } |
5384 | 4961 |
5385 /** | 4962 /** |
| 4963 * An artificial task that does nothing except to force [LIBRARY_ELEMENT7] for |
| 4964 * the target library and its import/export closure. |
| 4965 */ |
| 4966 class ResolvedUnit7InLibraryClosureTask extends SourceBasedAnalysisTask { |
| 4967 /** |
| 4968 * The name of the [LIBRARY_ELEMENT7] input. |
| 4969 */ |
| 4970 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; |
| 4971 |
| 4972 /** |
| 4973 * The task descriptor describing this kind of task. |
| 4974 */ |
| 4975 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 4976 'ResolvedUnit7InLibraryClosureTask', |
| 4977 createTask, |
| 4978 buildInputs, |
| 4979 <ResultDescriptor>[LIBRARY_ELEMENT8]); |
| 4980 |
| 4981 ResolvedUnit7InLibraryClosureTask( |
| 4982 InternalAnalysisContext context, AnalysisTarget target) |
| 4983 : super(context, target); |
| 4984 |
| 4985 @override |
| 4986 TaskDescriptor get descriptor => DESCRIPTOR; |
| 4987 |
| 4988 @override |
| 4989 void internalPerform() { |
| 4990 LibraryElement library = getRequiredInput(LIBRARY_INPUT); |
| 4991 outputs[LIBRARY_ELEMENT8] = library; |
| 4992 } |
| 4993 |
| 4994 /** |
| 4995 * Return a map from the names of the inputs of this kind of task to the task |
| 4996 * input descriptors describing those inputs for a task with the |
| 4997 * given [target]. |
| 4998 */ |
| 4999 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 5000 Source source = target; |
| 5001 return <String, TaskInput>{ |
| 5002 'readyForClosure': READY_LIBRARY_ELEMENT7.of(source), |
| 5003 LIBRARY_INPUT: LIBRARY_ELEMENT7.of(source), |
| 5004 }; |
| 5005 } |
| 5006 |
| 5007 /** |
| 5008 * Create a [ResolvedUnit7InLibraryClosureTask] based on the given |
| 5009 * [target] in the given [context]. |
| 5010 */ |
| 5011 static ResolvedUnit7InLibraryClosureTask createTask( |
| 5012 AnalysisContext context, AnalysisTarget target) { |
| 5013 return new ResolvedUnit7InLibraryClosureTask(context, target); |
| 5014 } |
| 5015 } |
| 5016 |
| 5017 /** |
| 5018 * An artificial task that does nothing except to force [LIBRARY_ELEMENT6] and |
| 5019 * [RESOLVED_UNIT7] in the defining and part units of a library. |
| 5020 */ |
| 5021 class ResolvedUnit7InLibraryTask extends SourceBasedAnalysisTask { |
| 5022 /** |
| 5023 * The name of the [LIBRARY_ELEMENT6] input. |
| 5024 */ |
| 5025 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; |
| 5026 |
| 5027 /** |
| 5028 * The task descriptor describing this kind of task. |
| 5029 */ |
| 5030 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 5031 'ResolvedUnit7InLibraryTask', |
| 5032 createTask, |
| 5033 buildInputs, |
| 5034 <ResultDescriptor>[LIBRARY_ELEMENT7]); |
| 5035 |
| 5036 ResolvedUnit7InLibraryTask( |
| 5037 InternalAnalysisContext context, AnalysisTarget target) |
| 5038 : super(context, target); |
| 5039 |
| 5040 @override |
| 5041 TaskDescriptor get descriptor => DESCRIPTOR; |
| 5042 |
| 5043 @override |
| 5044 void internalPerform() { |
| 5045 LibraryElement library = getRequiredInput(LIBRARY_INPUT); |
| 5046 outputs[LIBRARY_ELEMENT7] = library; |
| 5047 } |
| 5048 |
| 5049 /** |
| 5050 * Return a map from the names of the inputs of this kind of task to the task |
| 5051 * input descriptors describing those inputs for a task with the |
| 5052 * given [target]. |
| 5053 */ |
| 5054 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 5055 Source source = target; |
| 5056 return <String, TaskInput>{ |
| 5057 'resolvedUnits': |
| 5058 LIBRARY_SPECIFIC_UNITS.of(source).toListOf(RESOLVED_UNIT7), |
| 5059 LIBRARY_INPUT: LIBRARY_ELEMENT6.of(source), |
| 5060 }; |
| 5061 } |
| 5062 |
| 5063 /** |
| 5064 * Create a [ResolvedUnit7InLibraryTask] based on the given [target] |
| 5065 * in the given [context]. |
| 5066 */ |
| 5067 static ResolvedUnit7InLibraryTask createTask( |
| 5068 AnalysisContext context, AnalysisTarget target) { |
| 5069 return new ResolvedUnit7InLibraryTask(context, target); |
| 5070 } |
| 5071 } |
| 5072 |
| 5073 /** |
5386 * A task that ensures that all of the inferable instance members in a | 5074 * A task that ensures that all of the inferable instance members in a |
5387 * compilation unit have had their right hand sides re-resolved | 5075 * compilation unit have had their right hand sides re-resolved |
5388 */ | 5076 */ |
5389 class ResolveInstanceFieldsInUnitTask extends SourceBasedAnalysisTask { | 5077 class ResolveInstanceFieldsInUnitTask extends SourceBasedAnalysisTask { |
5390 /** | 5078 /** |
5391 * The name of the [LIBRARY_ELEMENT6] input. | 5079 * The name of the [LIBRARY_ELEMENT6] input. |
5392 */ | 5080 */ |
5393 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; | 5081 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; |
5394 | 5082 |
5395 /** | 5083 /** |
5396 * The name of the [TYPE_PROVIDER] input. | 5084 * The name of the [TYPE_PROVIDER] input. |
5397 */ | 5085 */ |
5398 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; | 5086 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; |
5399 | 5087 |
5400 /** | 5088 /** |
5401 * The name of the input whose value is the [RESOLVED_UNIT9] for the | 5089 * The name of the input whose value is the [RESOLVED_UNIT8] for the |
5402 * compilation unit. | 5090 * compilation unit. |
5403 */ | 5091 */ |
5404 static const String UNIT_INPUT = 'UNIT_INPUT'; | 5092 static const String UNIT_INPUT = 'UNIT_INPUT'; |
5405 | 5093 |
5406 /** | 5094 /** |
5407 * The task descriptor describing this kind of task. | 5095 * The task descriptor describing this kind of task. |
5408 */ | 5096 */ |
5409 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 5097 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
5410 'ResolveInstanceFieldsInUnitTask', | 5098 'ResolveInstanceFieldsInUnitTask', |
5411 createTask, | 5099 createTask, |
5412 buildInputs, | 5100 buildInputs, |
5413 <ResultDescriptor>[CREATED_RESOLVED_UNIT10, RESOLVED_UNIT10]); | 5101 <ResultDescriptor>[CREATED_RESOLVED_UNIT9, RESOLVED_UNIT9]); |
5414 | 5102 |
5415 /** | 5103 /** |
5416 * Initialize a newly created task to build a library element for the given | 5104 * Initialize a newly created task to build a library element for the given |
5417 * [unit] in the given [context]. | 5105 * [unit] in the given [context]. |
5418 */ | 5106 */ |
5419 ResolveInstanceFieldsInUnitTask( | 5107 ResolveInstanceFieldsInUnitTask( |
5420 InternalAnalysisContext context, LibrarySpecificUnit unit) | 5108 InternalAnalysisContext context, LibrarySpecificUnit unit) |
5421 : super(context, unit); | 5109 : super(context, unit); |
5422 | 5110 |
5423 @override | 5111 @override |
(...skipping 16 matching lines...) Expand all Loading... |
5440 InstanceFieldResolverVisitor visitor = new InstanceFieldResolverVisitor( | 5128 InstanceFieldResolverVisitor visitor = new InstanceFieldResolverVisitor( |
5441 libraryElement, | 5129 libraryElement, |
5442 unitElement.source, | 5130 unitElement.source, |
5443 typeProvider, | 5131 typeProvider, |
5444 AnalysisErrorListener.NULL_LISTENER); | 5132 AnalysisErrorListener.NULL_LISTENER); |
5445 visitor.resolveCompilationUnit(unit); | 5133 visitor.resolveCompilationUnit(unit); |
5446 } | 5134 } |
5447 // | 5135 // |
5448 // Record outputs. | 5136 // Record outputs. |
5449 // | 5137 // |
5450 outputs[RESOLVED_UNIT10] = unit; | 5138 outputs[RESOLVED_UNIT9] = unit; |
5451 outputs[CREATED_RESOLVED_UNIT10] = true; | 5139 outputs[CREATED_RESOLVED_UNIT9] = true; |
5452 } | 5140 } |
5453 | 5141 |
5454 /** | 5142 /** |
5455 * Return a map from the names of the inputs of this kind of task to the task | 5143 * Return a map from the names of the inputs of this kind of task to the task |
5456 * input descriptors describing those inputs for a task with the given | 5144 * input descriptors describing those inputs for a task with the given |
5457 * [libSource]. | 5145 * [libSource]. |
5458 */ | 5146 */ |
5459 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 5147 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
5460 LibrarySpecificUnit unit = target; | 5148 LibrarySpecificUnit unit = target; |
5461 return <String, TaskInput>{ | 5149 return <String, TaskInput>{ |
5462 UNIT_INPUT: RESOLVED_UNIT9.of(unit), | 5150 UNIT_INPUT: RESOLVED_UNIT8.of(unit), |
5463 LIBRARY_INPUT: LIBRARY_ELEMENT6.of(unit.library), | 5151 LIBRARY_INPUT: LIBRARY_ELEMENT6.of(unit.library), |
5464 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), | 5152 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), |
5465 // In strong mode, add additional dependencies to enforce inference | 5153 // In strong mode, add additional dependencies to enforce inference |
5466 // ordering. | 5154 // ordering. |
5467 | 5155 |
5468 // Require that static variable inference be complete for all units in | 5156 // Require that static variable inference be complete for all units in |
5469 // the current library cycle. | 5157 // the current library cycle. |
5470 'orderLibraryCycleTasks': LIBRARY_CYCLE_UNITS.of(unit.library).toList( | 5158 'orderLibraryCycleTasks': LIBRARY_CYCLE_UNITS.of(unit.library).toList( |
5471 (CompilationUnitElement unit) => CREATED_RESOLVED_UNIT9.of( | 5159 (CompilationUnitElement unit) => CREATED_RESOLVED_UNIT8.of( |
5472 new LibrarySpecificUnit( | 5160 new LibrarySpecificUnit( |
5473 (unit as CompilationUnitElementImpl).librarySource, | 5161 (unit as CompilationUnitElementImpl).librarySource, |
5474 unit.source))), | 5162 unit.source))), |
5475 // Require that full inference be complete for all dependencies of the | 5163 // Require that full inference be complete for all dependencies of the |
5476 // current library cycle. | 5164 // current library cycle. |
5477 'orderLibraryCycles': LIBRARY_CYCLE_DEPENDENCIES.of(unit.library).toList( | 5165 'orderLibraryCycles': LIBRARY_CYCLE_DEPENDENCIES.of(unit.library).toList( |
5478 (CompilationUnitElement unit) => CREATED_RESOLVED_UNIT11.of( | 5166 (CompilationUnitElement unit) => CREATED_RESOLVED_UNIT10.of( |
5479 new LibrarySpecificUnit( | 5167 new LibrarySpecificUnit( |
5480 (unit as CompilationUnitElementImpl).librarySource, | 5168 (unit as CompilationUnitElementImpl).librarySource, |
5481 unit.source))) | 5169 unit.source))) |
5482 }; | 5170 }; |
5483 } | 5171 } |
5484 | 5172 |
5485 /** | 5173 /** |
5486 * Create a [ResolveInstanceFieldsInUnitTask] based on the given [target] in | 5174 * Create a [ResolveInstanceFieldsInUnitTask] based on the given [target] in |
5487 * the given [context]. | 5175 * the given [context]. |
5488 */ | 5176 */ |
5489 static ResolveInstanceFieldsInUnitTask createTask( | 5177 static ResolveInstanceFieldsInUnitTask createTask( |
5490 AnalysisContext context, AnalysisTarget target) { | 5178 AnalysisContext context, AnalysisTarget target) { |
5491 return new ResolveInstanceFieldsInUnitTask(context, target); | 5179 return new ResolveInstanceFieldsInUnitTask(context, target); |
5492 } | 5180 } |
5493 } | 5181 } |
5494 | 5182 |
5495 /** | 5183 /** |
5496 * A task that finishes resolution by requesting [RESOLVED_UNIT12] for every | 5184 * A task that finishes resolution by requesting [RESOLVED_UNIT11] for every |
5497 * unit in the libraries closure and produces [LIBRARY_ELEMENT9]. | 5185 * unit in the libraries closure and produces [LIBRARY_ELEMENT9]. |
5498 */ | 5186 */ |
5499 class ResolveLibraryReferencesTask extends SourceBasedAnalysisTask { | 5187 class ResolveLibraryReferencesTask extends SourceBasedAnalysisTask { |
5500 /** | 5188 /** |
5501 * The name of the [LIBRARY_ELEMENT8] input. | 5189 * The name of the [LIBRARY_ELEMENT8] input. |
5502 */ | 5190 */ |
5503 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; | 5191 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; |
5504 | 5192 |
5505 /** | 5193 /** |
5506 * The task descriptor describing this kind of task. | 5194 * The task descriptor describing this kind of task. |
(...skipping 20 matching lines...) Expand all Loading... |
5527 /** | 5215 /** |
5528 * Return a map from the names of the inputs of this kind of task to the task | 5216 * Return a map from the names of the inputs of this kind of task to the task |
5529 * input descriptors describing those inputs for a task with the | 5217 * input descriptors describing those inputs for a task with the |
5530 * given [target]. | 5218 * given [target]. |
5531 */ | 5219 */ |
5532 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 5220 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
5533 Source source = target; | 5221 Source source = target; |
5534 return <String, TaskInput>{ | 5222 return <String, TaskInput>{ |
5535 LIBRARY_INPUT: LIBRARY_ELEMENT8.of(source), | 5223 LIBRARY_INPUT: LIBRARY_ELEMENT8.of(source), |
5536 'resolvedUnits': | 5224 'resolvedUnits': |
5537 LIBRARY_SPECIFIC_UNITS.of(source).toListOf(RESOLVED_UNIT12), | 5225 LIBRARY_SPECIFIC_UNITS.of(source).toListOf(RESOLVED_UNIT11), |
5538 }; | 5226 }; |
5539 } | 5227 } |
5540 | 5228 |
5541 /** | 5229 /** |
5542 * Create a [ResolveLibraryReferencesTask] based on the given [target] in | 5230 * Create a [ResolveLibraryReferencesTask] based on the given [target] in |
5543 * the given [context]. | 5231 * the given [context]. |
5544 */ | 5232 */ |
5545 static ResolveLibraryReferencesTask createTask( | 5233 static ResolveLibraryReferencesTask createTask( |
5546 AnalysisContext context, AnalysisTarget target) { | 5234 AnalysisContext context, AnalysisTarget target) { |
5547 return new ResolveLibraryReferencesTask(context, target); | 5235 return new ResolveLibraryReferencesTask(context, target); |
5548 } | 5236 } |
5549 } | 5237 } |
5550 | 5238 |
5551 /** | 5239 /** |
5552 * A task that finishes resolution by requesting [RESOLVED_UNIT13] for every | 5240 * A task that finishes resolution by requesting [RESOLVED_UNIT12] for every |
5553 * unit in the libraries closure and produces [LIBRARY_ELEMENT]. | 5241 * unit in the libraries closure and produces [LIBRARY_ELEMENT]. |
5554 */ | 5242 */ |
5555 class ResolveLibraryTask extends SourceBasedAnalysisTask { | 5243 class ResolveLibraryTask extends SourceBasedAnalysisTask { |
5556 /** | 5244 /** |
5557 * The name of the [LIBRARY_ELEMENT9] input. | 5245 * The name of the [LIBRARY_ELEMENT9] input. |
5558 */ | 5246 */ |
5559 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; | 5247 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; |
5560 | 5248 |
5561 /** | 5249 /** |
5562 * The name of the list of [RESOLVED_UNIT13] input. | 5250 * The name of the list of [RESOLVED_UNIT12] input. |
5563 */ | 5251 */ |
5564 static const String UNITS_INPUT = 'UNITS_INPUT'; | 5252 static const String UNITS_INPUT = 'UNITS_INPUT'; |
5565 | 5253 |
5566 /** | 5254 /** |
5567 * The task descriptor describing this kind of task. | 5255 * The task descriptor describing this kind of task. |
5568 */ | 5256 */ |
5569 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 5257 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
5570 'ResolveLibraryTask', | 5258 'ResolveLibraryTask', |
5571 createTask, | 5259 createTask, |
5572 buildInputs, | 5260 buildInputs, |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5852 * The name of the input whose value is the defining [LIBRARY_ELEMENT8]. | 5540 * The name of the input whose value is the defining [LIBRARY_ELEMENT8]. |
5853 */ | 5541 */ |
5854 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; | 5542 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; |
5855 | 5543 |
5856 /** | 5544 /** |
5857 * The name of the [TYPE_PROVIDER] input. | 5545 * The name of the [TYPE_PROVIDER] input. |
5858 */ | 5546 */ |
5859 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; | 5547 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; |
5860 | 5548 |
5861 /** | 5549 /** |
5862 * The name of the [RESOLVED_UNIT11] input. | 5550 * The name of the [RESOLVED_UNIT10] input. |
5863 */ | 5551 */ |
5864 static const String UNIT_INPUT = 'UNIT_INPUT'; | 5552 static const String UNIT_INPUT = 'UNIT_INPUT'; |
5865 | 5553 |
5866 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 5554 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
5867 'ResolveUnitTask', createTask, buildInputs, <ResultDescriptor>[ | 5555 'ResolveUnitTask', createTask, buildInputs, <ResultDescriptor>[ |
5868 CONSTANT_EXPRESSIONS_DEPENDENCIES, | 5556 CONSTANT_EXPRESSIONS_DEPENDENCIES, |
5869 RESOLVE_UNIT_ERRORS, | 5557 RESOLVE_UNIT_ERRORS, |
5870 CREATED_RESOLVED_UNIT12, | 5558 CREATED_RESOLVED_UNIT11, |
5871 RESOLVED_UNIT12 | 5559 RESOLVED_UNIT11 |
5872 ]); | 5560 ]); |
5873 | 5561 |
5874 ResolveUnitTask( | 5562 ResolveUnitTask( |
5875 InternalAnalysisContext context, LibrarySpecificUnit compilationUnit) | 5563 InternalAnalysisContext context, LibrarySpecificUnit compilationUnit) |
5876 : super(context, compilationUnit); | 5564 : super(context, compilationUnit); |
5877 | 5565 |
5878 @override | 5566 @override |
5879 TaskDescriptor get descriptor => DESCRIPTOR; | 5567 TaskDescriptor get descriptor => DESCRIPTOR; |
5880 | 5568 |
5881 @override | 5569 @override |
(...skipping 25 matching lines...) Expand all Loading... |
5907 } | 5595 } |
5908 // | 5596 // |
5909 // Record outputs. | 5597 // Record outputs. |
5910 // | 5598 // |
5911 // TODO(brianwilkerson) This task modifies the element model (by copying the | 5599 // TODO(brianwilkerson) This task modifies the element model (by copying the |
5912 // AST's for constructor initializers into it) but does not produce an | 5600 // AST's for constructor initializers into it) but does not produce an |
5913 // updated version of the element model. | 5601 // updated version of the element model. |
5914 // | 5602 // |
5915 outputs[CONSTANT_EXPRESSIONS_DEPENDENCIES] = constExprDependencies; | 5603 outputs[CONSTANT_EXPRESSIONS_DEPENDENCIES] = constExprDependencies; |
5916 outputs[RESOLVE_UNIT_ERRORS] = getTargetSourceErrors(errorListener, target); | 5604 outputs[RESOLVE_UNIT_ERRORS] = getTargetSourceErrors(errorListener, target); |
5917 outputs[RESOLVED_UNIT12] = unit; | 5605 outputs[RESOLVED_UNIT11] = unit; |
5918 outputs[CREATED_RESOLVED_UNIT12] = true; | 5606 outputs[CREATED_RESOLVED_UNIT11] = true; |
5919 } | 5607 } |
5920 | 5608 |
5921 /** | 5609 /** |
5922 * Return a map from the names of the inputs of this kind of task to the task | 5610 * Return a map from the names of the inputs of this kind of task to the task |
5923 * input descriptors describing those inputs for a task with the given | 5611 * input descriptors describing those inputs for a task with the given |
5924 * [target]. | 5612 * [target]. |
5925 */ | 5613 */ |
5926 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 5614 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
5927 LibrarySpecificUnit unit = target; | 5615 LibrarySpecificUnit unit = target; |
5928 return <String, TaskInput>{ | 5616 return <String, TaskInput>{ |
5929 LIBRARY_INPUT: LIBRARY_ELEMENT8.of(unit.library), | 5617 LIBRARY_INPUT: LIBRARY_ELEMENT8.of(unit.library), |
5930 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), | 5618 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), |
5931 UNIT_INPUT: RESOLVED_UNIT11.of(unit), | 5619 UNIT_INPUT: RESOLVED_UNIT10.of(unit), |
5932 // In strong mode, add additional dependencies to enforce inference | 5620 // In strong mode, add additional dependencies to enforce inference |
5933 // ordering. | 5621 // ordering. |
5934 | 5622 |
5935 // Require that inference be complete for all units in the | 5623 // Require that inference be complete for all units in the |
5936 // current library cycle. | 5624 // current library cycle. |
5937 'orderLibraryCycleTasks': LIBRARY_CYCLE_UNITS.of(unit.library).toList( | 5625 'orderLibraryCycleTasks': LIBRARY_CYCLE_UNITS.of(unit.library).toList( |
5938 (CompilationUnitElement unit) => CREATED_RESOLVED_UNIT11.of( | 5626 (CompilationUnitElement unit) => CREATED_RESOLVED_UNIT10.of( |
5939 new LibrarySpecificUnit( | 5627 new LibrarySpecificUnit( |
5940 (unit as CompilationUnitElementImpl).librarySource, | 5628 (unit as CompilationUnitElementImpl).librarySource, |
5941 unit.source))) | 5629 unit.source))) |
5942 }; | 5630 }; |
5943 } | 5631 } |
5944 | 5632 |
5945 /** | 5633 /** |
5946 * Create a [ResolveUnitTask] based on the given [target] in | 5634 * Create a [ResolveUnitTask] based on the given [target] in |
5947 * the given [context]. | 5635 * the given [context]. |
5948 */ | 5636 */ |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6283 return TaskSuitability.NONE; | 5971 return TaskSuitability.NONE; |
6284 } | 5972 } |
6285 } | 5973 } |
6286 | 5974 |
6287 /** | 5975 /** |
6288 * A task that builds [STRONG_MODE_ERRORS] for a unit. Also builds | 5976 * A task that builds [STRONG_MODE_ERRORS] for a unit. Also builds |
6289 * [RESOLVED_UNIT] for a unit. | 5977 * [RESOLVED_UNIT] for a unit. |
6290 */ | 5978 */ |
6291 class StrongModeVerifyUnitTask extends SourceBasedAnalysisTask { | 5979 class StrongModeVerifyUnitTask extends SourceBasedAnalysisTask { |
6292 /** | 5980 /** |
6293 * The name of the [RESOLVED_UNIT13] input. | 5981 * The name of the [RESOLVED_UNIT12] input. |
6294 */ | 5982 */ |
6295 static const String UNIT_INPUT = 'UNIT_INPUT'; | 5983 static const String UNIT_INPUT = 'UNIT_INPUT'; |
6296 | 5984 |
6297 /** | 5985 /** |
6298 * The name of the [TYPE_PROVIDER] input. | 5986 * The name of the [TYPE_PROVIDER] input. |
6299 */ | 5987 */ |
6300 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; | 5988 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; |
6301 | 5989 |
6302 /** | 5990 /** |
6303 * The task descriptor describing this kind of task. | 5991 * The task descriptor describing this kind of task. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6344 } | 6032 } |
6345 | 6033 |
6346 /** | 6034 /** |
6347 * Return a map from the names of the inputs of this kind of task to the task | 6035 * Return a map from the names of the inputs of this kind of task to the task |
6348 * input descriptors describing those inputs for a task with the | 6036 * input descriptors describing those inputs for a task with the |
6349 * given [target]. | 6037 * given [target]. |
6350 */ | 6038 */ |
6351 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 6039 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
6352 LibrarySpecificUnit unit = target; | 6040 LibrarySpecificUnit unit = target; |
6353 return <String, TaskInput>{ | 6041 return <String, TaskInput>{ |
6354 UNIT_INPUT: RESOLVED_UNIT13.of(unit), | 6042 UNIT_INPUT: RESOLVED_UNIT12.of(unit), |
6355 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), | 6043 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), |
6356 }; | 6044 }; |
6357 } | 6045 } |
6358 | 6046 |
6359 /** | 6047 /** |
6360 * Create a [StrongModeVerifyUnitTask] based on the given [target] in | 6048 * Create a [StrongModeVerifyUnitTask] based on the given [target] in |
6361 * the given [context]. | 6049 * the given [context]. |
6362 */ | 6050 */ |
6363 static StrongModeVerifyUnitTask createTask( | 6051 static StrongModeVerifyUnitTask createTask( |
6364 AnalysisContext context, AnalysisTarget target) { | 6052 AnalysisContext context, AnalysisTarget target) { |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6671 | 6359 |
6672 @override | 6360 @override |
6673 bool moveNext() { | 6361 bool moveNext() { |
6674 if (_newSources.isEmpty) { | 6362 if (_newSources.isEmpty) { |
6675 return false; | 6363 return false; |
6676 } | 6364 } |
6677 currentTarget = _newSources.removeLast(); | 6365 currentTarget = _newSources.removeLast(); |
6678 return true; | 6366 return true; |
6679 } | 6367 } |
6680 } | 6368 } |
OLD | NEW |