| 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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 * | 335 * |
| 336 * The list will be empty if there were no errors, but will not be `null`. | 336 * The list will be empty if there were no errors, but will not be `null`. |
| 337 * | 337 * |
| 338 * The result is only available for [LibrarySpecificUnit]s. | 338 * The result is only available for [LibrarySpecificUnit]s. |
| 339 */ | 339 */ |
| 340 final ListResultDescriptor<AnalysisError> RESOLVE_FUNCTION_BODIES_ERRORS = | 340 final ListResultDescriptor<AnalysisError> RESOLVE_FUNCTION_BODIES_ERRORS = |
| 341 new ListResultDescriptor<AnalysisError>( | 341 new ListResultDescriptor<AnalysisError>( |
| 342 'RESOLVE_FUNCTION_BODIES_ERRORS', AnalysisError.NO_ERRORS); | 342 'RESOLVE_FUNCTION_BODIES_ERRORS', AnalysisError.NO_ERRORS); |
| 343 | 343 |
| 344 /** | 344 /** |
| 345 * The errors produced while resolving references. | |
| 346 * | |
| 347 * The list will be empty if there were no errors, but will not be `null`. | |
| 348 * | |
| 349 * The result is only available for [LibrarySpecificUnit]s. | |
| 350 */ | |
| 351 final ListResultDescriptor<AnalysisError> RESOLVE_REFERENCES_ERRORS = | |
| 352 new ListResultDescriptor<AnalysisError>( | |
| 353 'RESOLVE_REFERENCES_ERRORS', AnalysisError.NO_ERRORS); | |
| 354 | |
| 355 /** | |
| 356 * The errors produced while resolving type names. | 345 * The errors produced while resolving type names. |
| 357 * | 346 * |
| 358 * The list will be empty if there were no errors, but will not be `null`. | 347 * The list will be empty if there were no errors, but will not be `null`. |
| 359 * | 348 * |
| 360 * The result is only available for [LibrarySpecificUnit]s. | 349 * The result is only available for [LibrarySpecificUnit]s. |
| 361 */ | 350 */ |
| 362 final ListResultDescriptor<AnalysisError> RESOLVE_TYPE_NAMES_ERRORS = | 351 final ListResultDescriptor<AnalysisError> RESOLVE_TYPE_NAMES_ERRORS = |
| 363 new ListResultDescriptor<AnalysisError>( | 352 new ListResultDescriptor<AnalysisError>( |
| 364 'RESOLVE_TYPE_NAMES_ERRORS', AnalysisError.NO_ERRORS); | 353 'RESOLVE_TYPE_NAMES_ERRORS', AnalysisError.NO_ERRORS); |
| 365 | 354 |
| (...skipping 3239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3605 * Create a [ResolveLibraryTypeNamesTask] based on the given [target] in | 3594 * Create a [ResolveLibraryTypeNamesTask] based on the given [target] in |
| 3606 * the given [context]. | 3595 * the given [context]. |
| 3607 */ | 3596 */ |
| 3608 static ResolveLibraryTypeNamesTask createTask( | 3597 static ResolveLibraryTypeNamesTask createTask( |
| 3609 AnalysisContext context, AnalysisTarget target) { | 3598 AnalysisContext context, AnalysisTarget target) { |
| 3610 return new ResolveLibraryTypeNamesTask(context, target); | 3599 return new ResolveLibraryTypeNamesTask(context, target); |
| 3611 } | 3600 } |
| 3612 } | 3601 } |
| 3613 | 3602 |
| 3614 /** | 3603 /** |
| 3615 * A task that builds [RESOLVED_UNIT8] for a unit. | |
| 3616 */ | |
| 3617 class ResolveUnitReferencesTask extends SourceBasedAnalysisTask { | |
| 3618 /** | |
| 3619 * The name of the [LIBRARY_ELEMENT5] input. | |
| 3620 */ | |
| 3621 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; | |
| 3622 | |
| 3623 /** | |
| 3624 * The name of the [RESOLVED_UNIT4] input. | |
| 3625 */ | |
| 3626 static const String UNIT_INPUT = 'UNIT_INPUT'; | |
| 3627 | |
| 3628 /** | |
| 3629 * The name of the [TYPE_PROVIDER] input. | |
| 3630 */ | |
| 3631 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; | |
| 3632 | |
| 3633 /** | |
| 3634 * The task descriptor describing this kind of task. | |
| 3635 */ | |
| 3636 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | |
| 3637 'ResolveUnitReferencesTask', | |
| 3638 createTask, | |
| 3639 buildInputs, | |
| 3640 <ResultDescriptor>[RESOLVE_REFERENCES_ERRORS, RESOLVED_UNIT8]); | |
| 3641 | |
| 3642 ResolveUnitReferencesTask( | |
| 3643 InternalAnalysisContext context, AnalysisTarget target) | |
| 3644 : super(context, target); | |
| 3645 | |
| 3646 @override | |
| 3647 TaskDescriptor get descriptor => DESCRIPTOR; | |
| 3648 | |
| 3649 @override | |
| 3650 void internalPerform() { | |
| 3651 RecordingErrorListener errorListener = new RecordingErrorListener(); | |
| 3652 // | |
| 3653 // Prepare inputs. | |
| 3654 // | |
| 3655 LibraryElement libraryElement = getRequiredInput(LIBRARY_INPUT); | |
| 3656 CompilationUnit unit = getRequiredInput(UNIT_INPUT); | |
| 3657 CompilationUnitElement unitElement = unit.element; | |
| 3658 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); | |
| 3659 // | |
| 3660 // Resolve references. | |
| 3661 // | |
| 3662 InheritanceManager inheritanceManager = | |
| 3663 new InheritanceManager(libraryElement); | |
| 3664 AstVisitor visitor = new ResolverVisitor( | |
| 3665 libraryElement, unitElement.source, typeProvider, errorListener, | |
| 3666 inheritanceManager: inheritanceManager); | |
| 3667 unit.accept(visitor); | |
| 3668 // | |
| 3669 // Record outputs. | |
| 3670 // | |
| 3671 outputs[RESOLVE_REFERENCES_ERRORS] = | |
| 3672 removeDuplicateErrors(errorListener.errors); | |
| 3673 outputs[RESOLVED_UNIT8] = unit; | |
| 3674 } | |
| 3675 | |
| 3676 /** | |
| 3677 * Return a map from the names of the inputs of this kind of task to the task | |
| 3678 * input descriptors describing those inputs for a task with the | |
| 3679 * given [target]. | |
| 3680 */ | |
| 3681 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | |
| 3682 LibrarySpecificUnit unit = target; | |
| 3683 return <String, TaskInput>{ | |
| 3684 'fullyBuiltLibraryElements': IMPORT_EXPORT_SOURCE_CLOSURE | |
| 3685 .of(unit.library) | |
| 3686 .toListOf(LIBRARY_ELEMENT5), | |
| 3687 LIBRARY_INPUT: LIBRARY_ELEMENT5.of(unit.library), | |
| 3688 UNIT_INPUT: RESOLVED_UNIT4.of(unit), | |
| 3689 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) | |
| 3690 }; | |
| 3691 } | |
| 3692 | |
| 3693 /** | |
| 3694 * Create a [ResolveUnitReferencesTask] based on the given [target] in | |
| 3695 * the given [context]. | |
| 3696 */ | |
| 3697 static ResolveUnitReferencesTask createTask( | |
| 3698 AnalysisContext context, AnalysisTarget target) { | |
| 3699 return new ResolveUnitReferencesTask(context, target); | |
| 3700 } | |
| 3701 } | |
| 3702 | |
| 3703 /** | |
| 3704 * A task that builds [RESOLVED_UNIT3] for a unit. | 3604 * A task that builds [RESOLVED_UNIT3] for a unit. |
| 3705 */ | 3605 */ |
| 3706 class ResolveUnitTypeNamesTask extends SourceBasedAnalysisTask { | 3606 class ResolveUnitTypeNamesTask extends SourceBasedAnalysisTask { |
| 3707 /** | 3607 /** |
| 3708 * The name of the input whose value is the defining [LIBRARY_ELEMENT4]. | 3608 * The name of the input whose value is the defining [LIBRARY_ELEMENT4]. |
| 3709 */ | 3609 */ |
| 3710 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; | 3610 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; |
| 3711 | 3611 |
| 3712 /** | 3612 /** |
| 3713 * The name of the [RESOLVED_UNIT2] input. | 3613 * The name of the [RESOLVED_UNIT2] input. |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4224 | 4124 |
| 4225 @override | 4125 @override |
| 4226 bool moveNext() { | 4126 bool moveNext() { |
| 4227 if (_newSources.isEmpty) { | 4127 if (_newSources.isEmpty) { |
| 4228 return false; | 4128 return false; |
| 4229 } | 4129 } |
| 4230 currentTarget = _newSources.removeLast(); | 4130 currentTarget = _newSources.removeLast(); |
| 4231 return true; | 4131 return true; |
| 4232 } | 4132 } |
| 4233 } | 4133 } |
| OLD | NEW |