| 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/src/context/cache.dart'; | 9 import 'package:analyzer/src/context/cache.dart'; |
| 10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 * static members inside classes. | 170 * static members inside classes. |
| 171 * | 171 * |
| 172 * The result is only available for [LibrarySpecificUnit]s, and only when strong | 172 * The result is only available for [LibrarySpecificUnit]s, and only when strong |
| 173 * mode is enabled. | 173 * mode is enabled. |
| 174 */ | 174 */ |
| 175 final ListResultDescriptor<VariableElement> INFERABLE_STATIC_VARIABLES_IN_UNIT = | 175 final ListResultDescriptor<VariableElement> INFERABLE_STATIC_VARIABLES_IN_UNIT = |
| 176 new ListResultDescriptor<VariableElement>( | 176 new ListResultDescriptor<VariableElement>( |
| 177 'INFERABLE_STATIC_VARIABLES_IN_UNIT', null); | 177 'INFERABLE_STATIC_VARIABLES_IN_UNIT', null); |
| 178 | 178 |
| 179 /** | 179 /** |
| 180 * An inferrable static variable ([VariableElement]) whose type has been | 180 * An inferable static variable ([VariableElement]) whose type has been |
| 181 * inferred. | 181 * inferred. |
| 182 * | 182 * |
| 183 * The result is only available for [VariableElement]s, and only when strong | 183 * The result is only available for [VariableElement]s, and only when strong |
| 184 * mode is enabled. | 184 * mode is enabled. |
| 185 */ | 185 */ |
| 186 final ResultDescriptor<VariableElement> INFERRED_STATIC_VARIABLE = | 186 final ResultDescriptor<VariableElement> INFERRED_STATIC_VARIABLE = |
| 187 new ResultDescriptor<VariableElement>('INFERRED_STATIC_VARIABLE', null, | 187 new ResultDescriptor<VariableElement>('INFERRED_STATIC_VARIABLE', null, |
| 188 cachingPolicy: ELEMENT_CACHING_POLICY); | 188 cachingPolicy: ELEMENT_CACHING_POLICY); |
| 189 | 189 |
| 190 /** | 190 /** |
| (...skipping 2456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2647 * Create a [GenerateLintsTask] based on the given [target] in | 2647 * Create a [GenerateLintsTask] based on the given [target] in |
| 2648 * the given [context]. | 2648 * the given [context]. |
| 2649 */ | 2649 */ |
| 2650 static GenerateLintsTask createTask( | 2650 static GenerateLintsTask createTask( |
| 2651 AnalysisContext context, AnalysisTarget target) { | 2651 AnalysisContext context, AnalysisTarget target) { |
| 2652 return new GenerateLintsTask(context, target); | 2652 return new GenerateLintsTask(context, target); |
| 2653 } | 2653 } |
| 2654 } | 2654 } |
| 2655 | 2655 |
| 2656 /** | 2656 /** |
| 2657 * A task that ensures that all of the inferrable instance members in a | 2657 * A task that ensures that all of the inferable instance members in a |
| 2658 * compilation unit have had their type inferred. | 2658 * compilation unit have had their type inferred. |
| 2659 */ | 2659 */ |
| 2660 class InferInstanceMembersInUnitTask extends SourceBasedAnalysisTask { | 2660 class InferInstanceMembersInUnitTask extends SourceBasedAnalysisTask { |
| 2661 /** | 2661 /** |
| 2662 * The name of the [TYPE_PROVIDER] input. | 2662 * The name of the [TYPE_PROVIDER] input. |
| 2663 */ | 2663 */ |
| 2664 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; | 2664 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; |
| 2665 | 2665 |
| 2666 /** | 2666 /** |
| 2667 * The name of the input whose value is the [RESOLVED_UNIT6] for the | 2667 * The name of the input whose value is the [RESOLVED_UNIT6] for the |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2767 node.getAncestor((AstNode ancestor) => ancestor is VariableDeclaration); | 2767 node.getAncestor((AstNode ancestor) => ancestor is VariableDeclaration); |
| 2768 if (declaration == null || declaration.name != node) { | 2768 if (declaration == null || declaration.name != node) { |
| 2769 throw new AnalysisException( | 2769 throw new AnalysisException( |
| 2770 "Failed to find the declaration of the variable ${variable.displayName
} in ${variable.source}"); | 2770 "Failed to find the declaration of the variable ${variable.displayName
} in ${variable.source}"); |
| 2771 } | 2771 } |
| 2772 return declaration; | 2772 return declaration; |
| 2773 } | 2773 } |
| 2774 } | 2774 } |
| 2775 | 2775 |
| 2776 /** | 2776 /** |
| 2777 * A task that ensures that all of the inferrable static variables in a | 2777 * A task that ensures that all of the inferable static variables in a |
| 2778 * compilation unit have had their type inferred. | 2778 * compilation unit have had their type inferred. |
| 2779 */ | 2779 */ |
| 2780 class InferStaticVariableTypesInUnitTask extends SourceBasedAnalysisTask { | 2780 class InferStaticVariableTypesInUnitTask extends SourceBasedAnalysisTask { |
| 2781 /** | 2781 /** |
| 2782 * The name of the input whose value is the [RESOLVED_UNIT5] for the | 2782 * The name of the input whose value is the [RESOLVED_UNIT5] for the |
| 2783 * compilation unit. | 2783 * compilation unit. |
| 2784 */ | 2784 */ |
| 2785 static const String UNIT_INPUT = 'UNIT_INPUT'; | 2785 static const String UNIT_INPUT = 'UNIT_INPUT'; |
| 2786 | 2786 |
| 2787 /** | 2787 /** |
| 2788 * The name of the input whose value is a list of the inferrable static | 2788 * The name of the input whose value is a list of the inferable static |
| 2789 * variables whose types have been computed. | 2789 * variables whose types have been computed. |
| 2790 */ | 2790 */ |
| 2791 static const String INFERRED_VARIABLES_INPUT = 'INFERRED_VARIABLES_INPUT'; | 2791 static const String INFERRED_VARIABLES_INPUT = 'INFERRED_VARIABLES_INPUT'; |
| 2792 | 2792 |
| 2793 /** | 2793 /** |
| 2794 * The task descriptor describing this kind of task. | 2794 * The task descriptor describing this kind of task. |
| 2795 */ | 2795 */ |
| 2796 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 2796 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 2797 'InferStaticVariableTypesInUnitTask', | 2797 'InferStaticVariableTypesInUnitTask', |
| 2798 createTask, | 2798 createTask, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2843 * Create a [InferStaticVariableTypesInUnitTask] based on the given [target] | 2843 * Create a [InferStaticVariableTypesInUnitTask] based on the given [target] |
| 2844 * in the given [context]. | 2844 * in the given [context]. |
| 2845 */ | 2845 */ |
| 2846 static InferStaticVariableTypesInUnitTask createTask( | 2846 static InferStaticVariableTypesInUnitTask createTask( |
| 2847 AnalysisContext context, AnalysisTarget target) { | 2847 AnalysisContext context, AnalysisTarget target) { |
| 2848 return new InferStaticVariableTypesInUnitTask(context, target); | 2848 return new InferStaticVariableTypesInUnitTask(context, target); |
| 2849 } | 2849 } |
| 2850 } | 2850 } |
| 2851 | 2851 |
| 2852 /** | 2852 /** |
| 2853 * A task that computes the type of an inferrable static variable and | 2853 * A task that computes the type of an inferable static variable and |
| 2854 * stores it in the element model. | 2854 * stores it in the element model. |
| 2855 */ | 2855 */ |
| 2856 class InferStaticVariableTypeTask extends InferStaticVariableTask { | 2856 class InferStaticVariableTypeTask extends InferStaticVariableTask { |
| 2857 /** | 2857 /** |
| 2858 * The name of the input which ensures that dependent values have their type | 2858 * The name of the input which ensures that dependent values have their type |
| 2859 * inferred before the target. | 2859 * inferred before the target. |
| 2860 */ | 2860 */ |
| 2861 static const String DEPENDENCIES_INPUT = 'DEPENDENCIES_INPUT'; | 2861 static const String DEPENDENCIES_INPUT = 'DEPENDENCIES_INPUT'; |
| 2862 | 2862 |
| 2863 /** | 2863 /** |
| (...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3800 String name = node.name; | 3800 String name = node.name; |
| 3801 names.names.add(name); | 3801 names.names.add(name); |
| 3802 if (dependsOn != null && bodyLevel == 0) { | 3802 if (dependsOn != null && bodyLevel == 0) { |
| 3803 dependsOn.add(name); | 3803 dependsOn.add(name); |
| 3804 } | 3804 } |
| 3805 } | 3805 } |
| 3806 } | 3806 } |
| 3807 } | 3807 } |
| 3808 | 3808 |
| 3809 /** | 3809 /** |
| 3810 * A task that ensures that all of the inferrable instance members in a | 3810 * A task that ensures that all of the inferable instance members in a |
| 3811 * compilation unit have had their right hand sides re-resolved | 3811 * compilation unit have had their right hand sides re-resolved |
| 3812 */ | 3812 */ |
| 3813 class ResolveInstanceFieldsInUnitTask extends SourceBasedAnalysisTask { | 3813 class ResolveInstanceFieldsInUnitTask extends SourceBasedAnalysisTask { |
| 3814 /** | 3814 /** |
| 3815 * The name of the [LIBRARY_ELEMENT5] input. | 3815 * The name of the [LIBRARY_ELEMENT5] input. |
| 3816 */ | 3816 */ |
| 3817 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; | 3817 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; |
| 3818 | 3818 |
| 3819 /** | 3819 /** |
| 3820 * The name of the [TYPE_PROVIDER] input. | 3820 * The name of the [TYPE_PROVIDER] input. |
| (...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4661 | 4661 |
| 4662 _ExportSourceClosureTaskInput(this.target, this.resultDescriptor); | 4662 _ExportSourceClosureTaskInput(this.target, this.resultDescriptor); |
| 4663 | 4663 |
| 4664 @override | 4664 @override |
| 4665 TaskInputBuilder<List<Source>> createBuilder() => | 4665 TaskInputBuilder<List<Source>> createBuilder() => |
| 4666 new _SourceClosureTaskInputBuilder( | 4666 new _SourceClosureTaskInputBuilder( |
| 4667 target, _SourceClosureKind.EXPORT, resultDescriptor); | 4667 target, _SourceClosureKind.EXPORT, resultDescriptor); |
| 4668 } | 4668 } |
| 4669 | 4669 |
| 4670 /** | 4670 /** |
| 4671 * The lists of library source that are imported or exported directly or | |
| 4672 * indirectly by a [Source]. | |
| 4673 */ | |
| 4674 class _ImportExportClosure {} | |
| 4675 | |
| 4676 /** | |
| 4677 * A [TaskInput] whose value is a list of library sources imported or exported, | |
| 4678 * directly or indirectly by the target [Source]. | |
| 4679 * | |
| 4680 * [resultDescriptor] is the type of result which should be produced for each | |
| 4681 * target [Source]. | |
| 4682 */ | |
| 4683 class _ImportExportSourceClosureTaskInput extends TaskInputImpl<List<Source>> { | |
| 4684 final Source target; | |
| 4685 final ResultDescriptor resultDescriptor; | |
| 4686 | |
| 4687 _ImportExportSourceClosureTaskInput(this.target, this.resultDescriptor); | |
| 4688 | |
| 4689 @override | |
| 4690 TaskInputBuilder<List<Source>> createBuilder() => | |
| 4691 new _SourceClosureTaskInputBuilder( | |
| 4692 target, _SourceClosureKind.IMPORT_EXPORT, resultDescriptor); | |
| 4693 } | |
| 4694 | |
| 4695 /** | |
| 4696 * A [TaskInput] whose value is a list of library sources imported directly | 4671 * A [TaskInput] whose value is a list of library sources imported directly |
| 4697 * or indirectly by the target [Source]. | 4672 * or indirectly by the target [Source]. |
| 4698 * | 4673 * |
| 4699 * [resultDescriptor] is the type of result which should be produced for each | 4674 * [resultDescriptor] is the type of result which should be produced for each |
| 4700 * target [Source]. | 4675 * target [Source]. |
| 4701 */ | 4676 */ |
| 4702 class _ImportSourceClosureTaskInput extends TaskInputImpl<List<Source>> { | 4677 class _ImportSourceClosureTaskInput extends TaskInputImpl<List<Source>> { |
| 4703 final Source target; | 4678 final Source target; |
| 4704 final ResultDescriptor resultDescriptor; | 4679 final ResultDescriptor resultDescriptor; |
| 4705 | 4680 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4771 | 4746 |
| 4772 @override | 4747 @override |
| 4773 bool moveNext() { | 4748 bool moveNext() { |
| 4774 if (_newSources.isEmpty) { | 4749 if (_newSources.isEmpty) { |
| 4775 return false; | 4750 return false; |
| 4776 } | 4751 } |
| 4777 currentTarget = _newSources.removeLast(); | 4752 currentTarget = _newSources.removeLast(); |
| 4778 return true; | 4753 return true; |
| 4779 } | 4754 } |
| 4780 } | 4755 } |
| OLD | NEW |