| 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 import 'dart:math' as math; | 8 import 'dart:math' as math; |
| 9 | 9 |
| 10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 * The partial [LibraryElement] associated with a library. | 172 * The partial [LibraryElement] associated with a library. |
| 173 * | 173 * |
| 174 * [LIBRARY_ELEMENT4] plus [RESOLVED_UNIT4] for every unit. | 174 * [LIBRARY_ELEMENT4] plus [RESOLVED_UNIT4] for every unit. |
| 175 * | 175 * |
| 176 * The result is only available for targets representing a Dart library. | 176 * The result is only available for targets representing a Dart library. |
| 177 */ | 177 */ |
| 178 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT5 = | 178 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT5 = |
| 179 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT5', null); | 179 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT5', null); |
| 180 | 180 |
| 181 /** | 181 /** |
| 182 * The partial [LibraryElement] associated with a library. | |
| 183 * | |
| 184 * Implicit constructors are built for every [ClassElement] requiring them. | |
| 185 * | |
| 186 * The result is only available for targets representing a Dart library. | |
| 187 */ | |
| 188 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT6 = | |
| 189 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT6', null); | |
| 190 | |
| 191 /** | |
| 192 * The errors produced while parsing a compilation unit. | 182 * The errors produced while parsing a compilation unit. |
| 193 * | 183 * |
| 194 * The list will be empty if there were no errors, but will not be `null`. | 184 * The list will be empty if there were no errors, but will not be `null`. |
| 195 * | 185 * |
| 196 * The result is only available for targets representing a Dart compilation unit
. | 186 * The result is only available for targets representing a Dart compilation unit
. |
| 197 */ | 187 */ |
| 198 final ResultDescriptor<List<AnalysisError>> PARSE_ERRORS = | 188 final ResultDescriptor<List<AnalysisError>> PARSE_ERRORS = |
| 199 new ResultDescriptor<List<AnalysisError>>( | 189 new ResultDescriptor<List<AnalysisError>>( |
| 200 'PARSE_ERRORS', AnalysisError.NO_ERRORS, contributesTo: DART_ERRORS); | 190 'PARSE_ERRORS', AnalysisError.NO_ERRORS, contributesTo: DART_ERRORS); |
| 201 | 191 |
| (...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1059 * Create a [BuildFunctionTypeAliasesTask] based on the given [target] in | 1049 * Create a [BuildFunctionTypeAliasesTask] based on the given [target] in |
| 1060 * the given [context]. | 1050 * the given [context]. |
| 1061 */ | 1051 */ |
| 1062 static BuildFunctionTypeAliasesTask createTask( | 1052 static BuildFunctionTypeAliasesTask createTask( |
| 1063 AnalysisContext context, AnalysisTarget target) { | 1053 AnalysisContext context, AnalysisTarget target) { |
| 1064 return new BuildFunctionTypeAliasesTask(context, target); | 1054 return new BuildFunctionTypeAliasesTask(context, target); |
| 1065 } | 1055 } |
| 1066 } | 1056 } |
| 1067 | 1057 |
| 1068 /** | 1058 /** |
| 1069 * An artifitial task that does nothing except to force building constructors | 1059 * This task finishes building [LIBRARY_ELEMENT] by forcing building |
| 1070 * for for the defining and part units of a library. | 1060 * constructors for classes in the defining and part units of a library. |
| 1071 */ | 1061 */ |
| 1072 class BuildLibraryConstructorsTask extends SourceBasedAnalysisTask { | 1062 class BuildLibraryConstructorsTask extends SourceBasedAnalysisTask { |
| 1073 /** | 1063 /** |
| 1074 * The name of the [LIBRARY_ELEMENT5] input. | 1064 * The name of the [LIBRARY_ELEMENT5] input. |
| 1075 */ | 1065 */ |
| 1076 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; | 1066 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; |
| 1077 | 1067 |
| 1078 /** | 1068 /** |
| 1079 * The task descriptor describing this kind of task. | 1069 * The task descriptor describing this kind of task. |
| 1080 */ | 1070 */ |
| 1081 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 1071 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 1082 'BuildLibraryConstructorsTask', createTask, buildInputs, | 1072 'BuildLibraryConstructorsTask', createTask, buildInputs, |
| 1083 <ResultDescriptor>[LIBRARY_ELEMENT6]); | 1073 <ResultDescriptor>[LIBRARY_ELEMENT]); |
| 1084 | 1074 |
| 1085 BuildLibraryConstructorsTask( | 1075 BuildLibraryConstructorsTask( |
| 1086 InternalAnalysisContext context, AnalysisTarget target) | 1076 InternalAnalysisContext context, AnalysisTarget target) |
| 1087 : super(context, target); | 1077 : super(context, target); |
| 1088 | 1078 |
| 1089 @override | 1079 @override |
| 1090 TaskDescriptor get descriptor => DESCRIPTOR; | 1080 TaskDescriptor get descriptor => DESCRIPTOR; |
| 1091 | 1081 |
| 1092 @override | 1082 @override |
| 1093 void internalPerform() { | 1083 void internalPerform() { |
| 1094 LibraryElement library = getRequiredInput(LIBRARY_INPUT); | 1084 LibraryElement library = getRequiredInput(LIBRARY_INPUT); |
| 1095 outputs[LIBRARY_ELEMENT6] = library; | 1085 outputs[LIBRARY_ELEMENT] = library; |
| 1096 } | 1086 } |
| 1097 | 1087 |
| 1098 /** | 1088 /** |
| 1099 * Return a map from the names of the inputs of this kind of task to the task | 1089 * Return a map from the names of the inputs of this kind of task to the task |
| 1100 * input descriptors describing those inputs for a task with the | 1090 * input descriptors describing those inputs for a task with the |
| 1101 * given [target]. | 1091 * given [target]. |
| 1102 */ | 1092 */ |
| 1103 static Map<String, TaskInput> buildInputs(Source libSource) { | 1093 static Map<String, TaskInput> buildInputs(Source libSource) { |
| 1104 return <String, TaskInput>{ | 1094 return <String, TaskInput>{ |
| 1105 LIBRARY_INPUT: LIBRARY_ELEMENT5.of(libSource), | 1095 LIBRARY_INPUT: LIBRARY_ELEMENT5.of(libSource), |
| (...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2112 AnalysisContext context, AnalysisTarget target) { | 2102 AnalysisContext context, AnalysisTarget target) { |
| 2113 return new ResolveLibraryTypeNamesTask(context, target); | 2103 return new ResolveLibraryTypeNamesTask(context, target); |
| 2114 } | 2104 } |
| 2115 } | 2105 } |
| 2116 | 2106 |
| 2117 /** | 2107 /** |
| 2118 * A task that builds [RESOLVED_UNIT] for a unit. | 2108 * A task that builds [RESOLVED_UNIT] for a unit. |
| 2119 */ | 2109 */ |
| 2120 class ResolveReferencesTask extends SourceBasedAnalysisTask { | 2110 class ResolveReferencesTask extends SourceBasedAnalysisTask { |
| 2121 /** | 2111 /** |
| 2122 * The name of the [LIBRARY_ELEMENT6] input. | 2112 * The name of the [LIBRARY_ELEMENT] input. |
| 2123 */ | 2113 */ |
| 2124 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; | 2114 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; |
| 2125 | 2115 |
| 2126 /** | 2116 /** |
| 2127 * The name of the [RESOLVED_UNIT5] input. | 2117 * The name of the [RESOLVED_UNIT5] input. |
| 2128 */ | 2118 */ |
| 2129 static const String UNIT_INPUT = 'UNIT_INPUT'; | 2119 static const String UNIT_INPUT = 'UNIT_INPUT'; |
| 2130 | 2120 |
| 2131 /** | 2121 /** |
| 2132 * The task descriptor describing this kind of task. | 2122 * The task descriptor describing this kind of task. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2166 outputs[RESOLVED_UNIT] = unit; | 2156 outputs[RESOLVED_UNIT] = unit; |
| 2167 } | 2157 } |
| 2168 | 2158 |
| 2169 /** | 2159 /** |
| 2170 * Return a map from the names of the inputs of this kind of task to the task | 2160 * Return a map from the names of the inputs of this kind of task to the task |
| 2171 * input descriptors describing those inputs for a task with the | 2161 * input descriptors describing those inputs for a task with the |
| 2172 * given [target]. | 2162 * given [target]. |
| 2173 */ | 2163 */ |
| 2174 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) { | 2164 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) { |
| 2175 return <String, TaskInput>{ | 2165 return <String, TaskInput>{ |
| 2176 LIBRARY_INPUT: LIBRARY_ELEMENT6.of(target.library), | 2166 LIBRARY_INPUT: LIBRARY_ELEMENT.of(target.library), |
| 2177 UNIT_INPUT: RESOLVED_UNIT5.of(target) | 2167 UNIT_INPUT: RESOLVED_UNIT5.of(target) |
| 2178 }; | 2168 }; |
| 2179 } | 2169 } |
| 2180 | 2170 |
| 2181 /** | 2171 /** |
| 2182 * Create a [ResolveReferencesTask] based on the given [target] in | 2172 * Create a [ResolveReferencesTask] based on the given [target] in |
| 2183 * the given [context]. | 2173 * the given [context]. |
| 2184 */ | 2174 */ |
| 2185 static ResolveReferencesTask createTask( | 2175 static ResolveReferencesTask createTask( |
| 2186 AnalysisContext context, AnalysisTarget target) { | 2176 AnalysisContext context, AnalysisTarget target) { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2252 AnalysisContext context, AnalysisTarget target) { | 2242 AnalysisContext context, AnalysisTarget target) { |
| 2253 return new ResolveUnitTypeNamesTask(context, target); | 2243 return new ResolveUnitTypeNamesTask(context, target); |
| 2254 } | 2244 } |
| 2255 } | 2245 } |
| 2256 | 2246 |
| 2257 /** | 2247 /** |
| 2258 * A task that builds [RESOLVED_UNIT5] for a unit. | 2248 * A task that builds [RESOLVED_UNIT5] for a unit. |
| 2259 */ | 2249 */ |
| 2260 class ResolveVariableReferencesTask extends SourceBasedAnalysisTask { | 2250 class ResolveVariableReferencesTask extends SourceBasedAnalysisTask { |
| 2261 /** | 2251 /** |
| 2262 * The name of the [LIBRARY_ELEMENT6] input. | 2252 * The name of the [LIBRARY_ELEMENT] input. |
| 2263 */ | 2253 */ |
| 2264 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; | 2254 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; |
| 2265 | 2255 |
| 2266 /** | 2256 /** |
| 2267 * The name of the [RESOLVED_UNIT4] input. | 2257 * The name of the [RESOLVED_UNIT4] input. |
| 2268 */ | 2258 */ |
| 2269 static const String UNIT_INPUT = 'UNIT_INPUT'; | 2259 static const String UNIT_INPUT = 'UNIT_INPUT'; |
| 2270 | 2260 |
| 2271 /** | 2261 /** |
| 2272 * The task descriptor describing this kind of task. | 2262 * The task descriptor describing this kind of task. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2305 outputs[RESOLVED_UNIT5] = unit; | 2295 outputs[RESOLVED_UNIT5] = unit; |
| 2306 } | 2296 } |
| 2307 | 2297 |
| 2308 /** | 2298 /** |
| 2309 * Return a map from the names of the inputs of this kind of task to the task | 2299 * Return a map from the names of the inputs of this kind of task to the task |
| 2310 * input descriptors describing those inputs for a task with the | 2300 * input descriptors describing those inputs for a task with the |
| 2311 * given [target]. | 2301 * given [target]. |
| 2312 */ | 2302 */ |
| 2313 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) { | 2303 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) { |
| 2314 return <String, TaskInput>{ | 2304 return <String, TaskInput>{ |
| 2315 LIBRARY_INPUT: LIBRARY_ELEMENT6.of(target.library), | 2305 LIBRARY_INPUT: LIBRARY_ELEMENT.of(target.library), |
| 2316 UNIT_INPUT: RESOLVED_UNIT4.of(target) | 2306 UNIT_INPUT: RESOLVED_UNIT4.of(target) |
| 2317 }; | 2307 }; |
| 2318 } | 2308 } |
| 2319 | 2309 |
| 2320 /** | 2310 /** |
| 2321 * Create a [ResolveVariableReferencesTask] based on the given [target] in | 2311 * Create a [ResolveVariableReferencesTask] based on the given [target] in |
| 2322 * the given [context]. | 2312 * the given [context]. |
| 2323 */ | 2313 */ |
| 2324 static ResolveVariableReferencesTask createTask( | 2314 static ResolveVariableReferencesTask createTask( |
| 2325 AnalysisContext context, AnalysisTarget target) { | 2315 AnalysisContext context, AnalysisTarget target) { |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2534 @override | 2524 @override |
| 2535 bool moveNext() { | 2525 bool moveNext() { |
| 2536 if (_newSources.isEmpty) { | 2526 if (_newSources.isEmpty) { |
| 2537 return false; | 2527 return false; |
| 2538 } | 2528 } |
| 2539 currentTarget = _newSources.first; | 2529 currentTarget = _newSources.first; |
| 2540 _newSources.remove(currentTarget); | 2530 _newSources.remove(currentTarget); |
| 2541 return true; | 2531 return true; |
| 2542 } | 2532 } |
| 2543 } | 2533 } |
| OLD | NEW |