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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
301 * | 301 * |
302 * [LIBRARY_ELEMENT6] for the library and its import/export closure. | 302 * [LIBRARY_ELEMENT6] for the library and its import/export closure. |
303 * | 303 * |
304 * The result is only available for [Source]s representing a library. | 304 * The result is only available for [Source]s representing a library. |
305 */ | 305 */ |
306 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT7 = | 306 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT7 = |
307 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT7', null, | 307 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT7', null, |
308 cachingPolicy: ELEMENT_CACHING_POLICY); | 308 cachingPolicy: ELEMENT_CACHING_POLICY); |
309 | 309 |
310 /** | 310 /** |
311 * The partial [LibraryElement] associated with a library. | |
312 * | |
313 * [LIBRARY_ELEMENT7] for the library for which references have been computed. | |
314 * | |
315 * The result is only available for [Source]s representing a library. | |
316 */ | |
317 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT8 = | |
318 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT8', null, | |
319 cachingPolicy: ELEMENT_CACHING_POLICY); | |
320 | |
321 /** | |
311 * The flag specifying whether all analysis errors are computed in a specific | 322 * The flag specifying whether all analysis errors are computed in a specific |
312 * library. | 323 * library. |
313 * | 324 * |
314 * The result is only available for [Source]s representing a library. | 325 * The result is only available for [Source]s representing a library. |
315 */ | 326 */ |
316 final ResultDescriptor<bool> LIBRARY_ERRORS_READY = | 327 final ResultDescriptor<bool> LIBRARY_ERRORS_READY = |
317 new ResultDescriptor<bool>('LIBRARY_ERRORS_READY', false); | 328 new ResultDescriptor<bool>('LIBRARY_ERRORS_READY', false); |
318 | 329 |
319 /** | 330 /** |
320 * The [LibrarySpecificUnit]s that a library consists of. | 331 * The [LibrarySpecificUnit]s that a library consists of. |
(...skipping 2079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2400 } | 2411 } |
2401 | 2412 |
2402 /** | 2413 /** |
2403 * Return a map from the names of the inputs of this kind of task to the task | 2414 * Return a map from the names of the inputs of this kind of task to the task |
2404 * input descriptors describing those inputs for a task with the | 2415 * input descriptors describing those inputs for a task with the |
2405 * given [target]. | 2416 * given [target]. |
2406 */ | 2417 */ |
2407 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 2418 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
2408 LibrarySpecificUnit unit = target; | 2419 LibrarySpecificUnit unit = target; |
2409 return <String, TaskInput>{ | 2420 return <String, TaskInput>{ |
2410 'libraryElement': LIBRARY_ELEMENT.of(unit.library), | 2421 'libraryElement': LIBRARY_ELEMENT8.of(unit.library), |
2411 UNIT_INPUT: RESOLVED_UNIT10.of(unit), | 2422 UNIT_INPUT: RESOLVED_UNIT10.of(unit), |
2412 CONSTANT_VALUES: | 2423 CONSTANT_VALUES: |
2413 COMPILATION_UNIT_CONSTANTS.of(unit).toListOf(CONSTANT_VALUE) | 2424 COMPILATION_UNIT_CONSTANTS.of(unit).toListOf(CONSTANT_VALUE) |
2414 }; | 2425 }; |
2415 } | 2426 } |
2416 | 2427 |
2417 /** | 2428 /** |
2418 * Create an [EvaluateUnitConstantsTask] based on the given [target] in | 2429 * Create an [EvaluateUnitConstantsTask] based on the given [target] in |
2419 * the given [context]. | 2430 * the given [context]. |
2420 */ | 2431 */ |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3210 } | 3221 } |
3211 | 3222 |
3212 /** | 3223 /** |
3213 * Return a map from the names of the inputs of this kind of task to the task | 3224 * Return a map from the names of the inputs of this kind of task to the task |
3214 * input descriptors describing those inputs for a task with the | 3225 * input descriptors describing those inputs for a task with the |
3215 * given [target]. | 3226 * given [target]. |
3216 */ | 3227 */ |
3217 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 3228 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
3218 Source source = target; | 3229 Source source = target; |
3219 return <String, TaskInput>{ | 3230 return <String, TaskInput>{ |
3220 'allErrors': UNITS.of(source).toListOf(DART_ERRORS) | 3231 'allErrors': UNITS.of(source).toListOf(DART_ERRORS), |
3232 'libraryElement': LIBRARY_ELEMENT.of(source) | |
3221 }; | 3233 }; |
3222 } | 3234 } |
3223 | 3235 |
3224 /** | 3236 /** |
3225 * Create a [LibraryErrorsReadyTask] based on the given [target] in the given | 3237 * Create a [LibraryErrorsReadyTask] based on the given [target] in the given |
3226 * [context]. | 3238 * [context]. |
3227 */ | 3239 */ |
3228 static LibraryErrorsReadyTask createTask( | 3240 static LibraryErrorsReadyTask createTask( |
3229 AnalysisContext context, AnalysisTarget target) { | 3241 AnalysisContext context, AnalysisTarget target) { |
3230 return new LibraryErrorsReadyTask(context, target); | 3242 return new LibraryErrorsReadyTask(context, target); |
(...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4446 return new ResolveInstanceFieldsInUnitTask(context, target); | 4458 return new ResolveInstanceFieldsInUnitTask(context, target); |
4447 } | 4459 } |
4448 } | 4460 } |
4449 | 4461 |
4450 /** | 4462 /** |
4451 * A task that finishes resolution by requesting [RESOLVED_UNIT10] for every | 4463 * A task that finishes resolution by requesting [RESOLVED_UNIT10] for every |
4452 * unit in the libraries closure and produces [LIBRARY_ELEMENT]. | 4464 * unit in the libraries closure and produces [LIBRARY_ELEMENT]. |
4453 */ | 4465 */ |
4454 class ResolveLibraryReferencesTask extends SourceBasedAnalysisTask { | 4466 class ResolveLibraryReferencesTask extends SourceBasedAnalysisTask { |
4455 /** | 4467 /** |
4456 * The name of the [LIBRARY_ELEMENT5] input. | 4468 * The name of the [LIBRARY_ELEMENT7] input. |
4457 */ | 4469 */ |
4458 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; | 4470 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; |
4459 | 4471 |
4460 /** | 4472 /** |
4461 * The name of the list of [RESOLVED_UNIT10] input. | 4473 * The name of the list of [RESOLVED_UNIT10] input. |
4462 */ | 4474 */ |
4463 static const String UNITS_INPUT = 'UNITS_INPUT'; | 4475 static const String UNITS_INPUT = 'UNITS_INPUT'; |
4464 | 4476 |
4465 /** | 4477 /** |
4466 * The task descriptor describing this kind of task. | 4478 * The task descriptor describing this kind of task. |
4467 */ | 4479 */ |
4468 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 4480 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
4469 'ResolveLibraryReferencesTask', | 4481 'ResolveLibraryReferencesTask', |
4470 createTask, | 4482 createTask, |
4471 buildInputs, | 4483 buildInputs, |
4472 <ResultDescriptor>[LIBRARY_ELEMENT, REFERENCED_NAMES]); | 4484 <ResultDescriptor>[LIBRARY_ELEMENT8, REFERENCED_NAMES]); |
4473 | 4485 |
4474 ResolveLibraryReferencesTask( | 4486 ResolveLibraryReferencesTask( |
4475 InternalAnalysisContext context, AnalysisTarget target) | 4487 InternalAnalysisContext context, AnalysisTarget target) |
4476 : super(context, target); | 4488 : super(context, target); |
4477 | 4489 |
4478 @override | 4490 @override |
4479 TaskDescriptor get descriptor => DESCRIPTOR; | 4491 TaskDescriptor get descriptor => DESCRIPTOR; |
4480 | 4492 |
4481 @override | 4493 @override |
4482 void internalPerform() { | 4494 void internalPerform() { |
4483 // | 4495 // |
4484 // Prepare inputs. | 4496 // Prepare inputs. |
4485 // | 4497 // |
4486 LibraryElement library = getRequiredInput(LIBRARY_INPUT); | 4498 LibraryElement library = getRequiredInput(LIBRARY_INPUT); |
4487 List<CompilationUnit> units = getRequiredInput(UNITS_INPUT); | 4499 List<CompilationUnit> units = getRequiredInput(UNITS_INPUT); |
4488 // Compute referenced names. | 4500 // Compute referenced names. |
4489 ReferencedNames referencedNames = new ReferencedNames(); | 4501 ReferencedNames referencedNames = new ReferencedNames(); |
4490 for (CompilationUnit unit in units) { | 4502 for (CompilationUnit unit in units) { |
4491 new ReferencedNamesBuilder(referencedNames).build(unit); | 4503 new ReferencedNamesBuilder(referencedNames).build(unit); |
4492 } | 4504 } |
4493 // | 4505 // |
4494 // Record outputs. | 4506 // Record outputs. |
4495 // | 4507 // |
4496 outputs[LIBRARY_ELEMENT] = library; | 4508 outputs[LIBRARY_ELEMENT8] = library; |
4497 outputs[REFERENCED_NAMES] = referencedNames; | 4509 outputs[REFERENCED_NAMES] = referencedNames; |
4498 } | 4510 } |
4499 | 4511 |
4500 /** | 4512 /** |
4501 * Return a map from the names of the inputs of this kind of task to the task | 4513 * Return a map from the names of the inputs of this kind of task to the task |
4502 * input descriptors describing those inputs for a task with the | 4514 * input descriptors describing those inputs for a task with the |
4503 * given [target]. | 4515 * given [target]. |
4504 */ | 4516 */ |
4505 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 4517 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
4506 Source source = target; | 4518 Source source = target; |
4507 return <String, TaskInput>{ | 4519 return <String, TaskInput>{ |
4508 LIBRARY_INPUT: LIBRARY_ELEMENT5.of(source), | 4520 LIBRARY_INPUT: LIBRARY_ELEMENT7.of(source), |
4509 UNITS_INPUT: LIBRARY_SPECIFIC_UNITS.of(source).toListOf(RESOLVED_UNIT10), | 4521 UNITS_INPUT: LIBRARY_SPECIFIC_UNITS.of(source).toListOf(RESOLVED_UNIT10), |
4510 'thisLibraryClosureIsReady': READY_RESOLVED_UNIT10.of(source), | 4522 'thisLibraryClosureIsReady': READY_RESOLVED_UNIT10.of(source), |
4511 }; | 4523 }; |
4512 } | 4524 } |
4513 | 4525 |
4514 /** | 4526 /** |
4515 * Create a [ResolveLibraryReferencesTask] based on the given [target] in | 4527 * Create a [ResolveLibraryReferencesTask] based on the given [target] in |
4516 * the given [context]. | 4528 * the given [context]. |
4517 */ | 4529 */ |
4518 static ResolveLibraryReferencesTask createTask( | 4530 static ResolveLibraryReferencesTask createTask( |
4519 AnalysisContext context, AnalysisTarget target) { | 4531 AnalysisContext context, AnalysisTarget target) { |
4520 return new ResolveLibraryReferencesTask(context, target); | 4532 return new ResolveLibraryReferencesTask(context, target); |
4521 } | 4533 } |
4522 } | 4534 } |
4523 | 4535 |
4524 /** | 4536 /** |
4537 * A task that finishes resolution by requesting [RESOLVED_UNIT11] for every | |
4538 * unit in the libraries closure and produces [LIBRARY_ELEMENT]. | |
4539 */ | |
4540 class ResolveLibraryTask extends SourceBasedAnalysisTask { | |
4541 /** | |
4542 * The name of the [LIBRARY_ELEMENT8] input. | |
4543 */ | |
4544 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; | |
4545 | |
4546 /** | |
4547 * The name of the list of [RESOLVED_UNIT11] input. | |
4548 */ | |
4549 static const String UNITS_INPUT = 'UNITS_INPUT'; | |
4550 | |
4551 /** | |
4552 * The task descriptor describing this kind of task. | |
4553 */ | |
4554 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | |
4555 'ResolveLibraryTask', | |
4556 createTask, | |
4557 buildInputs, | |
4558 <ResultDescriptor>[LIBRARY_ELEMENT]); | |
4559 | |
4560 ResolveLibraryTask(InternalAnalysisContext context, AnalysisTarget target) | |
4561 : super(context, target); | |
4562 | |
4563 @override | |
4564 TaskDescriptor get descriptor => DESCRIPTOR; | |
4565 | |
4566 @override | |
4567 void internalPerform() { | |
4568 // | |
4569 // Prepare inputs. | |
4570 // | |
4571 LibraryElement library = getRequiredInput(LIBRARY_INPUT); | |
4572 // | |
4573 // Record outputs. | |
4574 // | |
4575 outputs[LIBRARY_ELEMENT] = library; | |
4576 } | |
4577 | |
4578 /** | |
4579 * Return a map from the names of the inputs of this kind of task to the task | |
4580 * input descriptors describing those inputs for a task with the | |
4581 * given [target]. | |
4582 */ | |
4583 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | |
4584 Source source = target; | |
4585 return <String, TaskInput>{ | |
4586 LIBRARY_INPUT: LIBRARY_ELEMENT8.of(source), | |
4587 UNITS_INPUT: LIBRARY_SPECIFIC_UNITS.of(source).toListOf(RESOLVED_UNIT11), | |
scheglov
2015/11/24 22:17:23
This input is not used.
Brian Wilkerson
2015/11/25 14:44:41
Removed
| |
4588 'thisLibraryClosureIsReady': READY_RESOLVED_UNIT.of(source), | |
4589 }; | |
4590 } | |
4591 | |
4592 /** | |
4593 * Create a [ResolveLibraryTask] based on the given [target] in the given | |
4594 * [context]. | |
4595 */ | |
4596 static ResolveLibraryTask createTask( | |
4597 AnalysisContext context, AnalysisTarget target) { | |
4598 return new ResolveLibraryTask(context, target); | |
4599 } | |
4600 } | |
4601 | |
4602 /** | |
4525 * An artificial task that does nothing except to force type names resolution | 4603 * An artificial task that does nothing except to force type names resolution |
4526 * for the defining and part units of a library. | 4604 * for the defining and part units of a library. |
4527 */ | 4605 */ |
4528 class ResolveLibraryTypeNamesTask extends SourceBasedAnalysisTask { | 4606 class ResolveLibraryTypeNamesTask extends SourceBasedAnalysisTask { |
4529 /** | 4607 /** |
4530 * The name of the [LIBRARY_ELEMENT4] input. | 4608 * The name of the [LIBRARY_ELEMENT4] input. |
4531 */ | 4609 */ |
4532 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; | 4610 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; |
4533 | 4611 |
4534 /** | 4612 /** |
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5273 | 5351 |
5274 @override | 5352 @override |
5275 bool moveNext() { | 5353 bool moveNext() { |
5276 if (_newSources.isEmpty) { | 5354 if (_newSources.isEmpty) { |
5277 return false; | 5355 return false; |
5278 } | 5356 } |
5279 currentTarget = _newSources.removeLast(); | 5357 currentTarget = _newSources.removeLast(); |
5280 return true; | 5358 return true; |
5281 } | 5359 } |
5282 } | 5360 } |
OLD | NEW |