Chromium Code Reviews| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 */ | 72 */ |
| 73 final ListResultDescriptor<AnalysisError> BUILD_LIBRARY_ERRORS = | 73 final ListResultDescriptor<AnalysisError> BUILD_LIBRARY_ERRORS = |
| 74 new ListResultDescriptor<AnalysisError>( | 74 new ListResultDescriptor<AnalysisError>( |
| 75 'BUILD_LIBRARY_ERRORS', AnalysisError.NO_ERRORS); | 75 'BUILD_LIBRARY_ERRORS', AnalysisError.NO_ERRORS); |
| 76 | 76 |
| 77 /** | 77 /** |
| 78 * A list of the [ConstantEvaluationTarget]s defined in a unit. This includes | 78 * A list of the [ConstantEvaluationTarget]s defined in a unit. This includes |
| 79 * constants defined at top level, statically inside classes, and local to | 79 * constants defined at top level, statically inside classes, and local to |
| 80 * functions, as well as constant constructors, annotations, and default values | 80 * functions, as well as constant constructors, annotations, and default values |
| 81 * of parameters to constant constructors. | 81 * of parameters to constant constructors. |
| 82 * | |
| 83 * The result is only available for [LibrarySpecificUnit]s. | |
| 82 */ | 84 */ |
| 83 final ListResultDescriptor< | 85 final ListResultDescriptor< |
| 84 ConstantEvaluationTarget> COMPILATION_UNIT_CONSTANTS = | 86 ConstantEvaluationTarget> COMPILATION_UNIT_CONSTANTS = |
| 85 new ListResultDescriptor<ConstantEvaluationTarget>( | 87 new ListResultDescriptor<ConstantEvaluationTarget>( |
| 86 'COMPILATION_UNIT_CONSTANTS', null, | 88 'COMPILATION_UNIT_CONSTANTS', null, |
| 87 cachingPolicy: ELEMENT_CACHING_POLICY); | 89 cachingPolicy: ELEMENT_CACHING_POLICY); |
| 88 | 90 |
| 89 /** | 91 /** |
| 90 * The element model associated with a single compilation unit. | 92 * The element model associated with a single compilation unit. |
| 91 * | 93 * |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 105 * constructor, or a parameter element with a default value). | 107 * constructor, or a parameter element with a default value). |
| 106 */ | 108 */ |
| 107 final ListResultDescriptor<ConstantEvaluationTarget> CONSTANT_DEPENDENCIES = | 109 final ListResultDescriptor<ConstantEvaluationTarget> CONSTANT_DEPENDENCIES = |
| 108 new ListResultDescriptor<ConstantEvaluationTarget>( | 110 new ListResultDescriptor<ConstantEvaluationTarget>( |
| 109 'CONSTANT_DEPENDENCIES', const <ConstantEvaluationTarget>[]); | 111 'CONSTANT_DEPENDENCIES', const <ConstantEvaluationTarget>[]); |
| 110 | 112 |
| 111 /** | 113 /** |
| 112 * A [ConstantEvaluationTarget] that has been successfully constant-evaluated. | 114 * A [ConstantEvaluationTarget] that has been successfully constant-evaluated. |
| 113 * | 115 * |
| 114 * TODO(paulberry): is ELEMENT_CACHING_POLICY the correct caching policy? | 116 * TODO(paulberry): is ELEMENT_CACHING_POLICY the correct caching policy? |
| 117 * | |
| 118 * The result is only available for [ConstantEvaluationTarget]s. | |
| 119 * | |
| 115 */ | 120 */ |
| 116 final ResultDescriptor<ConstantEvaluationTarget> CONSTANT_VALUE = | 121 final ResultDescriptor<ConstantEvaluationTarget> CONSTANT_VALUE = |
| 117 new ResultDescriptor<ConstantEvaluationTarget>('CONSTANT_VALUE', null, | 122 new ResultDescriptor<ConstantEvaluationTarget>('CONSTANT_VALUE', null, |
| 118 cachingPolicy: ELEMENT_CACHING_POLICY); | 123 cachingPolicy: ELEMENT_CACHING_POLICY); |
| 119 | 124 |
| 120 /** | 125 /** |
| 121 * The sources representing the libraries that include a given source as a part. | 126 * The sources representing the libraries that include a given source as a part. |
| 122 * | 127 * |
| 123 * The result is only available for [Source]s representing a compilation unit. | 128 * The result is only available for [Source]s representing a compilation unit. |
| 124 */ | 129 */ |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 148 /** | 153 /** |
| 149 * The sources representing the combined import/export closure of a library. | 154 * The sources representing the combined import/export closure of a library. |
| 150 * The [Source]s include only library sources, not their units. | 155 * The [Source]s include only library sources, not their units. |
| 151 * | 156 * |
| 152 * The result is only available for [Source]s representing a library. | 157 * The result is only available for [Source]s representing a library. |
| 153 */ | 158 */ |
| 154 final ListResultDescriptor<Source> IMPORT_EXPORT_SOURCE_CLOSURE = | 159 final ListResultDescriptor<Source> IMPORT_EXPORT_SOURCE_CLOSURE = |
| 155 new ListResultDescriptor<Source>('IMPORT_EXPORT_SOURCE_CLOSURE', null); | 160 new ListResultDescriptor<Source>('IMPORT_EXPORT_SOURCE_CLOSURE', null); |
| 156 | 161 |
| 157 /** | 162 /** |
| 158 * The errors produced while inferring the type of a static variable. | 163 * A list of the [LibraryElement]s that make up the strongly connected |
| 164 * component in the import/export graph in which the target resides. | |
| 159 * | 165 * |
| 160 * The list will be empty if there were no errors, but will not be `null`. | 166 * Only non-empty in strongMode |
| 161 * | |
| 162 * The result is only available for [VariableElement]s, and only when strong | |
| 163 * mode is enabled. | |
| 164 */ | |
| 165 final ListResultDescriptor<AnalysisError> INFER_STATIC_VARIABLE_ERRORS = | |
| 166 new ListResultDescriptor<AnalysisError>( | |
| 167 'INFER_STATIC_VARIABLE_ERRORS', AnalysisError.NO_ERRORS); | |
| 168 | |
| 169 /** | |
| 170 * The errors produced while inferring the types of all of the static variables | |
| 171 * in a compilation unit. | |
| 172 * | |
| 173 * The list will be empty if there were no errors, but will not be `null`. | |
| 174 * | 167 * |
| 175 * The result is only available for [LibrarySpecificUnit]s. | 168 * The result is only available for [LibrarySpecificUnit]s. |
| 176 */ | 169 */ |
| 177 final ListResultDescriptor<AnalysisError> INFER_STATIC_VARIABLE_TYPES_ERRORS = | 170 final ListResultDescriptor<LibraryElement> LIBRARY_CYCLE = |
| 178 new ListResultDescriptor<AnalysisError>( | 171 new ListResultDescriptor<LibraryElement>('LIBRARY_CYCLE', null); |
| 179 'INFER_STATIC_VARIABLE_TYPES_ERRORS', AnalysisError.NO_ERRORS); | 172 |
| 173 /** | |
| 174 * A list of the [CompilationUnitElement]s (including all parts) that make up | |
| 175 * the strongly connected component in the import/export graph in which the | |
| 176 * target resides. | |
| 177 * | |
| 178 * Only non-empty in strongMode | |
| 179 * | |
| 180 * The result is only available for [LibrarySpecificUnit]s. | |
| 181 */ | |
| 182 final ListResultDescriptor<CompilationUnitElement> LIBRARY_CYCLE_UNITS = | |
| 183 new ListResultDescriptor<CompilationUnitElement>( | |
| 184 'LIBRARY_CYCLE_UNITS', null); | |
| 185 | |
| 186 /** | |
| 187 * A list of the [CompilationUnitElement]s that comprise all of the parts and | |
| 188 * libraries in the direct import/export dependencies of the library cycle | |
| 189 * of the target, with the intra-component dependencies excluded. | |
| 190 * | |
| 191 * Only non-empty in strongMode | |
| 192 * | |
| 193 * The result is only available for [LibrarySpecificUnit]s. | |
| 194 */ | |
| 195 final ListResultDescriptor<CompilationUnitElement> LIBRARY_CYCLE_DEPENDENCIES = | |
| 196 new ListResultDescriptor<CompilationUnitElement>( | |
| 197 'LIBRARY_CYCLE_DEPENDENCIES', null); | |
| 180 | 198 |
| 181 /** | 199 /** |
| 182 * A list of the [VariableElement]s whose type should be inferred that another | 200 * A list of the [VariableElement]s whose type should be inferred that another |
| 183 * inferable static variable (the target) depends on. | 201 * inferable static variable (the target) depends on. |
| 184 * | 202 * |
| 185 * The result is only available for [VariableElement]s, and only when strong | 203 * The result is only available for [VariableElement]s, and only when strong |
| 186 * mode is enabled. | 204 * mode is enabled. |
| 187 */ | 205 */ |
| 188 final ListResultDescriptor< | 206 final ListResultDescriptor< |
| 189 VariableElement> INFERABLE_STATIC_VARIABLE_DEPENDENCIES = | 207 VariableElement> INFERABLE_STATIC_VARIABLE_DEPENDENCIES = |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 308 * | 326 * |
| 309 * The list will be empty if there were no errors, but will not be `null`. | 327 * The list will be empty if there were no errors, but will not be `null`. |
| 310 * | 328 * |
| 311 * The result is only available for [Source]s representing a compilation unit. | 329 * The result is only available for [Source]s representing a compilation unit. |
| 312 */ | 330 */ |
| 313 final ListResultDescriptor<AnalysisError> PARSE_ERRORS = | 331 final ListResultDescriptor<AnalysisError> PARSE_ERRORS = |
| 314 new ListResultDescriptor<AnalysisError>( | 332 new ListResultDescriptor<AnalysisError>( |
| 315 'PARSE_ERRORS', AnalysisError.NO_ERRORS); | 333 'PARSE_ERRORS', AnalysisError.NO_ERRORS); |
| 316 | 334 |
| 317 /** | 335 /** |
| 318 * The errors produced while resolving references outside of function bodies. | |
| 319 * | |
| 320 * The list will be empty if there were no errors, but will not be `null`. | |
| 321 * | |
| 322 * The result is only available for [LibrarySpecificUnit]s. | |
| 323 */ | |
| 324 final ListResultDescriptor<AnalysisError> PARTIALLY_RESOLVE_REFERENCES_ERRORS = | |
| 325 new ListResultDescriptor<AnalysisError>( | |
| 326 'PARTIALLY_RESOLVE_REFERENCES_ERRORS', AnalysisError.NO_ERRORS); | |
| 327 | |
| 328 /** | |
| 329 * The names (resolved and not) referenced by a unit. | 336 * The names (resolved and not) referenced by a unit. |
| 330 * | 337 * |
| 331 * The result is only available for [Source]s representing a compilation unit. | 338 * The result is only available for [Source]s representing a compilation unit. |
| 332 */ | 339 */ |
| 333 final ResultDescriptor<ReferencedNames> REFERENCED_NAMES = | 340 final ResultDescriptor<ReferencedNames> REFERENCED_NAMES = |
| 334 new ResultDescriptor<ReferencedNames>('REFERENCED_NAMES', null); | 341 new ResultDescriptor<ReferencedNames>('REFERENCED_NAMES', null); |
| 335 | 342 |
| 336 /** | 343 /** |
| 337 * The errors produced while resolving the function bodies within a compilation | 344 * The errors produced while resolving a full compilation unit. |
| 338 * unit. | |
| 339 * | 345 * |
| 340 * The list will be empty if there were no errors, but will not be `null`. | 346 * The list will be empty if there were no errors, but will not be `null`. |
| 341 * | 347 * |
| 342 * The result is only available for [LibrarySpecificUnit]s. | 348 * The result is only available for [LibrarySpecificUnit]s. |
| 343 */ | 349 */ |
| 344 final ListResultDescriptor<AnalysisError> RESOLVE_FUNCTION_BODIES_ERRORS = | 350 final ListResultDescriptor<AnalysisError> RESOLVE_UNIT_ERRORS = |
| 345 new ListResultDescriptor<AnalysisError>( | 351 new ListResultDescriptor<AnalysisError>( |
| 346 'RESOLVE_FUNCTION_BODIES_ERRORS', AnalysisError.NO_ERRORS); | 352 'RESOLVE_UNIT_ERRORS', AnalysisError.NO_ERRORS); |
| 347 | 353 |
| 348 /** | 354 /** |
| 349 * The errors produced while resolving type names. | 355 * The errors produced while resolving type names. |
| 350 * | 356 * |
| 351 * The list will be empty if there were no errors, but will not be `null`. | 357 * The list will be empty if there were no errors, but will not be `null`. |
| 352 * | 358 * |
| 353 * The result is only available for [LibrarySpecificUnit]s. | 359 * The result is only available for [LibrarySpecificUnit]s. |
| 354 */ | 360 */ |
| 355 final ListResultDescriptor<AnalysisError> RESOLVE_TYPE_NAMES_ERRORS = | 361 final ListResultDescriptor<AnalysisError> RESOLVE_TYPE_NAMES_ERRORS = |
| 356 new ListResultDescriptor<AnalysisError>( | 362 new ListResultDescriptor<AnalysisError>( |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 417 * that is true of a [RESOLVED_UNIT5]. | 423 * that is true of a [RESOLVED_UNIT5]. |
| 418 * | 424 * |
| 419 * The result is only available for [LibrarySpecificUnit]s. | 425 * The result is only available for [LibrarySpecificUnit]s. |
| 420 */ | 426 */ |
| 421 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT6 = | 427 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT6 = |
| 422 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT6', null, | 428 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT6', null, |
| 423 cachingPolicy: AST_CACHING_POLICY); | 429 cachingPolicy: AST_CACHING_POLICY); |
| 424 | 430 |
| 425 /** | 431 /** |
| 426 * The resolved [CompilationUnit] associated with a compilation unit in which | 432 * The resolved [CompilationUnit] associated with a compilation unit in which |
| 427 * the types of class members have been inferred in addition to everything that | 433 * the right hand sides of instance variables have been re-resolved in addition |
| 428 * is true of a [RESOLVED_UNIT7]. | 434 * to everything that is true of a [RESOLVED_UNIT6]. |
| 429 * | 435 * |
| 430 * The result is only available for [LibrarySpecificUnit]s. | 436 * The result is only available for [LibrarySpecificUnit]s. |
| 431 */ | 437 */ |
| 432 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT7 = | 438 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT7 = |
| 433 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT7', null, | 439 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT7', null, |
| 434 cachingPolicy: AST_CACHING_POLICY); | 440 cachingPolicy: AST_CACHING_POLICY); |
| 435 | 441 |
| 436 /** | 442 /** |
| 437 * The resolved [CompilationUnit] associated with a compilation unit, with | 443 * The resolved [CompilationUnit] associated with a compilation unit in which |
| 438 * constants not yet resolved. | 444 * the types of class members have been inferred in addition to everything that |
| 445 * is true of a [RESOLVED_UNIT8]. | |
|
Brian Wilkerson
2015/10/07 22:56:56
nit: "8" --> "7"
| |
| 439 * | 446 * |
| 440 * The result is only available for [LibrarySpecificUnit]s. | 447 * The result is only available for [LibrarySpecificUnit]s. |
| 441 */ | 448 */ |
| 442 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT8 = | 449 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT8 = |
| 443 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT8', null, | 450 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT8', null, |
| 444 cachingPolicy: AST_CACHING_POLICY); | 451 cachingPolicy: AST_CACHING_POLICY); |
| 445 | 452 |
| 446 /** | 453 /** |
| 454 * The resolved [CompilationUnit] associated with a compilation unit, with | |
| 455 * constants not yet resolved. | |
| 456 * | |
| 457 * The result is only available for [LibrarySpecificUnit]s. | |
| 458 */ | |
| 459 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT9 = | |
| 460 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT9', null, | |
| 461 cachingPolicy: AST_CACHING_POLICY); | |
| 462 | |
| 463 /** | |
| 447 * The errors produced while scanning a compilation unit. | 464 * The errors produced while scanning a compilation unit. |
| 448 * | 465 * |
| 449 * The list will be empty if there were no errors, but will not be `null`. | 466 * The list will be empty if there were no errors, but will not be `null`. |
| 450 * | 467 * |
| 451 * The result is only available for [Source]s representing a compilation unit. | 468 * The result is only available for [Source]s representing a compilation unit. |
| 452 */ | 469 */ |
| 453 final ListResultDescriptor<AnalysisError> SCAN_ERRORS = | 470 final ListResultDescriptor<AnalysisError> SCAN_ERRORS = |
| 454 new ListResultDescriptor<AnalysisError>( | 471 new ListResultDescriptor<AnalysisError>( |
| 455 'SCAN_ERRORS', AnalysisError.NO_ERRORS); | 472 'SCAN_ERRORS', AnalysisError.NO_ERRORS); |
| 456 | 473 |
| (...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1488 AnalysisContext context, AnalysisTarget target) { | 1505 AnalysisContext context, AnalysisTarget target) { |
| 1489 return new BuildTypeProviderTask(context, target); | 1506 return new BuildTypeProviderTask(context, target); |
| 1490 } | 1507 } |
| 1491 } | 1508 } |
| 1492 | 1509 |
| 1493 /** | 1510 /** |
| 1494 * A task that computes [CONSTANT_DEPENDENCIES] for a constant. | 1511 * A task that computes [CONSTANT_DEPENDENCIES] for a constant. |
| 1495 */ | 1512 */ |
| 1496 class ComputeConstantDependenciesTask extends ConstantEvaluationAnalysisTask { | 1513 class ComputeConstantDependenciesTask extends ConstantEvaluationAnalysisTask { |
| 1497 /** | 1514 /** |
| 1498 * The name of the [RESOLVED_UNIT8] input. | 1515 * The name of the [RESOLVED_UNIT9] input. |
| 1499 */ | 1516 */ |
| 1500 static const String UNIT_INPUT = 'UNIT_INPUT'; | 1517 static const String UNIT_INPUT = 'UNIT_INPUT'; |
| 1501 | 1518 |
| 1502 /** | 1519 /** |
| 1503 * The name of the [TYPE_PROVIDER] input. | 1520 * The name of the [TYPE_PROVIDER] input. |
| 1504 */ | 1521 */ |
| 1505 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; | 1522 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; |
| 1506 | 1523 |
| 1507 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 1524 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 1508 'ComputeConstantDependenciesTask', | 1525 'ComputeConstantDependenciesTask', |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1544 /** | 1561 /** |
| 1545 * Return a map from the names of the inputs of this kind of task to the task | 1562 * Return a map from the names of the inputs of this kind of task to the task |
| 1546 * input descriptors describing those inputs for a task with the | 1563 * input descriptors describing those inputs for a task with the |
| 1547 * given [target]. | 1564 * given [target]. |
| 1548 */ | 1565 */ |
| 1549 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 1566 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 1550 if (target is Element) { | 1567 if (target is Element) { |
| 1551 CompilationUnitElementImpl unit = target | 1568 CompilationUnitElementImpl unit = target |
| 1552 .getAncestor((Element element) => element is CompilationUnitElement); | 1569 .getAncestor((Element element) => element is CompilationUnitElement); |
| 1553 return <String, TaskInput>{ | 1570 return <String, TaskInput>{ |
| 1554 UNIT_INPUT: RESOLVED_UNIT8 | 1571 UNIT_INPUT: RESOLVED_UNIT9 |
| 1555 .of(new LibrarySpecificUnit(unit.librarySource, target.source)), | 1572 .of(new LibrarySpecificUnit(unit.librarySource, target.source)), |
| 1556 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) | 1573 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) |
| 1557 }; | 1574 }; |
| 1558 } else if (target is ConstantEvaluationTarget_Annotation) { | 1575 } else if (target is ConstantEvaluationTarget_Annotation) { |
| 1559 return <String, TaskInput>{ | 1576 return <String, TaskInput>{ |
| 1560 UNIT_INPUT: RESOLVED_UNIT8 | 1577 UNIT_INPUT: RESOLVED_UNIT9 |
| 1561 .of(new LibrarySpecificUnit(target.librarySource, target.source)), | 1578 .of(new LibrarySpecificUnit(target.librarySource, target.source)), |
| 1562 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) | 1579 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) |
| 1563 }; | 1580 }; |
| 1564 } | 1581 } |
| 1565 throw new AnalysisException( | 1582 throw new AnalysisException( |
| 1566 'Cannot build inputs for a ${target.runtimeType}'); | 1583 'Cannot build inputs for a ${target.runtimeType}'); |
| 1567 } | 1584 } |
| 1568 | 1585 |
| 1569 /** | 1586 /** |
| 1570 * Create a [ComputeConstantDependenciesTask] based on the given [target] in | 1587 * Create a [ComputeConstantDependenciesTask] based on the given [target] in |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1749 * Create a [ComputeInferableStaticVariableDependenciesTask] based on the | 1766 * Create a [ComputeInferableStaticVariableDependenciesTask] based on the |
| 1750 * given [target] in the given [context]. | 1767 * given [target] in the given [context]. |
| 1751 */ | 1768 */ |
| 1752 static ComputeInferableStaticVariableDependenciesTask createTask( | 1769 static ComputeInferableStaticVariableDependenciesTask createTask( |
| 1753 AnalysisContext context, AnalysisTarget target) { | 1770 AnalysisContext context, AnalysisTarget target) { |
| 1754 return new ComputeInferableStaticVariableDependenciesTask(context, target); | 1771 return new ComputeInferableStaticVariableDependenciesTask(context, target); |
| 1755 } | 1772 } |
| 1756 } | 1773 } |
| 1757 | 1774 |
| 1758 /** | 1775 /** |
| 1776 * A task that computes the [LIBRARY_CYCLE] for a | |
| 1777 * library element. Also computes the [LIBRARY_CYCLE_UNITS] and the | |
| 1778 * [LIBRARY_CYCLE_DEPENDENCIES]. | |
| 1779 */ | |
| 1780 class ComputeLibraryCycleTask extends SourceBasedAnalysisTask { | |
| 1781 /** | |
| 1782 * The name of the [LIBRARY_ELEMENT2] input. | |
| 1783 */ | |
| 1784 static const String LIBRARY_ELEMENT_INPUT = 'LIBRARY_ELEMENT_INPUT'; | |
| 1785 | |
| 1786 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | |
| 1787 'ComputeLibraryCycleForUnitTask', | |
| 1788 createTask, | |
| 1789 buildInputs, <ResultDescriptor>[ | |
| 1790 LIBRARY_CYCLE, | |
| 1791 LIBRARY_CYCLE_UNITS, | |
| 1792 LIBRARY_CYCLE_DEPENDENCIES | |
| 1793 ]); | |
| 1794 | |
| 1795 ComputeLibraryCycleTask( | |
| 1796 InternalAnalysisContext context, AnalysisTarget target) | |
| 1797 : super(context, target); | |
| 1798 | |
| 1799 @override | |
| 1800 TaskDescriptor get descriptor => DESCRIPTOR; | |
| 1801 | |
| 1802 @override | |
| 1803 void internalPerform() { | |
| 1804 if (context.analysisOptions.strongMode) { | |
| 1805 LibraryElementImpl library = getRequiredInput(LIBRARY_ELEMENT_INPUT); | |
| 1806 List<LibraryElement> component = library.libraryCycle; | |
| 1807 Set<LibraryElement> filter = new Set<LibraryElement>.from(component); | |
| 1808 Set<CompilationUnitElement> deps = new Set<CompilationUnitElement>(); | |
| 1809 void addLibrary(l) { | |
| 1810 if (!filter.contains(l)) { | |
| 1811 deps.addAll(l.units); | |
| 1812 } | |
| 1813 } | |
| 1814 for (LibraryElement l in component) { | |
| 1815 l.importedLibraries.forEach(addLibrary); | |
| 1816 l.exportedLibraries.forEach(addLibrary); | |
| 1817 } | |
| 1818 | |
| 1819 // | |
| 1820 // Record outputs. | |
| 1821 // | |
| 1822 outputs[LIBRARY_CYCLE] = component; | |
| 1823 outputs[LIBRARY_CYCLE_UNITS] = component.expand((l) => l.units).toList(); | |
| 1824 outputs[LIBRARY_CYCLE_DEPENDENCIES] = deps.toList(); | |
| 1825 } else { | |
| 1826 outputs[LIBRARY_CYCLE] = []; | |
| 1827 outputs[LIBRARY_CYCLE_UNITS] = []; | |
| 1828 outputs[LIBRARY_CYCLE_DEPENDENCIES] = []; | |
| 1829 } | |
| 1830 } | |
| 1831 | |
| 1832 /** | |
| 1833 * Return a map from the names of the inputs of this kind of task to the task | |
| 1834 * input descriptors describing those inputs for a task with the | |
| 1835 * given [target]. | |
| 1836 */ | |
| 1837 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | |
| 1838 LibrarySpecificUnit unit = target; | |
| 1839 return <String, TaskInput>{ | |
| 1840 'resolveReachableLibraries': IMPORT_EXPORT_SOURCE_CLOSURE | |
| 1841 .of(unit.library) | |
| 1842 .toListOf(LIBRARY_ELEMENT2), | |
| 1843 LIBRARY_ELEMENT_INPUT: LIBRARY_ELEMENT2.of(unit.library) | |
| 1844 }; | |
| 1845 } | |
| 1846 | |
| 1847 /** | |
| 1848 * Create a [ComputeLibraryCycleTask] based on the | |
| 1849 * given [target] in the given [context]. | |
| 1850 */ | |
| 1851 static ComputeLibraryCycleTask createTask( | |
| 1852 AnalysisContext context, AnalysisTarget target) { | |
| 1853 return new ComputeLibraryCycleTask(context, target); | |
| 1854 } | |
| 1855 } | |
| 1856 | |
| 1857 /** | |
| 1759 * A base class for analysis tasks whose target is expected to be a | 1858 * A base class for analysis tasks whose target is expected to be a |
| 1760 * [ConstantEvaluationTarget]. | 1859 * [ConstantEvaluationTarget]. |
| 1761 */ | 1860 */ |
| 1762 abstract class ConstantEvaluationAnalysisTask extends AnalysisTask { | 1861 abstract class ConstantEvaluationAnalysisTask extends AnalysisTask { |
| 1763 /** | 1862 /** |
| 1764 * Initialize a newly created task to perform analysis within the given | 1863 * Initialize a newly created task to perform analysis within the given |
| 1765 * [context] in order to produce results for the given [constant]. | 1864 * [context] in order to produce results for the given [constant]. |
| 1766 */ | 1865 */ |
| 1767 ConstantEvaluationAnalysisTask( | 1866 ConstantEvaluationAnalysisTask( |
| 1768 AnalysisContext context, ConstantEvaluationTarget constant) | 1867 AnalysisContext context, ConstantEvaluationTarget constant) |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2007 AnalysisContext context, AnalysisTarget target) { | 2106 AnalysisContext context, AnalysisTarget target) { |
| 2008 return new DartErrorsTask(context, target); | 2107 return new DartErrorsTask(context, target); |
| 2009 } | 2108 } |
| 2010 } | 2109 } |
| 2011 | 2110 |
| 2012 /** | 2111 /** |
| 2013 * A task that builds [RESOLVED_UNIT] for a unit. | 2112 * A task that builds [RESOLVED_UNIT] for a unit. |
| 2014 */ | 2113 */ |
| 2015 class EvaluateUnitConstantsTask extends SourceBasedAnalysisTask { | 2114 class EvaluateUnitConstantsTask extends SourceBasedAnalysisTask { |
| 2016 /** | 2115 /** |
| 2017 * The name of the [RESOLVED_UNIT8] input. | 2116 * The name of the [RESOLVED_UNIT9] input. |
| 2018 */ | 2117 */ |
| 2019 static const String UNIT_INPUT = 'UNIT_INPUT'; | 2118 static const String UNIT_INPUT = 'UNIT_INPUT'; |
| 2020 | 2119 |
| 2021 /** | 2120 /** |
| 2022 * The name of the [CONSTANT_VALUE] input. | 2121 * The name of the [CONSTANT_VALUE] input. |
| 2023 */ | 2122 */ |
| 2024 static const String CONSTANT_VALUES = 'CONSTANT_VALUES'; | 2123 static const String CONSTANT_VALUES = 'CONSTANT_VALUES'; |
| 2025 | 2124 |
| 2026 /** | 2125 /** |
| 2027 * The task descriptor describing this kind of task. | 2126 * The task descriptor describing this kind of task. |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 2048 | 2147 |
| 2049 /** | 2148 /** |
| 2050 * Return a map from the names of the inputs of this kind of task to the task | 2149 * Return a map from the names of the inputs of this kind of task to the task |
| 2051 * input descriptors describing those inputs for a task with the | 2150 * input descriptors describing those inputs for a task with the |
| 2052 * given [target]. | 2151 * given [target]. |
| 2053 */ | 2152 */ |
| 2054 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 2153 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 2055 LibrarySpecificUnit unit = target; | 2154 LibrarySpecificUnit unit = target; |
| 2056 return <String, TaskInput>{ | 2155 return <String, TaskInput>{ |
| 2057 'libraryElement': LIBRARY_ELEMENT.of(unit.library), | 2156 'libraryElement': LIBRARY_ELEMENT.of(unit.library), |
| 2058 UNIT_INPUT: RESOLVED_UNIT8.of(unit), | 2157 UNIT_INPUT: RESOLVED_UNIT9.of(unit), |
| 2059 CONSTANT_VALUES: | 2158 CONSTANT_VALUES: |
| 2060 COMPILATION_UNIT_CONSTANTS.of(unit).toListOf(CONSTANT_VALUE) | 2159 COMPILATION_UNIT_CONSTANTS.of(unit).toListOf(CONSTANT_VALUE) |
| 2061 }; | 2160 }; |
| 2062 } | 2161 } |
| 2063 | 2162 |
| 2064 /** | 2163 /** |
| 2065 * Create an [EvaluateUnitConstantsTask] based on the given [target] in | 2164 * Create an [EvaluateUnitConstantsTask] based on the given [target] in |
| 2066 * the given [context]. | 2165 * the given [context]. |
| 2067 */ | 2166 */ |
| 2068 static EvaluateUnitConstantsTask createTask( | 2167 static EvaluateUnitConstantsTask createTask( |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2172 } | 2271 } |
| 2173 return newNames; | 2272 return newNames; |
| 2174 } | 2273 } |
| 2175 } | 2274 } |
| 2176 | 2275 |
| 2177 /** | 2276 /** |
| 2178 * A task that builds [USED_IMPORTED_ELEMENTS] for a unit. | 2277 * A task that builds [USED_IMPORTED_ELEMENTS] for a unit. |
| 2179 */ | 2278 */ |
| 2180 class GatherUsedImportedElementsTask extends SourceBasedAnalysisTask { | 2279 class GatherUsedImportedElementsTask extends SourceBasedAnalysisTask { |
| 2181 /** | 2280 /** |
| 2182 * The name of the [RESOLVED_UNIT8] input. | 2281 * The name of the [RESOLVED_UNIT9] input. |
| 2183 */ | 2282 */ |
| 2184 static const String UNIT_INPUT = 'UNIT_INPUT'; | 2283 static const String UNIT_INPUT = 'UNIT_INPUT'; |
| 2185 | 2284 |
| 2186 /** | 2285 /** |
| 2187 * The task descriptor describing this kind of task. | 2286 * The task descriptor describing this kind of task. |
| 2188 */ | 2287 */ |
| 2189 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 2288 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 2190 'GatherUsedImportedElementsTask', | 2289 'GatherUsedImportedElementsTask', |
| 2191 createTask, | 2290 createTask, |
| 2192 buildInputs, | 2291 buildInputs, |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 2216 outputs[USED_IMPORTED_ELEMENTS] = visitor.usedElements; | 2315 outputs[USED_IMPORTED_ELEMENTS] = visitor.usedElements; |
| 2217 } | 2316 } |
| 2218 | 2317 |
| 2219 /** | 2318 /** |
| 2220 * Return a map from the names of the inputs of this kind of task to the task | 2319 * Return a map from the names of the inputs of this kind of task to the task |
| 2221 * input descriptors describing those inputs for a task with the | 2320 * input descriptors describing those inputs for a task with the |
| 2222 * given [target]. | 2321 * given [target]. |
| 2223 */ | 2322 */ |
| 2224 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 2323 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 2225 LibrarySpecificUnit unit = target; | 2324 LibrarySpecificUnit unit = target; |
| 2226 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT8.of(unit)}; | 2325 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT9.of(unit)}; |
| 2227 } | 2326 } |
| 2228 | 2327 |
| 2229 /** | 2328 /** |
| 2230 * Create a [GatherUsedImportedElementsTask] based on the given [target] in | 2329 * Create a [GatherUsedImportedElementsTask] based on the given [target] in |
| 2231 * the given [context]. | 2330 * the given [context]. |
| 2232 */ | 2331 */ |
| 2233 static GatherUsedImportedElementsTask createTask( | 2332 static GatherUsedImportedElementsTask createTask( |
| 2234 AnalysisContext context, AnalysisTarget target) { | 2333 AnalysisContext context, AnalysisTarget target) { |
| 2235 return new GatherUsedImportedElementsTask(context, target); | 2334 return new GatherUsedImportedElementsTask(context, target); |
| 2236 } | 2335 } |
| 2237 } | 2336 } |
| 2238 | 2337 |
| 2239 /** | 2338 /** |
| 2240 * A task that builds [USED_LOCAL_ELEMENTS] for a unit. | 2339 * A task that builds [USED_LOCAL_ELEMENTS] for a unit. |
| 2241 */ | 2340 */ |
| 2242 class GatherUsedLocalElementsTask extends SourceBasedAnalysisTask { | 2341 class GatherUsedLocalElementsTask extends SourceBasedAnalysisTask { |
| 2243 /** | 2342 /** |
| 2244 * The name of the [RESOLVED_UNIT8] input. | 2343 * The name of the [RESOLVED_UNIT9] input. |
| 2245 */ | 2344 */ |
| 2246 static const String UNIT_INPUT = 'UNIT_INPUT'; | 2345 static const String UNIT_INPUT = 'UNIT_INPUT'; |
| 2247 | 2346 |
| 2248 /** | 2347 /** |
| 2249 * The task descriptor describing this kind of task. | 2348 * The task descriptor describing this kind of task. |
| 2250 */ | 2349 */ |
| 2251 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 2350 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 2252 'GatherUsedLocalElementsTask', | 2351 'GatherUsedLocalElementsTask', |
| 2253 createTask, | 2352 createTask, |
| 2254 buildInputs, | 2353 buildInputs, |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 2278 outputs[USED_LOCAL_ELEMENTS] = visitor.usedElements; | 2377 outputs[USED_LOCAL_ELEMENTS] = visitor.usedElements; |
| 2279 } | 2378 } |
| 2280 | 2379 |
| 2281 /** | 2380 /** |
| 2282 * Return a map from the names of the inputs of this kind of task to the task | 2381 * Return a map from the names of the inputs of this kind of task to the task |
| 2283 * input descriptors describing those inputs for a task with the | 2382 * input descriptors describing those inputs for a task with the |
| 2284 * given [target]. | 2383 * given [target]. |
| 2285 */ | 2384 */ |
| 2286 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 2385 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 2287 LibrarySpecificUnit unit = target; | 2386 LibrarySpecificUnit unit = target; |
| 2288 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT8.of(unit)}; | 2387 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT9.of(unit)}; |
| 2289 } | 2388 } |
| 2290 | 2389 |
| 2291 /** | 2390 /** |
| 2292 * Create a [GatherUsedLocalElementsTask] based on the given [target] in | 2391 * Create a [GatherUsedLocalElementsTask] based on the given [target] in |
| 2293 * the given [context]. | 2392 * the given [context]. |
| 2294 */ | 2393 */ |
| 2295 static GatherUsedLocalElementsTask createTask( | 2394 static GatherUsedLocalElementsTask createTask( |
| 2296 AnalysisContext context, AnalysisTarget target) { | 2395 AnalysisContext context, AnalysisTarget target) { |
| 2297 return new GatherUsedLocalElementsTask(context, target); | 2396 return new GatherUsedLocalElementsTask(context, target); |
| 2298 } | 2397 } |
| 2299 } | 2398 } |
| 2300 | 2399 |
| 2301 /** | 2400 /** |
| 2302 * A task that generates [HINTS] for a unit. | 2401 * A task that generates [HINTS] for a unit. |
| 2303 */ | 2402 */ |
| 2304 class GenerateHintsTask extends SourceBasedAnalysisTask { | 2403 class GenerateHintsTask extends SourceBasedAnalysisTask { |
| 2305 /** | 2404 /** |
| 2306 * The name of the [RESOLVED_UNIT8] input. | 2405 * The name of the [RESOLVED_UNIT9] input. |
| 2307 */ | 2406 */ |
| 2308 static const String RESOLVED_UNIT_INPUT = 'RESOLVED_UNIT'; | 2407 static const String RESOLVED_UNIT_INPUT = 'RESOLVED_UNIT'; |
| 2309 | 2408 |
| 2310 /** | 2409 /** |
| 2311 * The name of a list of [USED_LOCAL_ELEMENTS] for each library unit input. | 2410 * The name of a list of [USED_LOCAL_ELEMENTS] for each library unit input. |
| 2312 */ | 2411 */ |
| 2313 static const String USED_LOCAL_ELEMENTS_INPUT = 'USED_LOCAL_ELEMENTS'; | 2412 static const String USED_LOCAL_ELEMENTS_INPUT = 'USED_LOCAL_ELEMENTS'; |
| 2314 | 2413 |
| 2315 /** | 2414 /** |
| 2316 * The name of a list of [USED_IMPORTED_ELEMENTS] for each library unit input. | 2415 * The name of a list of [USED_IMPORTED_ELEMENTS] for each library unit input. |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2533 */ | 2632 */ |
| 2534 static const String UNIT_INPUT = 'UNIT_INPUT'; | 2633 static const String UNIT_INPUT = 'UNIT_INPUT'; |
| 2535 | 2634 |
| 2536 /** | 2635 /** |
| 2537 * The task descriptor describing this kind of task. | 2636 * The task descriptor describing this kind of task. |
| 2538 */ | 2637 */ |
| 2539 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 2638 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 2540 'InferInstanceMembersInUnitTask', | 2639 'InferInstanceMembersInUnitTask', |
| 2541 createTask, | 2640 createTask, |
| 2542 buildInputs, | 2641 buildInputs, |
| 2543 <ResultDescriptor>[RESOLVED_UNIT7]); | 2642 <ResultDescriptor>[RESOLVED_UNIT8]); |
| 2544 | 2643 |
| 2545 /** | 2644 /** |
| 2546 * Initialize a newly created task to build a library element for the given | 2645 * Initialize a newly created task to build a library element for the given |
| 2547 * [unit] in the given [context]. | 2646 * [unit] in the given [context]. |
| 2548 */ | 2647 */ |
| 2549 InferInstanceMembersInUnitTask( | 2648 InferInstanceMembersInUnitTask( |
| 2550 InternalAnalysisContext context, LibrarySpecificUnit unit) | 2649 InternalAnalysisContext context, LibrarySpecificUnit unit) |
| 2551 : super(context, unit); | 2650 : super(context, unit); |
| 2552 | 2651 |
| 2553 @override | 2652 @override |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 2564 // Infer instance members. | 2663 // Infer instance members. |
| 2565 // | 2664 // |
| 2566 if (context.analysisOptions.strongMode) { | 2665 if (context.analysisOptions.strongMode) { |
| 2567 InstanceMemberInferrer inferrer = new InstanceMemberInferrer(typeProvider, | 2666 InstanceMemberInferrer inferrer = new InstanceMemberInferrer(typeProvider, |
| 2568 typeSystem: context.typeSystem); | 2667 typeSystem: context.typeSystem); |
| 2569 inferrer.inferCompilationUnit(unit.element); | 2668 inferrer.inferCompilationUnit(unit.element); |
| 2570 } | 2669 } |
| 2571 // | 2670 // |
| 2572 // Record outputs. | 2671 // Record outputs. |
| 2573 // | 2672 // |
| 2574 outputs[RESOLVED_UNIT7] = unit; | 2673 outputs[RESOLVED_UNIT8] = unit; |
| 2575 } | 2674 } |
| 2576 | 2675 |
| 2577 /** | 2676 /** |
| 2578 * Return a map from the names of the inputs of this kind of task to the task | 2677 * Return a map from the names of the inputs of this kind of task to the task |
| 2579 * input descriptors describing those inputs for a task with the given | 2678 * input descriptors describing those inputs for a task with the given |
| 2580 * [libSource]. | 2679 * [libSource]. |
| 2581 */ | 2680 */ |
| 2582 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 2681 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 2583 LibrarySpecificUnit unit = target; | 2682 LibrarySpecificUnit unit = target; |
| 2584 return <String, TaskInput>{ | 2683 return <String, TaskInput>{ |
| 2585 UNIT_INPUT: RESOLVED_UNIT6.of(unit), | 2684 UNIT_INPUT: RESOLVED_UNIT7.of(unit), |
| 2586 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) | 2685 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), |
| 2686 // In strong mode, add additional dependencies to enforce inference | |
| 2687 // ordering. | |
| 2688 | |
| 2689 // Require that field re-resolution be complete for all units in the | |
| 2690 // current library cycle. | |
| 2691 'orderLibraryCycleTasks': LIBRARY_CYCLE_UNITS.of(unit).toList( | |
| 2692 (CompilationUnitElementImpl unit) => RESOLVED_UNIT7 | |
| 2693 .of(new LibrarySpecificUnit(unit.librarySource, unit.source))), | |
| 2694 // Require that full inference be complete for all dependencies of the | |
| 2695 // current library cycle. | |
| 2696 'orderLibraryCycles': LIBRARY_CYCLE_DEPENDENCIES.of(unit).toList( | |
| 2697 (CompilationUnitElementImpl unit) => RESOLVED_UNIT8 | |
| 2698 .of(new LibrarySpecificUnit(unit.librarySource, unit.source))) | |
| 2587 }; | 2699 }; |
| 2588 } | 2700 } |
| 2589 | 2701 |
| 2590 /** | 2702 /** |
| 2591 * Create a [InferInstanceMembersInUnitTask] based on the given [target] in | 2703 * Create a [InferInstanceMembersInUnitTask] based on the given [target] in |
| 2592 * the given [context]. | 2704 * the given [context]. |
| 2593 */ | 2705 */ |
| 2594 static InferInstanceMembersInUnitTask createTask( | 2706 static InferInstanceMembersInUnitTask createTask( |
| 2595 AnalysisContext context, AnalysisTarget target) { | 2707 AnalysisContext context, AnalysisTarget target) { |
| 2596 return new InferInstanceMembersInUnitTask(context, target); | 2708 return new InferInstanceMembersInUnitTask(context, target); |
| 2597 } | 2709 } |
| 2598 } | 2710 } |
| 2599 | 2711 |
| 2600 /** | 2712 /** |
| 2713 * A task that ensures that all of the inferrable instance members in a | |
| 2714 * compilation unit have had their right hand sides re-resolved | |
| 2715 */ | |
| 2716 class ResolveInstanceFieldsInUnitTask extends SourceBasedAnalysisTask { | |
| 2717 /** | |
| 2718 * The name of the [LIBRARY_ELEMENT5] input. | |
| 2719 */ | |
| 2720 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; | |
| 2721 | |
| 2722 /** | |
| 2723 * The name of the [TYPE_PROVIDER] input. | |
| 2724 */ | |
| 2725 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; | |
| 2726 | |
| 2727 /** | |
| 2728 * The name of the input whose value is the [RESOLVED_UNIT6] for the | |
| 2729 * compilation unit. | |
| 2730 */ | |
| 2731 static const String UNIT_INPUT = 'UNIT_INPUT'; | |
| 2732 | |
| 2733 /** | |
| 2734 * The task descriptor describing this kind of task. | |
| 2735 */ | |
| 2736 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | |
| 2737 'ResolveInstanceFieldsInUnitTask', | |
| 2738 createTask, | |
| 2739 buildInputs, | |
| 2740 <ResultDescriptor>[RESOLVED_UNIT7]); | |
| 2741 | |
| 2742 /** | |
| 2743 * Initialize a newly created task to build a library element for the given | |
| 2744 * [unit] in the given [context]. | |
| 2745 */ | |
| 2746 ResolveInstanceFieldsInUnitTask( | |
| 2747 InternalAnalysisContext context, LibrarySpecificUnit unit) | |
| 2748 : super(context, unit); | |
| 2749 | |
| 2750 @override | |
| 2751 TaskDescriptor get descriptor => DESCRIPTOR; | |
| 2752 | |
| 2753 @override | |
| 2754 void internalPerform() { | |
| 2755 // | |
| 2756 // Prepare inputs. | |
| 2757 // | |
| 2758 LibraryElement libraryElement = getRequiredInput(LIBRARY_INPUT); | |
| 2759 CompilationUnit unit = getRequiredInput(UNIT_INPUT); | |
| 2760 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); | |
| 2761 | |
| 2762 CompilationUnitElement unitElement = unit.element; | |
| 2763 if (context.analysisOptions.strongMode) { | |
| 2764 // | |
| 2765 // Resolve references. | |
| 2766 // | |
| 2767 // TODO(leafp): This code only needs to re-resolve the right hand sides of | |
| 2768 // instance fields. We could do incremental resolution on each field | |
| 2769 // only using the incremental resolver. However, this caused a massive | |
| 2770 // performance degredation on the large_class_declaration_test.dart test. | |
| 2771 // I would hypothesize that incremental resolution of field is linear in | |
| 2772 // the size of the enclosing class, and hence incrementally resolving each | |
| 2773 // field was quadratic. We may wish to revisit this if we can resolve | |
| 2774 // this performance issue. | |
| 2775 InheritanceManager inheritanceManager = | |
| 2776 new InheritanceManager(libraryElement); | |
| 2777 PartialResolverVisitor visitor = new PartialResolverVisitor( | |
| 2778 libraryElement, | |
| 2779 unitElement.source, | |
| 2780 typeProvider, | |
| 2781 AnalysisErrorListener.NULL_LISTENER, | |
| 2782 inheritanceManager: inheritanceManager); | |
| 2783 unit.accept(visitor); | |
| 2784 } | |
| 2785 // | |
| 2786 // Record outputs. | |
| 2787 // | |
| 2788 outputs[RESOLVED_UNIT7] = unit; | |
| 2789 } | |
| 2790 | |
| 2791 /** | |
| 2792 * Return a map from the names of the inputs of this kind of task to the task | |
| 2793 * input descriptors describing those inputs for a task with the given | |
| 2794 * [libSource]. | |
| 2795 */ | |
| 2796 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | |
| 2797 LibrarySpecificUnit unit = target; | |
| 2798 return <String, TaskInput>{ | |
| 2799 UNIT_INPUT: RESOLVED_UNIT6.of(unit), | |
| 2800 LIBRARY_INPUT: LIBRARY_ELEMENT5.of(unit.library), | |
| 2801 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), | |
| 2802 // In strong mode, add additional dependencies to enforce inference | |
| 2803 // ordering. | |
| 2804 | |
| 2805 // Require that static variable inference be complete for all units in | |
| 2806 // the current library cycle. | |
| 2807 'orderLibraryCycleTasks': LIBRARY_CYCLE_UNITS.of(unit).toList( | |
| 2808 (CompilationUnitElementImpl unit) => RESOLVED_UNIT6 | |
| 2809 .of(new LibrarySpecificUnit(unit.librarySource, unit.source))), | |
| 2810 // Require that full inference be complete for all dependencies of the | |
| 2811 // current library cycle. | |
| 2812 'orderLibraryCycles': LIBRARY_CYCLE_DEPENDENCIES.of(unit).toList( | |
| 2813 (CompilationUnitElementImpl unit) => RESOLVED_UNIT8 | |
| 2814 .of(new LibrarySpecificUnit(unit.librarySource, unit.source))) | |
| 2815 }; | |
| 2816 } | |
| 2817 | |
| 2818 /** | |
| 2819 * Create a [ResolveInstanceFieldsInUnitTask] based on the given [target] in | |
| 2820 * the given [context]. | |
| 2821 */ | |
| 2822 static ResolveInstanceFieldsInUnitTask createTask( | |
| 2823 AnalysisContext context, AnalysisTarget target) { | |
| 2824 return new ResolveInstanceFieldsInUnitTask(context, target); | |
| 2825 } | |
| 2826 } | |
| 2827 | |
| 2828 /** | |
| 2601 * An abstract class that defines utility methods that are useful for tasks | 2829 * An abstract class that defines utility methods that are useful for tasks |
| 2602 * operating on static variables. | 2830 * operating on static variables. |
| 2603 */ | 2831 */ |
| 2604 abstract class InferStaticVariableTask extends ConstantEvaluationAnalysisTask { | 2832 abstract class InferStaticVariableTask extends ConstantEvaluationAnalysisTask { |
| 2605 InferStaticVariableTask( | 2833 InferStaticVariableTask( |
| 2606 InternalAnalysisContext context, VariableElement variable) | 2834 InternalAnalysisContext context, VariableElement variable) |
| 2607 : super(context, variable); | 2835 : super(context, variable); |
| 2608 | 2836 |
| 2609 /** | 2837 /** |
| 2610 * Return the declaration of the target within the given compilation [unit]. | 2838 * Return the declaration of the target within the given compilation [unit]. |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 2635 */ | 2863 */ |
| 2636 static const String UNIT_INPUT = 'UNIT_INPUT'; | 2864 static const String UNIT_INPUT = 'UNIT_INPUT'; |
| 2637 | 2865 |
| 2638 /** | 2866 /** |
| 2639 * The name of the input whose value is a list of the inferrable static | 2867 * The name of the input whose value is a list of the inferrable static |
| 2640 * variables whose types have been computed. | 2868 * variables whose types have been computed. |
| 2641 */ | 2869 */ |
| 2642 static const String INFERRED_VARIABLES_INPUT = 'INFERRED_VARIABLES_INPUT'; | 2870 static const String INFERRED_VARIABLES_INPUT = 'INFERRED_VARIABLES_INPUT'; |
| 2643 | 2871 |
| 2644 /** | 2872 /** |
| 2645 * The name of the input whose value is a list of the errors produced while | |
| 2646 * inferring types for static variables. | |
| 2647 */ | |
| 2648 static const String INFER_STATIC_VARIABLE_ERRORS_INPUT = | |
| 2649 'INFER_STATIC_VARIABLE_ERRORS'; | |
| 2650 | |
| 2651 /** | |
| 2652 * The task descriptor describing this kind of task. | 2873 * The task descriptor describing this kind of task. |
| 2653 */ | 2874 */ |
| 2654 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 2875 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 2655 'InferStaticVariableTypesInUnitTask', | 2876 'InferStaticVariableTypesInUnitTask', |
| 2656 createTask, | 2877 createTask, |
| 2657 buildInputs, | 2878 buildInputs, |
| 2658 <ResultDescriptor>[INFER_STATIC_VARIABLE_TYPES_ERRORS, RESOLVED_UNIT6]); | 2879 <ResultDescriptor>[RESOLVED_UNIT6]); |
| 2659 | 2880 |
| 2660 /** | 2881 /** |
| 2661 * Initialize a newly created task to build a library element for the given | 2882 * Initialize a newly created task to build a library element for the given |
| 2662 * [unit] in the given [context]. | 2883 * [unit] in the given [context]. |
| 2663 */ | 2884 */ |
| 2664 InferStaticVariableTypesInUnitTask( | 2885 InferStaticVariableTypesInUnitTask( |
| 2665 InternalAnalysisContext context, LibrarySpecificUnit unit) | 2886 InternalAnalysisContext context, LibrarySpecificUnit unit) |
| 2666 : super(context, unit); | 2887 : super(context, unit); |
| 2667 | 2888 |
| 2668 @override | 2889 @override |
| 2669 TaskDescriptor get descriptor => DESCRIPTOR; | 2890 TaskDescriptor get descriptor => DESCRIPTOR; |
| 2670 | 2891 |
| 2671 @override | 2892 @override |
| 2672 void internalPerform() { | 2893 void internalPerform() { |
| 2673 // | 2894 // |
| 2674 // Prepare inputs. | 2895 // Prepare inputs. |
| 2675 // | 2896 // |
| 2676 CompilationUnit unit = getRequiredInput(UNIT_INPUT); | 2897 CompilationUnit unit = getRequiredInput(UNIT_INPUT); |
| 2677 List<List<AnalysisError>> perVariableErrors = | |
| 2678 getRequiredInput(INFER_STATIC_VARIABLE_ERRORS_INPUT); | |
| 2679 List<AnalysisError> errors = <AnalysisError>[]; | |
| 2680 for (List<AnalysisError> variableErrors in perVariableErrors) { | |
| 2681 errors.addAll(variableErrors); | |
| 2682 } | |
| 2683 // | 2898 // |
| 2684 // Record outputs. There is no additional work to be done at this time | 2899 // Record outputs. There is no additional work to be done at this time |
| 2685 // because the work has implicitly been done by virtue of the task model | 2900 // because the work has implicitly been done by virtue of the task model |
| 2686 // preparing all of the inputs. | 2901 // preparing all of the inputs. |
| 2687 // | 2902 // |
| 2688 outputs[INFER_STATIC_VARIABLE_TYPES_ERRORS] = errors; | |
| 2689 outputs[RESOLVED_UNIT6] = unit; | 2903 outputs[RESOLVED_UNIT6] = unit; |
| 2690 } | 2904 } |
| 2691 | 2905 |
| 2692 /** | 2906 /** |
| 2693 * Return a map from the names of the inputs of this kind of task to the task | 2907 * Return a map from the names of the inputs of this kind of task to the task |
| 2694 * input descriptors describing those inputs for a task with the given | 2908 * input descriptors describing those inputs for a task with the given |
| 2695 * [libSource]. | 2909 * [libSource]. |
| 2696 */ | 2910 */ |
| 2697 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 2911 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 2698 LibrarySpecificUnit unit = target; | 2912 LibrarySpecificUnit unit = target; |
| 2699 return <String, TaskInput>{ | 2913 return <String, TaskInput>{ |
| 2700 INFERRED_VARIABLES_INPUT: INFERABLE_STATIC_VARIABLES_IN_UNIT | 2914 INFERRED_VARIABLES_INPUT: INFERABLE_STATIC_VARIABLES_IN_UNIT |
| 2701 .of(unit) | 2915 .of(unit) |
| 2702 .toListOf(INFERRED_STATIC_VARIABLE), | 2916 .toListOf(INFERRED_STATIC_VARIABLE), |
| 2703 INFER_STATIC_VARIABLE_ERRORS_INPUT: INFERABLE_STATIC_VARIABLES_IN_UNIT | |
| 2704 .of(unit) | |
| 2705 .toListOf(INFER_STATIC_VARIABLE_ERRORS), | |
| 2706 UNIT_INPUT: RESOLVED_UNIT5.of(unit) | 2917 UNIT_INPUT: RESOLVED_UNIT5.of(unit) |
| 2707 }; | 2918 }; |
| 2708 } | 2919 } |
| 2709 | 2920 |
| 2710 /** | 2921 /** |
| 2711 * Create a [InferStaticVariableTypesInUnitTask] based on the given [target] | 2922 * Create a [InferStaticVariableTypesInUnitTask] based on the given [target] |
| 2712 * in the given [context]. | 2923 * in the given [context]. |
| 2713 */ | 2924 */ |
| 2714 static InferStaticVariableTypesInUnitTask createTask( | 2925 static InferStaticVariableTypesInUnitTask createTask( |
| 2715 AnalysisContext context, AnalysisTarget target) { | 2926 AnalysisContext context, AnalysisTarget target) { |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 2734 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; | 2945 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; |
| 2735 | 2946 |
| 2736 /** | 2947 /** |
| 2737 * The name of the [RESOLVED_UNIT5] input. | 2948 * The name of the [RESOLVED_UNIT5] input. |
| 2738 */ | 2949 */ |
| 2739 static const String UNIT_INPUT = 'UNIT_INPUT'; | 2950 static const String UNIT_INPUT = 'UNIT_INPUT'; |
| 2740 | 2951 |
| 2741 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 2952 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 2742 'InferStaticVariableTypeTask', | 2953 'InferStaticVariableTypeTask', |
| 2743 createTask, | 2954 createTask, |
| 2744 buildInputs, <ResultDescriptor>[ | 2955 buildInputs, |
| 2745 INFER_STATIC_VARIABLE_ERRORS, | 2956 <ResultDescriptor>[INFERRED_STATIC_VARIABLE]); |
| 2746 INFERRED_STATIC_VARIABLE | |
| 2747 ]); | |
| 2748 | 2957 |
| 2749 InferStaticVariableTypeTask( | 2958 InferStaticVariableTypeTask( |
| 2750 InternalAnalysisContext context, VariableElement variable) | 2959 InternalAnalysisContext context, VariableElement variable) |
| 2751 : super(context, variable); | 2960 : super(context, variable); |
| 2752 | 2961 |
| 2753 @override | 2962 @override |
| 2754 TaskDescriptor get descriptor => DESCRIPTOR; | 2963 TaskDescriptor get descriptor => DESCRIPTOR; |
| 2755 | 2964 |
| 2756 @override | 2965 @override |
| 2757 bool get handlesDependencyCycles => true; | 2966 bool get handlesDependencyCycles => true; |
| 2758 | 2967 |
| 2759 @override | 2968 @override |
| 2760 void internalPerform() { | 2969 void internalPerform() { |
| 2761 // | 2970 // |
| 2762 // Prepare inputs. | 2971 // Prepare inputs. |
| 2763 // | 2972 // |
| 2764 // Note: DEPENDENCIES_INPUT is not needed. It is merely a bookkeeping | 2973 // Note: DEPENDENCIES_INPUT is not needed. It is merely a bookkeeping |
| 2765 // dependency to ensure that the variables that this variable references | 2974 // dependency to ensure that the variables that this variable references |
| 2766 // have types inferred before inferring the type of this variable. | 2975 // have types inferred before inferring the type of this variable. |
| 2767 // | 2976 // |
| 2768 VariableElementImpl variable = target; | 2977 VariableElementImpl variable = target; |
| 2769 | 2978 |
| 2770 CompilationUnit unit = getRequiredInput(UNIT_INPUT); | 2979 CompilationUnit unit = getRequiredInput(UNIT_INPUT); |
| 2771 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); | 2980 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); |
| 2772 RecordingErrorListener errorListener = new RecordingErrorListener(); | |
| 2773 VariableDeclaration declaration = getDeclaration(unit); | |
| 2774 // | |
| 2775 // Re-resolve the variable's initializer so that the inferred types of other | |
| 2776 // variables will be propagated. | |
| 2777 // | |
| 2778 Expression initializer = declaration.initializer; | |
| 2779 ResolutionEraser.erase(initializer, eraseDeclarations: false); | |
| 2780 ResolutionContext resolutionContext = | |
| 2781 ResolutionContextBuilder.contextFor(initializer, errorListener); | |
| 2782 ResolverVisitor visitor = new ResolverVisitor( | |
| 2783 variable.library, variable.source, typeProvider, errorListener, | |
| 2784 nameScope: resolutionContext.scope); | |
| 2785 if (resolutionContext.enclosingClassDeclaration != null) { | |
| 2786 visitor.prepareToResolveMembersInClass( | |
| 2787 resolutionContext.enclosingClassDeclaration); | |
| 2788 } | |
| 2789 visitor.initForIncrementalResolution(); | |
| 2790 initializer.accept(visitor); | |
| 2791 | 2981 |
| 2792 // If we're not in a dependency cycle, and we have no type annotation, | 2982 // If we're not in a dependency cycle, and we have no type annotation, |
| 2793 // do inference. | 2983 // re-resolve the right hand side and do inference. |
| 2794 if (dependencyCycle == null && variable.hasImplicitType) { | 2984 if (dependencyCycle == null && variable.hasImplicitType) { |
| 2985 VariableDeclaration declaration = getDeclaration(unit); | |
| 2986 // | |
| 2987 // Re-resolve the variable's initializer so that the inferred types | |
| 2988 // of other variables will be propagated. | |
| 2989 // | |
| 2990 Expression initializer = declaration.initializer; | |
| 2991 ResolutionContext resolutionContext = ResolutionContextBuilder.contextFor( | |
| 2992 initializer, AnalysisErrorListener.NULL_LISTENER); | |
| 2993 ResolverVisitor visitor = new ResolverVisitor(variable.library, | |
| 2994 variable.source, typeProvider, AnalysisErrorListener.NULL_LISTENER, | |
| 2995 nameScope: resolutionContext.scope); | |
| 2996 if (resolutionContext.enclosingClassDeclaration != null) { | |
| 2997 visitor.prepareToResolveMembersInClass( | |
| 2998 resolutionContext.enclosingClassDeclaration); | |
| 2999 } | |
| 3000 visitor.initForIncrementalResolution(); | |
| 3001 initializer.accept(visitor); | |
| 3002 | |
| 2795 // | 3003 // |
| 2796 // Record the type of the variable. | 3004 // Record the type of the variable. |
| 2797 // | 3005 // |
| 2798 DartType newType = initializer.staticType; | 3006 DartType newType = initializer.staticType; |
| 2799 if (newType == null || newType.isBottom) { | 3007 if (newType == null || newType.isBottom) { |
| 2800 newType = typeProvider.dynamicType; | 3008 newType = typeProvider.dynamicType; |
| 2801 } | 3009 } |
| 2802 variable.type = newType; | 3010 variable.type = newType; |
| 2803 (variable.initializer as ExecutableElementImpl).returnType = newType; | 3011 (variable.initializer as ExecutableElementImpl).returnType = newType; |
| 2804 if (variable is PropertyInducingElementImpl) { | 3012 if (variable is PropertyInducingElementImpl) { |
| 2805 setReturnType(variable.getter, newType); | 3013 setReturnType(variable.getter, newType); |
| 2806 if (!variable.isFinal && !variable.isConst) { | 3014 if (!variable.isFinal && !variable.isConst) { |
| 2807 setParameterType(variable.setter, newType); | 3015 setParameterType(variable.setter, newType); |
| 2808 } | 3016 } |
| 2809 } | 3017 } |
| 2810 } else { | 3018 } else { |
| 2811 // TODO(brianwilkerson) For now we simply don't infer any type for | 3019 // TODO(brianwilkerson) For now we simply don't infer any type for |
| 2812 // variables or fields involved in a cycle. We could try to be smarter | 3020 // variables or fields involved in a cycle. We could try to be smarter |
| 2813 // by re-resolving the initializer in a context in which the types of all | 3021 // by re-resolving the initializer in a context in which the types of all |
| 2814 // of the variables in the cycle are assumed to be `null`, but it isn't | 3022 // of the variables in the cycle are assumed to be `null`, but it isn't |
| 2815 // clear to me that this would produce better results often enough to | 3023 // clear to me that this would produce better results often enough to |
| 2816 // warrant the extra effort. | 3024 // warrant the extra effort. |
| 2817 } | 3025 } |
| 2818 // | 3026 // |
| 2819 // Record outputs. | 3027 // Record outputs. |
| 2820 // | 3028 // |
| 2821 outputs[INFERRED_STATIC_VARIABLE] = variable; | 3029 outputs[INFERRED_STATIC_VARIABLE] = variable; |
| 2822 outputs[INFER_STATIC_VARIABLE_ERRORS] = errorListener.errors; | |
| 2823 } | 3030 } |
| 2824 | 3031 |
| 2825 /** | 3032 /** |
| 2826 * Return a map from the names of the inputs of this kind of task to the task | 3033 * Return a map from the names of the inputs of this kind of task to the task |
| 2827 * input descriptors describing those inputs for a task with the given | 3034 * input descriptors describing those inputs for a task with the given |
| 2828 * [target]. | 3035 * [target]. |
| 2829 */ | 3036 */ |
| 2830 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 3037 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 2831 VariableElement variable = target; | 3038 VariableElement variable = target; |
| 2832 LibrarySpecificUnit unit = | 3039 LibrarySpecificUnit unit = |
| 2833 new LibrarySpecificUnit(variable.library.source, variable.source); | 3040 new LibrarySpecificUnit(variable.library.source, variable.source); |
| 2834 return <String, TaskInput>{ | 3041 return <String, TaskInput>{ |
| 2835 DEPENDENCIES_INPUT: INFERABLE_STATIC_VARIABLE_DEPENDENCIES | 3042 DEPENDENCIES_INPUT: INFERABLE_STATIC_VARIABLE_DEPENDENCIES |
| 2836 .of(variable) | 3043 .of(variable) |
| 2837 .toListOf(INFERRED_STATIC_VARIABLE), | 3044 .toListOf(INFERRED_STATIC_VARIABLE), |
| 2838 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), | 3045 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), |
| 2839 UNIT_INPUT: RESOLVED_UNIT5.of(unit) | 3046 UNIT_INPUT: RESOLVED_UNIT5.of(unit), |
| 3047 // In strong mode, add additional dependencies to enforce inference | |
| 3048 // ordering. | |
| 3049 | |
| 3050 // Require that full inference be complete for all dependencies of the | |
| 3051 // current library cycle. | |
| 3052 'orderLibraryCycles': LIBRARY_CYCLE_DEPENDENCIES.of(unit).toList( | |
| 3053 (CompilationUnitElementImpl unit) => RESOLVED_UNIT8 | |
| 3054 .of(new LibrarySpecificUnit(unit.librarySource, unit.source))) | |
| 2840 }; | 3055 }; |
| 2841 } | 3056 } |
| 2842 | 3057 |
| 2843 /** | 3058 /** |
| 2844 * Create a [InferStaticVariableTypeTask] based on the given [target] in the | 3059 * Create a [InferStaticVariableTypeTask] based on the given [target] in the |
| 2845 * given [context]. | 3060 * given [context]. |
| 2846 */ | 3061 */ |
| 2847 static InferStaticVariableTypeTask createTask( | 3062 static InferStaticVariableTypeTask createTask( |
| 2848 AnalysisContext context, AnalysisTarget target) { | 3063 AnalysisContext context, AnalysisTarget target) { |
| 2849 return new InferStaticVariableTypeTask(context, target); | 3064 return new InferStaticVariableTypeTask(context, target); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2916 * The name of the [HINTS] input. | 3131 * The name of the [HINTS] input. |
| 2917 */ | 3132 */ |
| 2918 static const String HINTS_INPUT = 'HINTS'; | 3133 static const String HINTS_INPUT = 'HINTS'; |
| 2919 | 3134 |
| 2920 /** | 3135 /** |
| 2921 * The name of the [LINTS] input. | 3136 * The name of the [LINTS] input. |
| 2922 */ | 3137 */ |
| 2923 static const String LINTS_INPUT = 'LINTS'; | 3138 static const String LINTS_INPUT = 'LINTS'; |
| 2924 | 3139 |
| 2925 /** | 3140 /** |
| 2926 * The name of the [INFER_STATIC_VARIABLE_TYPES_ERRORS] input. | |
| 2927 */ | |
| 2928 static const String INFER_STATIC_VARIABLE_TYPES_ERRORS_INPUT = | |
| 2929 'INFER_STATIC_VARIABLE_TYPES_ERRORS'; | |
| 2930 | |
| 2931 /** | |
| 2932 * The name of the [PARTIALLY_RESOLVE_REFERENCES_ERRORS] input. | |
| 2933 */ | |
| 2934 static const String PARTIALLY_RESOLVE_REFERENCES_ERRORS_INPUT = | |
| 2935 'PARTIALLY_RESOLVE_REFERENCES_ERRORS'; | |
| 2936 | |
| 2937 /** | |
| 2938 * The name of the [RESOLVE_FUNCTION_BODIES_ERRORS] input. | |
| 2939 */ | |
| 2940 static const String RESOLVE_FUNCTION_BODIES_ERRORS_INPUT = | |
| 2941 'RESOLVE_FUNCTION_BODIES_ERRORS'; | |
| 2942 | |
| 2943 /** | |
| 2944 * The name of the [RESOLVE_TYPE_NAMES_ERRORS] input. | 3141 * The name of the [RESOLVE_TYPE_NAMES_ERRORS] input. |
| 2945 */ | 3142 */ |
| 2946 static const String RESOLVE_TYPE_NAMES_ERRORS_INPUT = | 3143 static const String RESOLVE_TYPE_NAMES_ERRORS_INPUT = |
| 2947 'RESOLVE_TYPE_NAMES_ERRORS'; | 3144 'RESOLVE_TYPE_NAMES_ERRORS'; |
| 2948 | 3145 |
| 2949 /** | 3146 /** |
| 3147 * The name of the [RESOLVE_UNIT_ERRORS] input. | |
| 3148 */ | |
| 3149 static const String RESOLVE_UNIT_ERRORS_INPUT = 'RESOLVE_UNIT_ERRORS'; | |
| 3150 | |
| 3151 /** | |
| 2950 * The name of the [VARIABLE_REFERENCE_ERRORS] input. | 3152 * The name of the [VARIABLE_REFERENCE_ERRORS] input. |
| 2951 */ | 3153 */ |
| 2952 static const String VARIABLE_REFERENCE_ERRORS_INPUT = | 3154 static const String VARIABLE_REFERENCE_ERRORS_INPUT = |
| 2953 'VARIABLE_REFERENCE_ERRORS'; | 3155 'VARIABLE_REFERENCE_ERRORS'; |
| 2954 | 3156 |
| 2955 /** | 3157 /** |
| 2956 * The name of the [VERIFY_ERRORS] input. | 3158 * The name of the [VERIFY_ERRORS] input. |
| 2957 */ | 3159 */ |
| 2958 static const String VERIFY_ERRORS_INPUT = 'VERIFY_ERRORS'; | 3160 static const String VERIFY_ERRORS_INPUT = 'VERIFY_ERRORS'; |
| 2959 | 3161 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 2975 @override | 3177 @override |
| 2976 void internalPerform() { | 3178 void internalPerform() { |
| 2977 // | 3179 // |
| 2978 // Prepare inputs. | 3180 // Prepare inputs. |
| 2979 // | 3181 // |
| 2980 List<List<AnalysisError>> errorLists = <List<AnalysisError>>[]; | 3182 List<List<AnalysisError>> errorLists = <List<AnalysisError>>[]; |
| 2981 errorLists.add(getRequiredInput(BUILD_DIRECTIVES_ERRORS_INPUT)); | 3183 errorLists.add(getRequiredInput(BUILD_DIRECTIVES_ERRORS_INPUT)); |
| 2982 errorLists.add(getRequiredInput(BUILD_LIBRARY_ERRORS_INPUT)); | 3184 errorLists.add(getRequiredInput(BUILD_LIBRARY_ERRORS_INPUT)); |
| 2983 errorLists.add(getRequiredInput(HINTS_INPUT)); | 3185 errorLists.add(getRequiredInput(HINTS_INPUT)); |
| 2984 errorLists.add(getRequiredInput(LINTS_INPUT)); | 3186 errorLists.add(getRequiredInput(LINTS_INPUT)); |
| 2985 errorLists.add(getRequiredInput(INFER_STATIC_VARIABLE_TYPES_ERRORS_INPUT)); | |
| 2986 errorLists.add(getRequiredInput(PARTIALLY_RESOLVE_REFERENCES_ERRORS_INPUT)); | |
| 2987 errorLists.add(getRequiredInput(RESOLVE_FUNCTION_BODIES_ERRORS_INPUT)); | |
| 2988 errorLists.add(getRequiredInput(RESOLVE_TYPE_NAMES_ERRORS_INPUT)); | 3187 errorLists.add(getRequiredInput(RESOLVE_TYPE_NAMES_ERRORS_INPUT)); |
| 3188 errorLists.add(getRequiredInput(RESOLVE_UNIT_ERRORS_INPUT)); | |
| 2989 errorLists.add(getRequiredInput(VARIABLE_REFERENCE_ERRORS_INPUT)); | 3189 errorLists.add(getRequiredInput(VARIABLE_REFERENCE_ERRORS_INPUT)); |
| 2990 errorLists.add(getRequiredInput(VERIFY_ERRORS_INPUT)); | 3190 errorLists.add(getRequiredInput(VERIFY_ERRORS_INPUT)); |
| 2991 // | 3191 // |
| 2992 // Record outputs. | 3192 // Record outputs. |
| 2993 // | 3193 // |
| 2994 outputs[LIBRARY_UNIT_ERRORS] = AnalysisError.mergeLists(errorLists); | 3194 outputs[LIBRARY_UNIT_ERRORS] = AnalysisError.mergeLists(errorLists); |
| 2995 } | 3195 } |
| 2996 | 3196 |
| 2997 /** | 3197 /** |
| 2998 * Return a map from the names of the inputs of this kind of task to the task | 3198 * Return a map from the names of the inputs of this kind of task to the task |
| 2999 * input descriptors describing those inputs for a task with the | 3199 * input descriptors describing those inputs for a task with the |
| 3000 * given [unit]. | 3200 * given [unit]. |
| 3001 */ | 3201 */ |
| 3002 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 3202 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 3003 LibrarySpecificUnit unit = target; | 3203 LibrarySpecificUnit unit = target; |
| 3004 Map<String, TaskInput> inputs = <String, TaskInput>{ | 3204 Map<String, TaskInput> inputs = <String, TaskInput>{ |
| 3005 HINTS_INPUT: HINTS.of(unit), | 3205 HINTS_INPUT: HINTS.of(unit), |
| 3006 LINTS_INPUT: LINTS.of(unit), | 3206 LINTS_INPUT: LINTS.of(unit), |
| 3007 INFER_STATIC_VARIABLE_TYPES_ERRORS_INPUT: | |
| 3008 INFER_STATIC_VARIABLE_TYPES_ERRORS.of(unit), | |
| 3009 PARTIALLY_RESOLVE_REFERENCES_ERRORS_INPUT: | |
| 3010 PARTIALLY_RESOLVE_REFERENCES_ERRORS.of(unit), | |
| 3011 RESOLVE_FUNCTION_BODIES_ERRORS_INPUT: | |
| 3012 RESOLVE_FUNCTION_BODIES_ERRORS.of(unit), | |
| 3013 RESOLVE_TYPE_NAMES_ERRORS_INPUT: RESOLVE_TYPE_NAMES_ERRORS.of(unit), | 3207 RESOLVE_TYPE_NAMES_ERRORS_INPUT: RESOLVE_TYPE_NAMES_ERRORS.of(unit), |
| 3208 RESOLVE_UNIT_ERRORS_INPUT: RESOLVE_UNIT_ERRORS.of(unit), | |
| 3014 VARIABLE_REFERENCE_ERRORS_INPUT: VARIABLE_REFERENCE_ERRORS.of(unit), | 3209 VARIABLE_REFERENCE_ERRORS_INPUT: VARIABLE_REFERENCE_ERRORS.of(unit), |
| 3015 VERIFY_ERRORS_INPUT: VERIFY_ERRORS.of(unit) | 3210 VERIFY_ERRORS_INPUT: VERIFY_ERRORS.of(unit) |
| 3016 }; | 3211 }; |
| 3017 Source source = unit.source; | 3212 Source source = unit.source; |
| 3018 if (unit.library == source) { | 3213 if (unit.library == source) { |
| 3019 inputs[BUILD_DIRECTIVES_ERRORS_INPUT] = | 3214 inputs[BUILD_DIRECTIVES_ERRORS_INPUT] = |
| 3020 BUILD_DIRECTIVES_ERRORS.of(source); | 3215 BUILD_DIRECTIVES_ERRORS.of(source); |
| 3021 inputs[BUILD_LIBRARY_ERRORS_INPUT] = BUILD_LIBRARY_ERRORS.of(source); | 3216 inputs[BUILD_LIBRARY_ERRORS_INPUT] = BUILD_LIBRARY_ERRORS.of(source); |
| 3022 } else { | 3217 } else { |
| 3023 inputs[BUILD_DIRECTIVES_ERRORS_INPUT] = | 3218 inputs[BUILD_DIRECTIVES_ERRORS_INPUT] = |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3244 * The name of the [TYPE_PROVIDER] input. | 3439 * The name of the [TYPE_PROVIDER] input. |
| 3245 */ | 3440 */ |
| 3246 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; | 3441 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; |
| 3247 | 3442 |
| 3248 /** | 3443 /** |
| 3249 * The task descriptor describing this kind of task. | 3444 * The task descriptor describing this kind of task. |
| 3250 */ | 3445 */ |
| 3251 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 3446 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 3252 'PartiallyResolveUnitReferencesTask', | 3447 'PartiallyResolveUnitReferencesTask', |
| 3253 createTask, | 3448 createTask, |
| 3254 buildInputs, <ResultDescriptor>[ | 3449 buildInputs, |
| 3255 INFERABLE_STATIC_VARIABLES_IN_UNIT, | 3450 <ResultDescriptor>[INFERABLE_STATIC_VARIABLES_IN_UNIT, RESOLVED_UNIT5]); |
| 3256 PARTIALLY_RESOLVE_REFERENCES_ERRORS, | |
| 3257 RESOLVED_UNIT5 | |
| 3258 ]); | |
| 3259 | 3451 |
| 3260 PartiallyResolveUnitReferencesTask( | 3452 PartiallyResolveUnitReferencesTask( |
| 3261 InternalAnalysisContext context, AnalysisTarget target) | 3453 InternalAnalysisContext context, AnalysisTarget target) |
| 3262 : super(context, target); | 3454 : super(context, target); |
| 3263 | 3455 |
| 3264 @override | 3456 @override |
| 3265 TaskDescriptor get descriptor => DESCRIPTOR; | 3457 TaskDescriptor get descriptor => DESCRIPTOR; |
| 3266 | 3458 |
| 3267 @override | 3459 @override |
| 3268 void internalPerform() { | 3460 void internalPerform() { |
| 3269 RecordingErrorListener errorListener = new RecordingErrorListener(); | |
| 3270 // | 3461 // |
| 3271 // Prepare inputs. | 3462 // Prepare inputs. |
| 3272 // | 3463 // |
| 3273 LibraryElement libraryElement = getRequiredInput(LIBRARY_INPUT); | 3464 LibraryElement libraryElement = getRequiredInput(LIBRARY_INPUT); |
| 3274 CompilationUnit unit = getRequiredInput(UNIT_INPUT); | 3465 CompilationUnit unit = getRequiredInput(UNIT_INPUT); |
| 3275 CompilationUnitElement unitElement = unit.element; | 3466 CompilationUnitElement unitElement = unit.element; |
| 3276 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); | 3467 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); |
| 3277 // | 3468 if (context.analysisOptions.strongMode) { |
| 3278 // Resolve references. | 3469 // |
| 3279 // | 3470 // Resolve references. |
| 3280 InheritanceManager inheritanceManager = | 3471 // |
| 3281 new InheritanceManager(libraryElement); | 3472 InheritanceManager inheritanceManager = |
| 3282 PartialResolverVisitor visitor = new PartialResolverVisitor( | 3473 new InheritanceManager(libraryElement); |
| 3283 libraryElement, unitElement.source, typeProvider, errorListener, | 3474 PartialResolverVisitor visitor = new PartialResolverVisitor( |
| 3284 inheritanceManager: inheritanceManager); | 3475 libraryElement, |
| 3285 unit.accept(visitor); | 3476 unitElement.source, |
| 3286 // | 3477 typeProvider, |
| 3287 // Record outputs. | 3478 AnalysisErrorListener.NULL_LISTENER, |
| 3288 // | 3479 inheritanceManager: inheritanceManager); |
| 3289 outputs[INFERABLE_STATIC_VARIABLES_IN_UNIT] = visitor.variablesAndFields; | 3480 unit.accept(visitor); |
| 3290 outputs[PARTIALLY_RESOLVE_REFERENCES_ERRORS] = | 3481 // |
| 3291 removeDuplicateErrors(errorListener.errors); | 3482 // Record outputs. |
| 3483 // | |
| 3484 outputs[INFERABLE_STATIC_VARIABLES_IN_UNIT] = visitor.variablesAndFields; | |
| 3485 } else { | |
| 3486 outputs[INFERABLE_STATIC_VARIABLES_IN_UNIT] = []; | |
| 3487 } | |
| 3292 outputs[RESOLVED_UNIT5] = unit; | 3488 outputs[RESOLVED_UNIT5] = unit; |
| 3293 } | 3489 } |
| 3294 | 3490 |
| 3295 /** | 3491 /** |
| 3296 * Return a map from the names of the inputs of this kind of task to the task | 3492 * Return a map from the names of the inputs of this kind of task to the task |
| 3297 * input descriptors describing those inputs for a task with the | 3493 * input descriptors describing those inputs for a task with the |
| 3298 * given [target]. | 3494 * given [target]. |
| 3299 */ | 3495 */ |
| 3300 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 3496 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 3301 LibrarySpecificUnit unit = target; | 3497 LibrarySpecificUnit unit = target; |
| 3302 return <String, TaskInput>{ | 3498 return <String, TaskInput>{ |
| 3303 'fullyBuiltLibraryElements': IMPORT_EXPORT_SOURCE_CLOSURE | 3499 'fullyBuiltLibraryElements': IMPORT_EXPORT_SOURCE_CLOSURE |
| 3304 .of(unit.library) | 3500 .of(unit.library) |
| 3305 .toListOf(LIBRARY_ELEMENT5), | 3501 .toListOf(LIBRARY_ELEMENT5), |
| 3306 LIBRARY_INPUT: LIBRARY_ELEMENT5.of(unit.library), | 3502 LIBRARY_INPUT: LIBRARY_ELEMENT5.of(unit.library), |
| 3307 UNIT_INPUT: RESOLVED_UNIT4.of(unit), | 3503 UNIT_INPUT: RESOLVED_UNIT4.of(unit), |
| 3308 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) | 3504 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), |
| 3505 // In strong mode, add additional dependencies to enforce inference | |
| 3506 // ordering. | |
| 3507 | |
| 3508 // Require that full inference be complete for all dependencies of the | |
| 3509 // current library cycle. | |
| 3510 'orderLibraryCycles': LIBRARY_CYCLE_DEPENDENCIES.of(unit).toList( | |
| 3511 (CompilationUnitElementImpl unit) => RESOLVED_UNIT8 | |
| 3512 .of(new LibrarySpecificUnit(unit.librarySource, unit.source))) | |
| 3309 }; | 3513 }; |
| 3310 } | 3514 } |
| 3311 | 3515 |
| 3312 /** | 3516 /** |
| 3313 * Create a [PartiallyResolveUnitReferencesTask] based on the given [target] | 3517 * Create a [PartiallyResolveUnitReferencesTask] based on the given [target] |
| 3314 * in the given [context]. | 3518 * in the given [context]. |
| 3315 */ | 3519 */ |
| 3316 static PartiallyResolveUnitReferencesTask createTask( | 3520 static PartiallyResolveUnitReferencesTask createTask( |
| 3317 AnalysisContext context, AnalysisTarget target) { | 3521 AnalysisContext context, AnalysisTarget target) { |
| 3318 return new PartiallyResolveUnitReferencesTask(context, target); | 3522 return new PartiallyResolveUnitReferencesTask(context, target); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3453 dependsOn.add(name); | 3657 dependsOn.add(name); |
| 3454 } | 3658 } |
| 3455 } | 3659 } |
| 3456 } | 3660 } |
| 3457 } | 3661 } |
| 3458 | 3662 |
| 3459 /** | 3663 /** |
| 3460 * A task that resolves the bodies of top-level functions, constructors, and | 3664 * A task that resolves the bodies of top-level functions, constructors, and |
| 3461 * methods within a single compilation unit. | 3665 * methods within a single compilation unit. |
| 3462 */ | 3666 */ |
| 3463 class ResolveFunctionBodiesInUnitTask extends SourceBasedAnalysisTask { | 3667 class ResolveUnitTask extends SourceBasedAnalysisTask { |
| 3668 /** | |
| 3669 * The name of the input whose value is the defining [LIBRARY_ELEMENT5]. | |
| 3670 */ | |
| 3671 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; | |
| 3672 | |
| 3464 /** | 3673 /** |
| 3465 * The name of the [TYPE_PROVIDER] input. | 3674 * The name of the [TYPE_PROVIDER] input. |
| 3466 */ | 3675 */ |
| 3467 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; | 3676 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; |
| 3468 | 3677 |
| 3469 /** | 3678 /** |
| 3470 * The name of the [RESOLVED_UNIT7] input. | 3679 * The name of the [RESOLVED_UNIT8] input. |
| 3471 */ | 3680 */ |
| 3472 static const String UNIT_INPUT = 'UNIT_INPUT'; | 3681 static const String UNIT_INPUT = 'UNIT_INPUT'; |
| 3473 | 3682 |
| 3474 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 3683 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 3475 'ResolveFunctionBodiesInUnitTask', | 3684 'ResolveUnitTask', |
| 3476 createTask, | 3685 createTask, |
| 3477 buildInputs, | 3686 buildInputs, |
| 3478 <ResultDescriptor>[RESOLVE_FUNCTION_BODIES_ERRORS, RESOLVED_UNIT8]); | 3687 <ResultDescriptor>[RESOLVE_UNIT_ERRORS, RESOLVED_UNIT9]); |
| 3479 | 3688 |
| 3480 ResolveFunctionBodiesInUnitTask( | 3689 ResolveUnitTask( |
| 3481 InternalAnalysisContext context, LibrarySpecificUnit compilationUnit) | 3690 InternalAnalysisContext context, LibrarySpecificUnit compilationUnit) |
| 3482 : super(context, compilationUnit); | 3691 : super(context, compilationUnit); |
| 3483 | 3692 |
| 3484 @override | 3693 @override |
| 3485 TaskDescriptor get descriptor => DESCRIPTOR; | 3694 TaskDescriptor get descriptor => DESCRIPTOR; |
| 3486 | 3695 |
| 3487 @override | 3696 @override |
| 3488 void internalPerform() { | 3697 void internalPerform() { |
| 3489 // | 3698 // |
| 3490 // Prepare inputs. | 3699 // Prepare inputs. |
| 3491 // | 3700 // |
| 3701 LibraryElement libraryElement = getRequiredInput(LIBRARY_INPUT); | |
| 3492 CompilationUnit unit = getRequiredInput(UNIT_INPUT); | 3702 CompilationUnit unit = getRequiredInput(UNIT_INPUT); |
| 3493 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); | 3703 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); |
| 3494 // | 3704 // |
| 3495 // Resolve function bodies. | 3705 // Resolve everything |
| 3496 // | 3706 // |
| 3497 CompilationUnitElement unitElement = unit.element; | 3707 CompilationUnitElement unitElement = unit.element; |
| 3498 RecordingErrorListener errorListener = new RecordingErrorListener(); | 3708 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 3499 for (CompilationUnitMember unitMember in unit.declarations) { | 3709 ResolverVisitor visitor = new ResolverVisitor( |
| 3500 if (unitMember is FunctionDeclaration) { | 3710 libraryElement, unitElement.source, typeProvider, errorListener); |
| 3501 _resolveFunctionBody(unitMember.functionExpression.body, unitElement, | 3711 unit.accept(visitor); |
| 3502 typeProvider, errorListener); | |
| 3503 } else if (unitMember is ClassDeclaration) { | |
| 3504 for (ClassMember classMember in unitMember.members) { | |
| 3505 if (classMember is ConstructorDeclaration) { | |
| 3506 _resolveFunctionBody( | |
| 3507 classMember.body, unitElement, typeProvider, errorListener); | |
| 3508 } else if (classMember is MethodDeclaration) { | |
| 3509 _resolveFunctionBody( | |
| 3510 classMember.body, unitElement, typeProvider, errorListener); | |
| 3511 } | |
| 3512 } | |
| 3513 } | |
| 3514 } | |
| 3515 // | 3712 // |
| 3516 // Record outputs. | 3713 // Record outputs. |
| 3517 // | 3714 // |
| 3518 outputs[RESOLVE_FUNCTION_BODIES_ERRORS] = errorListener.errors; | 3715 outputs[RESOLVE_UNIT_ERRORS] = errorListener.errors; |
| 3519 outputs[RESOLVED_UNIT8] = unit; | 3716 outputs[RESOLVED_UNIT9] = unit; |
| 3520 } | |
| 3521 | |
| 3522 void _resolveFunctionBody( | |
| 3523 FunctionBody functionBody, | |
| 3524 CompilationUnitElement unitElement, | |
| 3525 TypeProvider typeProvider, | |
| 3526 RecordingErrorListener errorListener) { | |
| 3527 ResolutionContext resolutionContext = | |
| 3528 ResolutionContextBuilder.contextFor(functionBody, errorListener); | |
| 3529 ResolverVisitor visitor = new ResolverVisitor( | |
| 3530 unitElement.library, unitElement.source, typeProvider, errorListener, | |
| 3531 nameScope: resolutionContext.scope); | |
| 3532 if (resolutionContext.enclosingClassDeclaration != null) { | |
| 3533 visitor.prepareToResolveMembersInClass( | |
| 3534 resolutionContext.enclosingClassDeclaration); | |
| 3535 } | |
| 3536 Declaration declaration = functionBody.getAncestor((AstNode node) => | |
| 3537 node is ConstructorDeclaration || | |
| 3538 node is FunctionDeclaration || | |
| 3539 node is MethodDeclaration); | |
| 3540 visitor.initForIncrementalResolution(declaration); | |
| 3541 functionBody.accept(visitor); | |
| 3542 if (declaration is FunctionDeclaration) { | |
| 3543 // This is in the wrong place. The propagated return type is stored | |
| 3544 // locally in the resolver, not in the declaration (or element). Hence, | |
| 3545 // this needs to happen later. | |
| 3546 declaration.accept(visitor.typeAnalyzer); | |
| 3547 } | |
| 3548 } | 3717 } |
| 3549 | 3718 |
| 3550 /** | 3719 /** |
| 3551 * Return a map from the names of the inputs of this kind of task to the task | 3720 * Return a map from the names of the inputs of this kind of task to the task |
| 3552 * input descriptors describing those inputs for a task with the given | 3721 * input descriptors describing those inputs for a task with the given |
| 3553 * [target]. | 3722 * [target]. |
| 3554 */ | 3723 */ |
| 3555 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 3724 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 3556 LibrarySpecificUnit unit = target; | 3725 LibrarySpecificUnit unit = target; |
| 3557 return <String, TaskInput>{ | 3726 return <String, TaskInput>{ |
| 3727 LIBRARY_INPUT: LIBRARY_ELEMENT5.of(unit.library), | |
| 3558 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), | 3728 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), |
| 3559 UNIT_INPUT: RESOLVED_UNIT7.of(unit) | 3729 UNIT_INPUT: RESOLVED_UNIT8.of(unit), |
| 3730 // In strong mode, add additional dependencies to enforce inference | |
| 3731 // ordering. | |
| 3732 | |
| 3733 // Require that inference be complete for all units in the | |
| 3734 // current library cycle. | |
| 3735 'orderLibraryCycleTasks': LIBRARY_CYCLE_UNITS.of(unit).toList( | |
| 3736 (CompilationUnitElementImpl unit) => RESOLVED_UNIT8 | |
| 3737 .of(new LibrarySpecificUnit(unit.librarySource, unit.source))) | |
| 3560 }; | 3738 }; |
| 3561 } | 3739 } |
| 3562 | 3740 |
| 3563 /** | 3741 /** |
| 3564 * Create a [ResolveFunctionBodiesInUnitTask] based on the given [target] in | 3742 * Create a [ResolveUnitTask] based on the given [target] in |
| 3565 * the given [context]. | 3743 * the given [context]. |
| 3566 */ | 3744 */ |
| 3567 static ResolveFunctionBodiesInUnitTask createTask( | 3745 static ResolveUnitTask createTask( |
| 3568 AnalysisContext context, AnalysisTarget target) { | 3746 AnalysisContext context, AnalysisTarget target) { |
| 3569 return new ResolveFunctionBodiesInUnitTask(context, target); | 3747 return new ResolveUnitTask(context, target); |
| 3570 } | 3748 } |
| 3571 } | 3749 } |
| 3572 | 3750 |
| 3573 /** | 3751 /** |
| 3574 * A task that finishes resolution by requesting [RESOLVED_UNIT_NO_CONSTANTS] fo r every | 3752 * A task that finishes resolution by requesting [RESOLVED_UNIT_NO_CONSTANTS] fo r every |
| 3575 * unit in the libraries closure and produces [LIBRARY_ELEMENT]. | 3753 * unit in the libraries closure and produces [LIBRARY_ELEMENT]. |
| 3576 */ | 3754 */ |
| 3577 class ResolveLibraryReferencesTask extends SourceBasedAnalysisTask { | 3755 class ResolveLibraryReferencesTask extends SourceBasedAnalysisTask { |
| 3578 /** | 3756 /** |
| 3579 * The name of the [LIBRARY_ELEMENT5] input. | 3757 * The name of the [LIBRARY_ELEMENT5] input. |
| 3580 */ | 3758 */ |
| 3581 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; | 3759 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; |
| 3582 | 3760 |
| 3583 /** | 3761 /** |
| 3584 * The name of the list of [RESOLVED_UNIT8] input. | 3762 * The name of the list of [RESOLVED_UNIT9] input. |
| 3585 */ | 3763 */ |
| 3586 static const String UNITS_INPUT = 'UNITS_INPUT'; | 3764 static const String UNITS_INPUT = 'UNITS_INPUT'; |
| 3587 | 3765 |
| 3588 /** | 3766 /** |
| 3589 * The task descriptor describing this kind of task. | 3767 * The task descriptor describing this kind of task. |
| 3590 */ | 3768 */ |
| 3591 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 3769 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 3592 'ResolveLibraryReferencesTask', | 3770 'ResolveLibraryReferencesTask', |
| 3593 createTask, | 3771 createTask, |
| 3594 buildInputs, | 3772 buildInputs, |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 3623 /** | 3801 /** |
| 3624 * Return a map from the names of the inputs of this kind of task to the task | 3802 * Return a map from the names of the inputs of this kind of task to the task |
| 3625 * input descriptors describing those inputs for a task with the | 3803 * input descriptors describing those inputs for a task with the |
| 3626 * given [target]. | 3804 * given [target]. |
| 3627 */ | 3805 */ |
| 3628 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 3806 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 3629 Source source = target; | 3807 Source source = target; |
| 3630 return <String, TaskInput>{ | 3808 return <String, TaskInput>{ |
| 3631 LIBRARY_INPUT: LIBRARY_ELEMENT5.of(source), | 3809 LIBRARY_INPUT: LIBRARY_ELEMENT5.of(source), |
| 3632 UNITS_INPUT: UNITS.of(source).toList((Source unit) => | 3810 UNITS_INPUT: UNITS.of(source).toList((Source unit) => |
| 3633 RESOLVED_UNIT8.of(new LibrarySpecificUnit(source, unit))), | 3811 RESOLVED_UNIT9.of(new LibrarySpecificUnit(source, unit))), |
| 3634 'resolvedUnits': IMPORT_EXPORT_SOURCE_CLOSURE | 3812 'resolvedUnits': IMPORT_EXPORT_SOURCE_CLOSURE |
| 3635 .of(source) | 3813 .of(source) |
| 3636 .toMapOf(UNITS) | 3814 .toMapOf(UNITS) |
| 3637 .toFlattenList((Source library, Source unit) => | 3815 .toFlattenList((Source library, Source unit) => |
| 3638 RESOLVED_UNIT8.of(new LibrarySpecificUnit(library, unit))), | 3816 RESOLVED_UNIT9.of(new LibrarySpecificUnit(library, unit))), |
| 3639 }; | 3817 }; |
| 3640 } | 3818 } |
| 3641 | 3819 |
| 3642 /** | 3820 /** |
| 3643 * Create a [ResolveLibraryReferencesTask] based on the given [target] in | 3821 * Create a [ResolveLibraryReferencesTask] based on the given [target] in |
| 3644 * the given [context]. | 3822 * the given [context]. |
| 3645 */ | 3823 */ |
| 3646 static ResolveLibraryReferencesTask createTask( | 3824 static ResolveLibraryReferencesTask createTask( |
| 3647 AnalysisContext context, AnalysisTarget target) { | 3825 AnalysisContext context, AnalysisTarget target) { |
| 3648 return new ResolveLibraryReferencesTask(context, target); | 3826 return new ResolveLibraryReferencesTask(context, target); |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4234 | 4412 |
| 4235 @override | 4413 @override |
| 4236 bool moveNext() { | 4414 bool moveNext() { |
| 4237 if (_newSources.isEmpty) { | 4415 if (_newSources.isEmpty) { |
| 4238 return false; | 4416 return false; |
| 4239 } | 4417 } |
| 4240 currentTarget = _newSources.removeLast(); | 4418 currentTarget = _newSources.removeLast(); |
| 4241 return true; | 4419 return true; |
| 4242 } | 4420 } |
| 4243 } | 4421 } |
| OLD | NEW |