| 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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 340  * | 340  * | 
| 341  * The list will be empty if there were no errors, but will not be `null`. | 341  * The list will be empty if there were no errors, but will not be `null`. | 
| 342  * | 342  * | 
| 343  * The result is only available for [Source]s representing a compilation unit. | 343  * The result is only available for [Source]s representing a compilation unit. | 
| 344  */ | 344  */ | 
| 345 final ListResultDescriptor<AnalysisError> PARSE_ERRORS = | 345 final ListResultDescriptor<AnalysisError> PARSE_ERRORS = | 
| 346     new ListResultDescriptor<AnalysisError>( | 346     new ListResultDescriptor<AnalysisError>( | 
| 347         'PARSE_ERRORS', AnalysisError.NO_ERRORS); | 347         'PARSE_ERRORS', AnalysisError.NO_ERRORS); | 
| 348 | 348 | 
| 349 /** | 349 /** | 
|  | 350  * The flag specifying that [RESOLVED_UNIT] is ready for a library. | 
|  | 351  * | 
|  | 352  * The result is only available for [Source]s representing a library. | 
|  | 353  */ | 
|  | 354 final ResultDescriptor<bool> READY_RESOLVED_UNIT = | 
|  | 355     new ResultDescriptor<bool>('READY_RESOLVED_UNIT', false); | 
|  | 356 | 
|  | 357 /** | 
|  | 358  * The flag specifying that [RESOLVED_UNIT10] is ready for a library. | 
|  | 359  * | 
|  | 360  * The result is only available for [Source]s representing a library. | 
|  | 361  */ | 
|  | 362 final ResultDescriptor<bool> READY_RESOLVED_UNIT10 = | 
|  | 363     new ResultDescriptor<bool>('READY_RESOLVED_UNIT10', false); | 
|  | 364 | 
|  | 365 /** | 
|  | 366  * The flag specifying that [RESOLVED_UNIT9] is ready for a library. | 
|  | 367  * | 
|  | 368  * The result is only available for [Source]s representing a library. | 
|  | 369  */ | 
|  | 370 final ResultDescriptor<bool> READY_RESOLVED_UNIT9 = | 
|  | 371     new ResultDescriptor<bool>('READY_RESOLVED_UNIT9', false); | 
|  | 372 | 
|  | 373 /** | 
| 350  * The names (resolved and not) referenced by a unit. | 374  * The names (resolved and not) referenced by a unit. | 
| 351  * | 375  * | 
| 352  * The result is only available for [Source]s representing a compilation unit. | 376  * The result is only available for [Source]s representing a compilation unit. | 
| 353  */ | 377  */ | 
| 354 final ResultDescriptor<ReferencedNames> REFERENCED_NAMES = | 378 final ResultDescriptor<ReferencedNames> REFERENCED_NAMES = | 
| 355     new ResultDescriptor<ReferencedNames>('REFERENCED_NAMES', null); | 379     new ResultDescriptor<ReferencedNames>('REFERENCED_NAMES', null); | 
| 356 | 380 | 
| 357 /** | 381 /** | 
| 358  * The errors produced while resolving type names. | 382  * The errors produced while resolving type names. | 
| 359  * | 383  * | 
| (...skipping 3154 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3514   void _addPublicNames(CompilationUnitElement compilationUnit) { | 3538   void _addPublicNames(CompilationUnitElement compilationUnit) { | 
| 3515     compilationUnit.accessors.forEach(_addIfPublic); | 3539     compilationUnit.accessors.forEach(_addIfPublic); | 
| 3516     compilationUnit.enums.forEach(_addIfPublic); | 3540     compilationUnit.enums.forEach(_addIfPublic); | 
| 3517     compilationUnit.functions.forEach(_addIfPublic); | 3541     compilationUnit.functions.forEach(_addIfPublic); | 
| 3518     compilationUnit.functionTypeAliases.forEach(_addIfPublic); | 3542     compilationUnit.functionTypeAliases.forEach(_addIfPublic); | 
| 3519     compilationUnit.types.forEach(_addIfPublic); | 3543     compilationUnit.types.forEach(_addIfPublic); | 
| 3520   } | 3544   } | 
| 3521 } | 3545 } | 
| 3522 | 3546 | 
| 3523 /** | 3547 /** | 
|  | 3548  * A task that ensures that [RESOLVED_UNIT10] is ready for every unit of the | 
|  | 3549  * target library source and its import/export closure. | 
|  | 3550  */ | 
|  | 3551 class ReadyResolvedUnit10Task extends SourceBasedAnalysisTask { | 
|  | 3552   static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 
|  | 3553       'ReadyResolvedUnit10Task', | 
|  | 3554       createTask, | 
|  | 3555       buildInputs, | 
|  | 3556       <ResultDescriptor>[READY_RESOLVED_UNIT10]); | 
|  | 3557 | 
|  | 3558   ReadyResolvedUnit10Task( | 
|  | 3559       InternalAnalysisContext context, AnalysisTarget target) | 
|  | 3560       : super(context, target); | 
|  | 3561 | 
|  | 3562   @override | 
|  | 3563   TaskDescriptor get descriptor => DESCRIPTOR; | 
|  | 3564 | 
|  | 3565   @override | 
|  | 3566   bool get handlesDependencyCycles => true; | 
|  | 3567 | 
|  | 3568   @override | 
|  | 3569   void internalPerform() { | 
|  | 3570     outputs[READY_RESOLVED_UNIT10] = true; | 
|  | 3571   } | 
|  | 3572 | 
|  | 3573   static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 
|  | 3574     Source source = target; | 
|  | 3575     return <String, TaskInput>{ | 
|  | 3576       'thisLibraryUnitsReady': | 
|  | 3577           LIBRARY_SPECIFIC_UNITS.of(source).toListOf(RESOLVED_UNIT10), | 
|  | 3578       'directlyImportedLibrariesReady': | 
|  | 3579           IMPORTED_LIBRARIES.of(source).toListOf(READY_RESOLVED_UNIT10), | 
|  | 3580       'directlyExportedLibrariesReady': | 
|  | 3581           EXPORTED_LIBRARIES.of(source).toListOf(READY_RESOLVED_UNIT10), | 
|  | 3582     }; | 
|  | 3583   } | 
|  | 3584 | 
|  | 3585   static ReadyResolvedUnit10Task createTask( | 
|  | 3586       AnalysisContext context, AnalysisTarget target) { | 
|  | 3587     return new ReadyResolvedUnit10Task(context, target); | 
|  | 3588   } | 
|  | 3589 } | 
|  | 3590 | 
|  | 3591 /** | 
|  | 3592  * A task that ensures that [RESOLVED_UNIT9] is ready for every unit of the | 
|  | 3593  * target library source and its import/export closure. | 
|  | 3594  */ | 
|  | 3595 class ReadyResolvedUnit9Task extends SourceBasedAnalysisTask { | 
|  | 3596   static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 
|  | 3597       'ReadyResolvedUnit9Task', | 
|  | 3598       createTask, | 
|  | 3599       buildInputs, | 
|  | 3600       <ResultDescriptor>[READY_RESOLVED_UNIT9]); | 
|  | 3601 | 
|  | 3602   ReadyResolvedUnit9Task(InternalAnalysisContext context, AnalysisTarget target) | 
|  | 3603       : super(context, target); | 
|  | 3604 | 
|  | 3605   @override | 
|  | 3606   TaskDescriptor get descriptor => DESCRIPTOR; | 
|  | 3607 | 
|  | 3608   @override | 
|  | 3609   bool get handlesDependencyCycles => true; | 
|  | 3610 | 
|  | 3611   @override | 
|  | 3612   void internalPerform() { | 
|  | 3613     outputs[READY_RESOLVED_UNIT9] = true; | 
|  | 3614   } | 
|  | 3615 | 
|  | 3616   static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 
|  | 3617     Source source = target; | 
|  | 3618     return <String, TaskInput>{ | 
|  | 3619       'thisLibraryUnitsReady': | 
|  | 3620           LIBRARY_SPECIFIC_UNITS.of(source).toListOf(RESOLVED_UNIT9), | 
|  | 3621       'directlyImportedLibrariesReady': | 
|  | 3622           IMPORTED_LIBRARIES.of(source).toListOf(READY_RESOLVED_UNIT9), | 
|  | 3623       'directlyExportedLibrariesReady': | 
|  | 3624           EXPORTED_LIBRARIES.of(source).toListOf(READY_RESOLVED_UNIT9), | 
|  | 3625     }; | 
|  | 3626   } | 
|  | 3627 | 
|  | 3628   static ReadyResolvedUnit9Task createTask( | 
|  | 3629       AnalysisContext context, AnalysisTarget target) { | 
|  | 3630     return new ReadyResolvedUnit9Task(context, target); | 
|  | 3631   } | 
|  | 3632 } | 
|  | 3633 | 
|  | 3634 /** | 
|  | 3635  * A task that ensures that [RESOLVED_UNIT] is ready for every unit of the | 
|  | 3636  * target library source and its import/export closure. | 
|  | 3637  */ | 
|  | 3638 class ReadyResolvedUnitTask extends SourceBasedAnalysisTask { | 
|  | 3639   static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 
|  | 3640       'ReadyResolvedUnitTask', | 
|  | 3641       createTask, | 
|  | 3642       buildInputs, | 
|  | 3643       <ResultDescriptor>[READY_RESOLVED_UNIT]); | 
|  | 3644 | 
|  | 3645   ReadyResolvedUnitTask(InternalAnalysisContext context, AnalysisTarget target) | 
|  | 3646       : super(context, target); | 
|  | 3647 | 
|  | 3648   @override | 
|  | 3649   TaskDescriptor get descriptor => DESCRIPTOR; | 
|  | 3650 | 
|  | 3651   @override | 
|  | 3652   bool get handlesDependencyCycles => true; | 
|  | 3653 | 
|  | 3654   @override | 
|  | 3655   void internalPerform() { | 
|  | 3656     outputs[READY_RESOLVED_UNIT] = true; | 
|  | 3657   } | 
|  | 3658 | 
|  | 3659   static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 
|  | 3660     Source source = target; | 
|  | 3661     return <String, TaskInput>{ | 
|  | 3662       'thisLibraryUnitsReady': | 
|  | 3663           LIBRARY_SPECIFIC_UNITS.of(source).toListOf(RESOLVED_UNIT), | 
|  | 3664       'directlyImportedLibrariesReady': | 
|  | 3665           IMPORTED_LIBRARIES.of(source).toListOf(READY_RESOLVED_UNIT), | 
|  | 3666       'directlyExportedLibrariesReady': | 
|  | 3667           EXPORTED_LIBRARIES.of(source).toListOf(READY_RESOLVED_UNIT), | 
|  | 3668     }; | 
|  | 3669   } | 
|  | 3670 | 
|  | 3671   static ReadyResolvedUnitTask createTask( | 
|  | 3672       AnalysisContext context, AnalysisTarget target) { | 
|  | 3673     return new ReadyResolvedUnitTask(context, target); | 
|  | 3674   } | 
|  | 3675 } | 
|  | 3676 | 
|  | 3677 /** | 
| 3524  * Information about a library - which names it uses, which names it defines | 3678  * Information about a library - which names it uses, which names it defines | 
| 3525  * with their externally visible dependencies. | 3679  * with their externally visible dependencies. | 
| 3526  */ | 3680  */ | 
| 3527 class ReferencedNames { | 3681 class ReferencedNames { | 
| 3528   final Set<String> names = new Set<String>(); | 3682   final Set<String> names = new Set<String>(); | 
| 3529   final Map<String, Set<String>> userToDependsOn = <String, Set<String>>{}; | 3683   final Map<String, Set<String>> userToDependsOn = <String, Set<String>>{}; | 
| 3530 | 3684 | 
| 3531   /** | 3685   /** | 
| 3532    * Updates [delta] by adding names that are changed in this library. | 3686    * Updates [delta] by adding names that are changed in this library. | 
| 3533    */ | 3687    */ | 
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3728    * Create a [ResolveInstanceFieldsInUnitTask] based on the given [target] in | 3882    * Create a [ResolveInstanceFieldsInUnitTask] based on the given [target] in | 
| 3729    * the given [context]. | 3883    * the given [context]. | 
| 3730    */ | 3884    */ | 
| 3731   static ResolveInstanceFieldsInUnitTask createTask( | 3885   static ResolveInstanceFieldsInUnitTask createTask( | 
| 3732       AnalysisContext context, AnalysisTarget target) { | 3886       AnalysisContext context, AnalysisTarget target) { | 
| 3733     return new ResolveInstanceFieldsInUnitTask(context, target); | 3887     return new ResolveInstanceFieldsInUnitTask(context, target); | 
| 3734   } | 3888   } | 
| 3735 } | 3889 } | 
| 3736 | 3890 | 
| 3737 /** | 3891 /** | 
| 3738  * A task that finishes resolution by requesting [RESOLVED_UNIT_NO_CONSTANTS] fo
      r every | 3892  * A task that finishes resolution by requesting [RESOLVED_UNIT9] for every | 
| 3739  * unit in the libraries closure and produces [LIBRARY_ELEMENT]. | 3893  * unit in the libraries closure and produces [LIBRARY_ELEMENT]. | 
| 3740  */ | 3894  */ | 
| 3741 class ResolveLibraryReferencesTask extends SourceBasedAnalysisTask { | 3895 class ResolveLibraryReferencesTask extends SourceBasedAnalysisTask { | 
| 3742   /** | 3896   /** | 
| 3743    * The name of the [LIBRARY_ELEMENT5] input. | 3897    * The name of the [LIBRARY_ELEMENT5] input. | 
| 3744    */ | 3898    */ | 
| 3745   static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; | 3899   static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; | 
| 3746 | 3900 | 
| 3747   /** | 3901   /** | 
| 3748    * The name of the list of [RESOLVED_UNIT9] input. | 3902    * The name of the list of [RESOLVED_UNIT9] input. | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3787   /** | 3941   /** | 
| 3788    * Return a map from the names of the inputs of this kind of task to the task | 3942    * Return a map from the names of the inputs of this kind of task to the task | 
| 3789    * input descriptors describing those inputs for a task with the | 3943    * input descriptors describing those inputs for a task with the | 
| 3790    * given [target]. | 3944    * given [target]. | 
| 3791    */ | 3945    */ | 
| 3792   static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 3946   static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 
| 3793     Source source = target; | 3947     Source source = target; | 
| 3794     return <String, TaskInput>{ | 3948     return <String, TaskInput>{ | 
| 3795       LIBRARY_INPUT: LIBRARY_ELEMENT5.of(source), | 3949       LIBRARY_INPUT: LIBRARY_ELEMENT5.of(source), | 
| 3796       UNITS_INPUT: LIBRARY_SPECIFIC_UNITS.of(source).toListOf(RESOLVED_UNIT9), | 3950       UNITS_INPUT: LIBRARY_SPECIFIC_UNITS.of(source).toListOf(RESOLVED_UNIT9), | 
| 3797       'resolvedUnits': IMPORT_EXPORT_SOURCE_CLOSURE | 3951       'thisLibraryClosureIsReady': READY_RESOLVED_UNIT9.of(source), | 
| 3798           .of(source) |  | 
| 3799           .toFlattenListOf(LIBRARY_SPECIFIC_UNITS) |  | 
| 3800           .toListOf(RESOLVED_UNIT9), |  | 
| 3801     }; | 3952     }; | 
| 3802   } | 3953   } | 
| 3803 | 3954 | 
| 3804   /** | 3955   /** | 
| 3805    * Create a [ResolveLibraryReferencesTask] based on the given [target] in | 3956    * Create a [ResolveLibraryReferencesTask] based on the given [target] in | 
| 3806    * the given [context]. | 3957    * the given [context]. | 
| 3807    */ | 3958    */ | 
| 3808   static ResolveLibraryReferencesTask createTask( | 3959   static ResolveLibraryReferencesTask createTask( | 
| 3809       AnalysisContext context, AnalysisTarget target) { | 3960       AnalysisContext context, AnalysisTarget target) { | 
| 3810     return new ResolveLibraryReferencesTask(context, target); | 3961     return new ResolveLibraryReferencesTask(context, target); | 
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4313   } | 4464   } | 
| 4314 | 4465 | 
| 4315   /** | 4466   /** | 
| 4316    * Return a map from the names of the inputs of this kind of task to the task | 4467    * Return a map from the names of the inputs of this kind of task to the task | 
| 4317    * input descriptors describing those inputs for a task with the | 4468    * input descriptors describing those inputs for a task with the | 
| 4318    * given [target]. | 4469    * given [target]. | 
| 4319    */ | 4470    */ | 
| 4320   static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 4471   static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 
| 4321     LibrarySpecificUnit unit = target; | 4472     LibrarySpecificUnit unit = target; | 
| 4322     return <String, TaskInput>{ | 4473     return <String, TaskInput>{ | 
| 4323       'resolvedUnits': IMPORT_EXPORT_SOURCE_CLOSURE |  | 
| 4324           .of(unit.library) |  | 
| 4325           .toFlattenListOf(LIBRARY_SPECIFIC_UNITS) |  | 
| 4326           .toListOf(RESOLVED_UNIT10), |  | 
| 4327       UNIT_INPUT: RESOLVED_UNIT10.of(unit), | 4474       UNIT_INPUT: RESOLVED_UNIT10.of(unit), | 
| 4328       TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) | 4475       TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), | 
|  | 4476       'thisLibraryClosureIsReady': READY_RESOLVED_UNIT10.of(unit.library), | 
| 4329     }; | 4477     }; | 
| 4330   } | 4478   } | 
| 4331 | 4479 | 
| 4332   /** | 4480   /** | 
| 4333    * Create a [StrongModeVerifyUnitTask] based on the given [target] in | 4481    * Create a [StrongModeVerifyUnitTask] based on the given [target] in | 
| 4334    * the given [context]. | 4482    * the given [context]. | 
| 4335    */ | 4483    */ | 
| 4336   static StrongModeVerifyUnitTask createTask( | 4484   static StrongModeVerifyUnitTask createTask( | 
| 4337       AnalysisContext context, AnalysisTarget target) { | 4485       AnalysisContext context, AnalysisTarget target) { | 
| 4338     return new StrongModeVerifyUnitTask(context, target); | 4486     return new StrongModeVerifyUnitTask(context, target); | 
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4443   } | 4591   } | 
| 4444 | 4592 | 
| 4445   /** | 4593   /** | 
| 4446    * Return a map from the names of the inputs of this kind of task to the task | 4594    * Return a map from the names of the inputs of this kind of task to the task | 
| 4447    * input descriptors describing those inputs for a task with the | 4595    * input descriptors describing those inputs for a task with the | 
| 4448    * given [target]. | 4596    * given [target]. | 
| 4449    */ | 4597    */ | 
| 4450   static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 4598   static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 
| 4451     LibrarySpecificUnit unit = target; | 4599     LibrarySpecificUnit unit = target; | 
| 4452     return <String, TaskInput>{ | 4600     return <String, TaskInput>{ | 
| 4453       'resolvedUnits': IMPORT_EXPORT_SOURCE_CLOSURE | 4601       'thisLibraryClosureIsReady': READY_RESOLVED_UNIT.of(unit.library), | 
| 4454           .of(unit.library) |  | 
| 4455           .toFlattenListOf(LIBRARY_SPECIFIC_UNITS) |  | 
| 4456           .toListOf(RESOLVED_UNIT), |  | 
| 4457       UNIT_INPUT: RESOLVED_UNIT.of(unit), | 4602       UNIT_INPUT: RESOLVED_UNIT.of(unit), | 
| 4458       TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) | 4603       TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) | 
| 4459     }; | 4604     }; | 
| 4460   } | 4605   } | 
| 4461 | 4606 | 
| 4462   /** | 4607   /** | 
| 4463    * Create a [VerifyUnitTask] based on the given [target] in | 4608    * Create a [VerifyUnitTask] based on the given [target] in | 
| 4464    * the given [context]. | 4609    * the given [context]. | 
| 4465    */ | 4610    */ | 
| 4466   static VerifyUnitTask createTask( | 4611   static VerifyUnitTask createTask( | 
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4592 | 4737 | 
| 4593   @override | 4738   @override | 
| 4594   bool moveNext() { | 4739   bool moveNext() { | 
| 4595     if (_newSources.isEmpty) { | 4740     if (_newSources.isEmpty) { | 
| 4596       return false; | 4741       return false; | 
| 4597     } | 4742     } | 
| 4598     currentTarget = _newSources.removeLast(); | 4743     currentTarget = _newSources.removeLast(); | 
| 4599     return true; | 4744     return true; | 
| 4600   } | 4745   } | 
| 4601 } | 4746 } | 
| OLD | NEW | 
|---|