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 * The same as a [LIBRARY_ELEMENT7]. | |
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 /** | |
322 * The flag specifying whether all analysis errors are computed in a specific | 311 * The flag specifying whether all analysis errors are computed in a specific |
323 * library. | 312 * library. |
324 * | 313 * |
325 * The result is only available for [Source]s representing a library. | 314 * The result is only available for [Source]s representing a library. |
326 */ | 315 */ |
327 final ResultDescriptor<bool> LIBRARY_ERRORS_READY = | 316 final ResultDescriptor<bool> LIBRARY_ERRORS_READY = |
328 new ResultDescriptor<bool>('LIBRARY_ERRORS_READY', false); | 317 new ResultDescriptor<bool>('LIBRARY_ERRORS_READY', false); |
329 | 318 |
330 /** | 319 /** |
331 * The [LibrarySpecificUnit]s that a library consists of. | 320 * The [LibrarySpecificUnit]s that a library consists of. |
(...skipping 2089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2421 } | 2410 } |
2422 | 2411 |
2423 /** | 2412 /** |
2424 * Return a map from the names of the inputs of this kind of task to the task | 2413 * Return a map from the names of the inputs of this kind of task to the task |
2425 * input descriptors describing those inputs for a task with the | 2414 * input descriptors describing those inputs for a task with the |
2426 * given [target]. | 2415 * given [target]. |
2427 */ | 2416 */ |
2428 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 2417 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
2429 LibrarySpecificUnit unit = target; | 2418 LibrarySpecificUnit unit = target; |
2430 return <String, TaskInput>{ | 2419 return <String, TaskInput>{ |
2431 'libraryElement': LIBRARY_ELEMENT8.of(unit.library), | 2420 'libraryElement': LIBRARY_ELEMENT.of(unit.library), |
2432 UNIT_INPUT: RESOLVED_UNIT10.of(unit), | 2421 UNIT_INPUT: RESOLVED_UNIT10.of(unit), |
2433 CONSTANT_VALUES: | 2422 CONSTANT_VALUES: |
2434 COMPILATION_UNIT_CONSTANTS.of(unit).toListOf(CONSTANT_VALUE) | 2423 COMPILATION_UNIT_CONSTANTS.of(unit).toListOf(CONSTANT_VALUE) |
2435 }; | 2424 }; |
2436 } | 2425 } |
2437 | 2426 |
2438 /** | 2427 /** |
2439 * Create an [EvaluateUnitConstantsTask] based on the given [target] in | 2428 * Create an [EvaluateUnitConstantsTask] based on the given [target] in |
2440 * the given [context]. | 2429 * the given [context]. |
2441 */ | 2430 */ |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3231 } | 3220 } |
3232 | 3221 |
3233 /** | 3222 /** |
3234 * Return a map from the names of the inputs of this kind of task to the task | 3223 * Return a map from the names of the inputs of this kind of task to the task |
3235 * input descriptors describing those inputs for a task with the | 3224 * input descriptors describing those inputs for a task with the |
3236 * given [target]. | 3225 * given [target]. |
3237 */ | 3226 */ |
3238 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 3227 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
3239 Source source = target; | 3228 Source source = target; |
3240 return <String, TaskInput>{ | 3229 return <String, TaskInput>{ |
3241 'allErrors': UNITS.of(source).toListOf(DART_ERRORS), | 3230 'allErrors': UNITS.of(source).toListOf(DART_ERRORS) |
3242 'libraryElement': LIBRARY_ELEMENT.of(source) | |
3243 }; | 3231 }; |
3244 } | 3232 } |
3245 | 3233 |
3246 /** | 3234 /** |
3247 * Create a [LibraryErrorsReadyTask] based on the given [target] in the given | 3235 * Create a [LibraryErrorsReadyTask] based on the given [target] in the given |
3248 * [context]. | 3236 * [context]. |
3249 */ | 3237 */ |
3250 static LibraryErrorsReadyTask createTask( | 3238 static LibraryErrorsReadyTask createTask( |
3251 AnalysisContext context, AnalysisTarget target) { | 3239 AnalysisContext context, AnalysisTarget target) { |
3252 return new LibraryErrorsReadyTask(context, target); | 3240 return new LibraryErrorsReadyTask(context, target); |
(...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4463 * the given [context]. | 4451 * the given [context]. |
4464 */ | 4452 */ |
4465 static ResolveInstanceFieldsInUnitTask createTask( | 4453 static ResolveInstanceFieldsInUnitTask createTask( |
4466 AnalysisContext context, AnalysisTarget target) { | 4454 AnalysisContext context, AnalysisTarget target) { |
4467 return new ResolveInstanceFieldsInUnitTask(context, target); | 4455 return new ResolveInstanceFieldsInUnitTask(context, target); |
4468 } | 4456 } |
4469 } | 4457 } |
4470 | 4458 |
4471 /** | 4459 /** |
4472 * A task that finishes resolution by requesting [RESOLVED_UNIT10] for every | 4460 * A task that finishes resolution by requesting [RESOLVED_UNIT10] for every |
4473 * unit in the libraries closure and produces [LIBRARY_ELEMENT8]. | 4461 * unit in the libraries closure and produces [LIBRARY_ELEMENT]. |
4474 */ | 4462 */ |
4475 class ResolveLibraryReferencesTask extends SourceBasedAnalysisTask { | 4463 class ResolveLibraryReferencesTask extends SourceBasedAnalysisTask { |
4476 /** | 4464 /** |
4477 * The name of the [LIBRARY_ELEMENT7] input. | 4465 * The name of the [LIBRARY_ELEMENT5] input. |
4478 */ | 4466 */ |
4479 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; | 4467 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; |
4480 | 4468 |
4481 /** | 4469 /** |
4482 * The name of the list of [RESOLVED_UNIT10] input. | 4470 * The name of the list of [RESOLVED_UNIT10] input. |
4483 */ | 4471 */ |
4484 static const String UNITS_INPUT = 'UNITS_INPUT'; | 4472 static const String UNITS_INPUT = 'UNITS_INPUT'; |
4485 | 4473 |
4486 /** | 4474 /** |
4487 * The task descriptor describing this kind of task. | 4475 * The task descriptor describing this kind of task. |
4488 */ | 4476 */ |
4489 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 4477 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
4490 'ResolveLibraryReferencesTask', | 4478 'ResolveLibraryReferencesTask', |
4491 createTask, | 4479 createTask, |
4492 buildInputs, | 4480 buildInputs, |
4493 <ResultDescriptor>[LIBRARY_ELEMENT8, REFERENCED_NAMES]); | 4481 <ResultDescriptor>[LIBRARY_ELEMENT, REFERENCED_NAMES]); |
4494 | 4482 |
4495 ResolveLibraryReferencesTask( | 4483 ResolveLibraryReferencesTask( |
4496 InternalAnalysisContext context, AnalysisTarget target) | 4484 InternalAnalysisContext context, AnalysisTarget target) |
4497 : super(context, target); | 4485 : super(context, target); |
4498 | 4486 |
4499 @override | 4487 @override |
4500 TaskDescriptor get descriptor => DESCRIPTOR; | 4488 TaskDescriptor get descriptor => DESCRIPTOR; |
4501 | 4489 |
4502 @override | 4490 @override |
4503 void internalPerform() { | 4491 void internalPerform() { |
4504 // | 4492 // |
4505 // Prepare inputs. | 4493 // Prepare inputs. |
4506 // | 4494 // |
4507 LibraryElement library = getRequiredInput(LIBRARY_INPUT); | 4495 LibraryElement library = getRequiredInput(LIBRARY_INPUT); |
4508 List<CompilationUnit> units = getRequiredInput(UNITS_INPUT); | 4496 List<CompilationUnit> units = getRequiredInput(UNITS_INPUT); |
4509 // Compute referenced names. | 4497 // Compute referenced names. |
4510 ReferencedNames referencedNames = new ReferencedNames(); | 4498 ReferencedNames referencedNames = new ReferencedNames(); |
4511 for (CompilationUnit unit in units) { | 4499 for (CompilationUnit unit in units) { |
4512 new ReferencedNamesBuilder(referencedNames).build(unit); | 4500 new ReferencedNamesBuilder(referencedNames).build(unit); |
4513 } | 4501 } |
4514 // | 4502 // |
4515 // Record outputs. | 4503 // Record outputs. |
4516 // | 4504 // |
4517 outputs[LIBRARY_ELEMENT8] = library; | 4505 outputs[LIBRARY_ELEMENT] = library; |
4518 outputs[REFERENCED_NAMES] = referencedNames; | 4506 outputs[REFERENCED_NAMES] = referencedNames; |
4519 } | 4507 } |
4520 | 4508 |
4521 /** | 4509 /** |
4522 * Return a map from the names of the inputs of this kind of task to the task | 4510 * Return a map from the names of the inputs of this kind of task to the task |
4523 * input descriptors describing those inputs for a task with the | 4511 * input descriptors describing those inputs for a task with the |
4524 * given [target]. | 4512 * given [target]. |
4525 */ | 4513 */ |
4526 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 4514 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
4527 Source source = target; | 4515 Source source = target; |
4528 return <String, TaskInput>{ | 4516 return <String, TaskInput>{ |
4529 LIBRARY_INPUT: LIBRARY_ELEMENT7.of(source), | 4517 LIBRARY_INPUT: LIBRARY_ELEMENT5.of(source), |
4530 UNITS_INPUT: LIBRARY_SPECIFIC_UNITS.of(source).toListOf(RESOLVED_UNIT10), | 4518 UNITS_INPUT: LIBRARY_SPECIFIC_UNITS.of(source).toListOf(RESOLVED_UNIT10), |
4531 'thisLibraryClosureIsReady': READY_RESOLVED_UNIT10.of(source), | 4519 'thisLibraryClosureIsReady': READY_RESOLVED_UNIT10.of(source), |
4532 }; | 4520 }; |
4533 } | 4521 } |
4534 | 4522 |
4535 /** | 4523 /** |
4536 * Create a [ResolveLibraryReferencesTask] based on the given [target] in | 4524 * Create a [ResolveLibraryReferencesTask] based on the given [target] in |
4537 * the given [context]. | 4525 * the given [context]. |
4538 */ | 4526 */ |
4539 static ResolveLibraryReferencesTask createTask( | 4527 static ResolveLibraryReferencesTask createTask( |
4540 AnalysisContext context, AnalysisTarget target) { | 4528 AnalysisContext context, AnalysisTarget target) { |
4541 return new ResolveLibraryReferencesTask(context, target); | 4529 return new ResolveLibraryReferencesTask(context, target); |
4542 } | 4530 } |
4543 } | 4531 } |
4544 | 4532 |
4545 /** | 4533 /** |
4546 * A task that finishes resolution by requesting [RESOLVED_UNIT11] for every | |
4547 * unit in the libraries closure and produces [LIBRARY_ELEMENT]. | |
4548 */ | |
4549 class ResolveLibraryTask extends SourceBasedAnalysisTask { | |
4550 /** | |
4551 * The name of the [LIBRARY_ELEMENT8] input. | |
4552 */ | |
4553 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; | |
4554 | |
4555 /** | |
4556 * The name of the list of [RESOLVED_UNIT11] input. | |
4557 */ | |
4558 static const String UNITS_INPUT = 'UNITS_INPUT'; | |
4559 | |
4560 /** | |
4561 * The task descriptor describing this kind of task. | |
4562 */ | |
4563 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | |
4564 'ResolveLibraryTask', | |
4565 createTask, | |
4566 buildInputs, | |
4567 <ResultDescriptor>[LIBRARY_ELEMENT]); | |
4568 | |
4569 ResolveLibraryTask(InternalAnalysisContext context, AnalysisTarget target) | |
4570 : super(context, target); | |
4571 | |
4572 @override | |
4573 TaskDescriptor get descriptor => DESCRIPTOR; | |
4574 | |
4575 @override | |
4576 void internalPerform() { | |
4577 // | |
4578 // Prepare inputs. | |
4579 // | |
4580 LibraryElement library = getRequiredInput(LIBRARY_INPUT); | |
4581 // | |
4582 // Record outputs. | |
4583 // | |
4584 outputs[LIBRARY_ELEMENT] = library; | |
4585 } | |
4586 | |
4587 /** | |
4588 * Return a map from the names of the inputs of this kind of task to the task | |
4589 * input descriptors describing those inputs for a task with the | |
4590 * given [target]. | |
4591 */ | |
4592 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | |
4593 Source source = target; | |
4594 return <String, TaskInput>{ | |
4595 LIBRARY_INPUT: LIBRARY_ELEMENT8.of(source), | |
4596 'thisLibraryClosureIsReady': READY_RESOLVED_UNIT.of(source), | |
4597 }; | |
4598 } | |
4599 | |
4600 /** | |
4601 * Create a [ResolveLibraryTask] based on the given [target] in the given | |
4602 * [context]. | |
4603 */ | |
4604 static ResolveLibraryTask createTask( | |
4605 AnalysisContext context, AnalysisTarget target) { | |
4606 return new ResolveLibraryTask(context, target); | |
4607 } | |
4608 } | |
4609 | |
4610 /** | |
4611 * An artificial task that does nothing except to force type names resolution | 4534 * An artificial task that does nothing except to force type names resolution |
4612 * for the defining and part units of a library. | 4535 * for the defining and part units of a library. |
4613 */ | 4536 */ |
4614 class ResolveLibraryTypeNamesTask extends SourceBasedAnalysisTask { | 4537 class ResolveLibraryTypeNamesTask extends SourceBasedAnalysisTask { |
4615 /** | 4538 /** |
4616 * The name of the [LIBRARY_ELEMENT4] input. | 4539 * The name of the [LIBRARY_ELEMENT4] input. |
4617 */ | 4540 */ |
4618 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; | 4541 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; |
4619 | 4542 |
4620 /** | 4543 /** |
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5359 | 5282 |
5360 @override | 5283 @override |
5361 bool moveNext() { | 5284 bool moveNext() { |
5362 if (_newSources.isEmpty) { | 5285 if (_newSources.isEmpty) { |
5363 return false; | 5286 return false; |
5364 } | 5287 } |
5365 currentTarget = _newSources.removeLast(); | 5288 currentTarget = _newSources.removeLast(); |
5366 return true; | 5289 return true; |
5367 } | 5290 } |
5368 } | 5291 } |
OLD | NEW |