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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 /** | 146 /** |
| 147 * The sources representing the combined import/export closure of a library. | 147 * The sources representing the combined import/export closure of a library. |
| 148 * The [Source]s include only library sources, not their units. | 148 * The [Source]s include only library sources, not their units. |
| 149 * | 149 * |
| 150 * The result is only available for [Source]s representing a library. | 150 * The result is only available for [Source]s representing a library. |
| 151 */ | 151 */ |
| 152 final ListResultDescriptor<Source> IMPORT_EXPORT_SOURCE_CLOSURE = | 152 final ListResultDescriptor<Source> IMPORT_EXPORT_SOURCE_CLOSURE = |
| 153 new ListResultDescriptor<Source>('IMPORT_EXPORT_SOURCE_CLOSURE', null); | 153 new ListResultDescriptor<Source>('IMPORT_EXPORT_SOURCE_CLOSURE', null); |
| 154 | 154 |
| 155 /** | 155 /** |
| 156 * The errors produced while inferring the type of a static variable. | 156 * A list of the [LibraryElement]s that make up the strongly connected |
| 157 * component in the import/export graph in which the target resides. | |
| 157 * | 158 * |
| 158 * The list will be empty if there were no errors, but will not be `null`. | 159 * Only non-empty in strongMode |
|
Brian Wilkerson
2015/10/06 19:04:46
nit: It would be helpful (here and elsewhere) to i
Leaf
2015/10/07 18:53:55
Done.
| |
| 159 * | 160 * |
| 160 * The result is only available for [VariableElement]s, and only when strong | |
| 161 * mode is enabled. | |
| 162 */ | 161 */ |
| 163 final ListResultDescriptor<AnalysisError> INFER_STATIC_VARIABLE_ERRORS = | 162 final ListResultDescriptor<LibraryElement> LIBRARY_CYCLE = |
| 164 new ListResultDescriptor<AnalysisError>( | 163 new ListResultDescriptor<LibraryElement>('LIBRARY_CYCLE', null); |
| 165 'INFER_STATIC_VARIABLE_ERRORS', AnalysisError.NO_ERRORS); | |
| 166 | 164 |
| 167 /** | 165 /** |
| 168 * The errors produced while inferring the types of all of the static variables | 166 * A list of the [CompilationUnitElement]s (including all parts) that make up |
| 169 * in a compilation unit. | 167 * the strongly connected component in the import/export graph in which the |
| 168 * target resides. | |
| 170 * | 169 * |
| 171 * The list will be empty if there were no errors, but will not be `null`. | 170 * Only non-empty in strongMode |
| 172 * | 171 * |
| 173 * The result is only available for [LibrarySpecificUnit]s. | |
| 174 */ | 172 */ |
| 175 final ListResultDescriptor<AnalysisError> INFER_STATIC_VARIABLE_TYPES_ERRORS = | 173 final ListResultDescriptor<CompilationUnitElement> LIBRARY_CYCLE_UNITS = |
| 176 new ListResultDescriptor<AnalysisError>( | 174 new ListResultDescriptor<CompilationUnitElement>( |
| 177 'INFER_STATIC_VARIABLE_TYPES_ERRORS', AnalysisError.NO_ERRORS); | 175 'LIBRARY_CYCLE_UNITS', null); |
| 176 | |
| 177 /** | |
| 178 * A list of the [CompilationUnitElement]s that comprise all of the parts and | |
| 179 * libraries in the direct import/export dependencies of the library cycle | |
| 180 * of the target, with the intra-component dependencies excluded. | |
| 181 * | |
| 182 * Only non-empty in strongMode | |
| 183 * | |
| 184 */ | |
| 185 final ListResultDescriptor<CompilationUnitElement> LIBRARY_CYCLE_DEPENDENCIES = | |
| 186 new ListResultDescriptor<CompilationUnitElement>( | |
| 187 'LIBRARY_CYCLE_DEPENDENCIES', null); | |
| 178 | 188 |
| 179 /** | 189 /** |
| 180 * A list of the [VariableElement]s whose type should be inferred that another | 190 * A list of the [VariableElement]s whose type should be inferred that another |
| 181 * inferable static variable (the target) depends on. | 191 * inferable static variable (the target) depends on. |
| 182 * | 192 * |
| 183 * The result is only available for [VariableElement]s, and only when strong | 193 * The result is only available for [VariableElement]s, and only when strong |
| 184 * mode is enabled. | 194 * mode is enabled. |
| 185 */ | 195 */ |
| 186 final ListResultDescriptor< | 196 final ListResultDescriptor< |
| 187 VariableElement> INFERABLE_STATIC_VARIABLE_DEPENDENCIES = | 197 VariableElement> INFERABLE_STATIC_VARIABLE_DEPENDENCIES = |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 * | 305 * |
| 296 * The list will be empty if there were no errors, but will not be `null`. | 306 * The list will be empty if there were no errors, but will not be `null`. |
| 297 * | 307 * |
| 298 * The result is only available for [Source]s representing a compilation unit. | 308 * The result is only available for [Source]s representing a compilation unit. |
| 299 */ | 309 */ |
| 300 final ListResultDescriptor<AnalysisError> PARSE_ERRORS = | 310 final ListResultDescriptor<AnalysisError> PARSE_ERRORS = |
| 301 new ListResultDescriptor<AnalysisError>( | 311 new ListResultDescriptor<AnalysisError>( |
| 302 'PARSE_ERRORS', AnalysisError.NO_ERRORS); | 312 'PARSE_ERRORS', AnalysisError.NO_ERRORS); |
| 303 | 313 |
| 304 /** | 314 /** |
| 305 * The errors produced while resolving references outside of function bodies. | |
| 306 * | |
| 307 * The list will be empty if there were no errors, but will not be `null`. | |
| 308 * | |
| 309 * The result is only available for [LibrarySpecificUnit]s. | |
| 310 */ | |
| 311 final ListResultDescriptor<AnalysisError> PARTIALLY_RESOLVE_REFERENCES_ERRORS = | |
| 312 new ListResultDescriptor<AnalysisError>( | |
| 313 'PARTIALLY_RESOLVE_REFERENCES_ERRORS', AnalysisError.NO_ERRORS); | |
| 314 | |
| 315 /** | |
| 316 * The names (resolved and not) referenced by a unit. | 315 * The names (resolved and not) referenced by a unit. |
| 317 * | 316 * |
| 318 * The result is only available for [Source]s representing a compilation unit. | 317 * The result is only available for [Source]s representing a compilation unit. |
| 319 */ | 318 */ |
| 320 final ResultDescriptor<ReferencedNames> REFERENCED_NAMES = | 319 final ResultDescriptor<ReferencedNames> REFERENCED_NAMES = |
| 321 new ResultDescriptor<ReferencedNames>('REFERENCED_NAMES', null); | 320 new ResultDescriptor<ReferencedNames>('REFERENCED_NAMES', null); |
| 322 | 321 |
| 323 /** | 322 /** |
| 324 * The errors produced while resolving the function bodies within a compilation | 323 * The errors produced while resolving a full compilation unit. |
| 325 * unit. | |
| 326 * | 324 * |
| 327 * The list will be empty if there were no errors, but will not be `null`. | 325 * The list will be empty if there were no errors, but will not be `null`. |
| 328 * | 326 * |
| 329 * The result is only available for [LibrarySpecificUnit]s. | 327 * The result is only available for [LibrarySpecificUnit]s. |
| 330 */ | 328 */ |
| 331 final ListResultDescriptor<AnalysisError> RESOLVE_FUNCTION_BODIES_ERRORS = | 329 final ListResultDescriptor<AnalysisError> RESOLVE_UNIT_ERRORS = |
| 332 new ListResultDescriptor<AnalysisError>( | 330 new ListResultDescriptor<AnalysisError>( |
| 333 'RESOLVE_FUNCTION_BODIES_ERRORS', AnalysisError.NO_ERRORS); | 331 'RESOLVE_UNIT_ERRORS', AnalysisError.NO_ERRORS); |
| 334 | 332 |
| 335 /** | 333 /** |
| 336 * The errors produced while resolving type names. | 334 * The errors produced while resolving type names. |
| 337 * | 335 * |
| 338 * The list will be empty if there were no errors, but will not be `null`. | 336 * The list will be empty if there were no errors, but will not be `null`. |
| 339 * | 337 * |
| 340 * The result is only available for [LibrarySpecificUnit]s. | 338 * The result is only available for [LibrarySpecificUnit]s. |
| 341 */ | 339 */ |
| 342 final ListResultDescriptor<AnalysisError> RESOLVE_TYPE_NAMES_ERRORS = | 340 final ListResultDescriptor<AnalysisError> RESOLVE_TYPE_NAMES_ERRORS = |
| 343 new ListResultDescriptor<AnalysisError>( | 341 new ListResultDescriptor<AnalysisError>( |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 404 * that is true of a [RESOLVED_UNIT5]. | 402 * that is true of a [RESOLVED_UNIT5]. |
| 405 * | 403 * |
| 406 * The result is only available for [LibrarySpecificUnit]s. | 404 * The result is only available for [LibrarySpecificUnit]s. |
| 407 */ | 405 */ |
| 408 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT6 = | 406 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT6 = |
| 409 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT6', null, | 407 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT6', null, |
| 410 cachingPolicy: AST_CACHING_POLICY); | 408 cachingPolicy: AST_CACHING_POLICY); |
| 411 | 409 |
| 412 /** | 410 /** |
| 413 * The resolved [CompilationUnit] associated with a compilation unit in which | 411 * The resolved [CompilationUnit] associated with a compilation unit in which |
| 414 * the types of class members have been inferred in addition to everything that | 412 * the right hand sides of instance variables have been re-resolved in addition |
| 415 * is true of a [RESOLVED_UNIT7]. | 413 * to everything that is true of a [RESOLVED_UNIT6]. |
| 416 * | 414 * |
| 417 * The result is only available for [LibrarySpecificUnit]s. | 415 * The result is only available for [LibrarySpecificUnit]s. |
| 418 */ | 416 */ |
| 419 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT7 = | 417 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT7 = |
| 420 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT7', null, | 418 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT7', null, |
| 421 cachingPolicy: AST_CACHING_POLICY); | 419 cachingPolicy: AST_CACHING_POLICY); |
| 422 | 420 |
| 423 /** | 421 /** |
| 424 * The resolved [CompilationUnit] associated with a compilation unit, with | 422 * The resolved [CompilationUnit] associated with a compilation unit in which |
| 425 * constants not yet resolved. | 423 * the types of class members have been inferred in addition to everything that |
| 424 * is true of a [RESOLVED_UNIT8]. | |
| 426 * | 425 * |
| 427 * The result is only available for [LibrarySpecificUnit]s. | 426 * The result is only available for [LibrarySpecificUnit]s. |
| 428 */ | 427 */ |
| 429 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT8 = | 428 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT8 = |
| 430 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT8', null, | 429 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT8', null, |
| 431 cachingPolicy: AST_CACHING_POLICY); | 430 cachingPolicy: AST_CACHING_POLICY); |
| 432 | 431 |
| 433 /** | 432 /** |
| 433 * The resolved [CompilationUnit] associated with a compilation unit, with | |
| 434 * constants not yet resolved. | |
| 435 * | |
| 436 * The result is only available for [LibrarySpecificUnit]s. | |
| 437 */ | |
| 438 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT9 = | |
| 439 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT9', null, | |
| 440 cachingPolicy: AST_CACHING_POLICY); | |
| 441 | |
| 442 /** | |
| 434 * The errors produced while scanning a compilation unit. | 443 * The errors produced while scanning a compilation unit. |
| 435 * | 444 * |
| 436 * The list will be empty if there were no errors, but will not be `null`. | 445 * The list will be empty if there were no errors, but will not be `null`. |
| 437 * | 446 * |
| 438 * The result is only available for [Source]s representing a compilation unit. | 447 * The result is only available for [Source]s representing a compilation unit. |
| 439 */ | 448 */ |
| 440 final ListResultDescriptor<AnalysisError> SCAN_ERRORS = | 449 final ListResultDescriptor<AnalysisError> SCAN_ERRORS = |
| 441 new ListResultDescriptor<AnalysisError>( | 450 new ListResultDescriptor<AnalysisError>( |
| 442 'SCAN_ERRORS', AnalysisError.NO_ERRORS); | 451 'SCAN_ERRORS', AnalysisError.NO_ERRORS); |
| 443 | 452 |
| (...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1475 AnalysisContext context, AnalysisTarget target) { | 1484 AnalysisContext context, AnalysisTarget target) { |
| 1476 return new BuildTypeProviderTask(context, target); | 1485 return new BuildTypeProviderTask(context, target); |
| 1477 } | 1486 } |
| 1478 } | 1487 } |
| 1479 | 1488 |
| 1480 /** | 1489 /** |
| 1481 * A task that computes [CONSTANT_DEPENDENCIES] for a constant. | 1490 * A task that computes [CONSTANT_DEPENDENCIES] for a constant. |
| 1482 */ | 1491 */ |
| 1483 class ComputeConstantDependenciesTask extends ConstantEvaluationAnalysisTask { | 1492 class ComputeConstantDependenciesTask extends ConstantEvaluationAnalysisTask { |
| 1484 /** | 1493 /** |
| 1485 * The name of the [RESOLVED_UNIT8] input. | 1494 * The name of the [RESOLVED_UNIT9] input. |
| 1486 */ | 1495 */ |
| 1487 static const String UNIT_INPUT = 'UNIT_INPUT'; | 1496 static const String UNIT_INPUT = 'UNIT_INPUT'; |
| 1488 | 1497 |
| 1489 /** | 1498 /** |
| 1490 * The name of the [TYPE_PROVIDER] input. | 1499 * The name of the [TYPE_PROVIDER] input. |
| 1491 */ | 1500 */ |
| 1492 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; | 1501 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; |
| 1493 | 1502 |
| 1494 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 1503 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 1495 'ComputeConstantDependenciesTask', | 1504 'ComputeConstantDependenciesTask', |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1531 /** | 1540 /** |
| 1532 * Return a map from the names of the inputs of this kind of task to the task | 1541 * Return a map from the names of the inputs of this kind of task to the task |
| 1533 * input descriptors describing those inputs for a task with the | 1542 * input descriptors describing those inputs for a task with the |
| 1534 * given [target]. | 1543 * given [target]. |
| 1535 */ | 1544 */ |
| 1536 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 1545 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 1537 if (target is Element) { | 1546 if (target is Element) { |
| 1538 CompilationUnitElementImpl unit = target | 1547 CompilationUnitElementImpl unit = target |
| 1539 .getAncestor((Element element) => element is CompilationUnitElement); | 1548 .getAncestor((Element element) => element is CompilationUnitElement); |
| 1540 return <String, TaskInput>{ | 1549 return <String, TaskInput>{ |
| 1541 UNIT_INPUT: RESOLVED_UNIT8 | 1550 UNIT_INPUT: RESOLVED_UNIT9 |
| 1542 .of(new LibrarySpecificUnit(unit.librarySource, target.source)), | 1551 .of(new LibrarySpecificUnit(unit.librarySource, target.source)), |
| 1543 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) | 1552 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) |
| 1544 }; | 1553 }; |
| 1545 } else if (target is ConstantEvaluationTarget_Annotation) { | 1554 } else if (target is ConstantEvaluationTarget_Annotation) { |
| 1546 return <String, TaskInput>{ | 1555 return <String, TaskInput>{ |
| 1547 UNIT_INPUT: RESOLVED_UNIT8 | 1556 UNIT_INPUT: RESOLVED_UNIT9 |
| 1548 .of(new LibrarySpecificUnit(target.librarySource, target.source)), | 1557 .of(new LibrarySpecificUnit(target.librarySource, target.source)), |
| 1549 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) | 1558 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) |
| 1550 }; | 1559 }; |
| 1551 } | 1560 } |
| 1552 throw new AnalysisException( | 1561 throw new AnalysisException( |
| 1553 'Cannot build inputs for a ${target.runtimeType}'); | 1562 'Cannot build inputs for a ${target.runtimeType}'); |
| 1554 } | 1563 } |
| 1555 | 1564 |
| 1556 /** | 1565 /** |
| 1557 * Create a [ComputeConstantDependenciesTask] based on the given [target] in | 1566 * Create a [ComputeConstantDependenciesTask] based on the given [target] in |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1736 * Create a [ComputeInferableStaticVariableDependenciesTask] based on the | 1745 * Create a [ComputeInferableStaticVariableDependenciesTask] based on the |
| 1737 * given [target] in the given [context]. | 1746 * given [target] in the given [context]. |
| 1738 */ | 1747 */ |
| 1739 static ComputeInferableStaticVariableDependenciesTask createTask( | 1748 static ComputeInferableStaticVariableDependenciesTask createTask( |
| 1740 AnalysisContext context, AnalysisTarget target) { | 1749 AnalysisContext context, AnalysisTarget target) { |
| 1741 return new ComputeInferableStaticVariableDependenciesTask(context, target); | 1750 return new ComputeInferableStaticVariableDependenciesTask(context, target); |
| 1742 } | 1751 } |
| 1743 } | 1752 } |
| 1744 | 1753 |
| 1745 /** | 1754 /** |
| 1755 * A task that computes the [LIBRARY_CYCLE_DEPENDENCIES] for a | |
| 1756 * compilation unit | |
|
Brian Wilkerson
2015/10/06 19:04:46
nit: missing period
Leaf
2015/10/07 18:53:55
Done.
| |
| 1757 */ | |
| 1758 class ComputeLibraryCycleDependenciesTask extends SourceBasedAnalysisTask { | |
|
Brian Wilkerson
2015/10/06 19:04:46
Is there a reason for this to be a separate task?
Leaf
2015/10/07 18:53:55
Done.
| |
| 1759 /** | |
| 1760 * The name of the [LIBRARY_CYCLE] input. | |
| 1761 */ | |
| 1762 static const String LIBRARY_CYCLE_INPUT = 'LIBRARY_CYCLE_INPUT'; | |
| 1763 | |
| 1764 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | |
| 1765 'ComputeLibraryCycleDependenciesTask', | |
| 1766 createTask, | |
| 1767 buildInputs, | |
| 1768 <ResultDescriptor>[LIBRARY_CYCLE_DEPENDENCIES]); | |
| 1769 | |
| 1770 ComputeLibraryCycleDependenciesTask( | |
| 1771 InternalAnalysisContext context, AnalysisTarget target) | |
| 1772 : super(context, target); | |
| 1773 | |
| 1774 @override | |
| 1775 TaskDescriptor get descriptor => DESCRIPTOR; | |
| 1776 | |
| 1777 @override | |
| 1778 void internalPerform() { | |
| 1779 if (context.analysisOptions.strongMode) { | |
| 1780 // | |
| 1781 // Prepare inputs. | |
| 1782 // | |
| 1783 List<LibraryElement> scc = getRequiredInput(LIBRARY_CYCLE_INPUT); | |
| 1784 | |
| 1785 Set<LibraryElement> filter = new Set<LibraryElement>.from(scc); | |
| 1786 Set<CompilationUnitElement> deps = new Set<CompilationUnitElement>(); | |
| 1787 void addLibrary(l) { | |
| 1788 if (!filter.contains(l)) { | |
| 1789 deps.addAll(l.units); | |
| 1790 } | |
| 1791 } | |
| 1792 for (LibraryElement l in scc) { | |
| 1793 l.importedLibraries.forEach(addLibrary); | |
| 1794 l.exportedLibraries.forEach(addLibrary); | |
| 1795 } | |
| 1796 outputs[LIBRARY_CYCLE_DEPENDENCIES] = deps.toList(); | |
| 1797 } else { | |
| 1798 outputs[LIBRARY_CYCLE_DEPENDENCIES] = []; | |
| 1799 } | |
| 1800 } | |
| 1801 | |
| 1802 /** | |
| 1803 * Return a map from the names of the inputs of this kind of task to the task | |
| 1804 * input descriptors describing those inputs for a task with the | |
| 1805 * given [target]. | |
| 1806 */ | |
| 1807 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | |
| 1808 LibrarySpecificUnit unit = target; | |
| 1809 return <String, TaskInput>{LIBRARY_CYCLE_INPUT: LIBRARY_CYCLE.of(unit)}; | |
| 1810 } | |
| 1811 | |
| 1812 /** | |
| 1813 * Create a [ComputeLibraryCycleDependenciesTask] based on the | |
| 1814 * given [target] in the given [context]. | |
| 1815 */ | |
| 1816 static ComputeLibraryCycleDependenciesTask createTask( | |
| 1817 AnalysisContext context, AnalysisTarget target) { | |
| 1818 return new ComputeLibraryCycleDependenciesTask(context, target); | |
| 1819 } | |
| 1820 } | |
| 1821 | |
| 1822 /** | |
| 1823 * A task that computes the [LIBRARY_CYCLE] for a | |
| 1824 * library element. Also computes the [LIBRARY_CYCLE_UNITS] | |
|
Brian Wilkerson
2015/10/06 19:04:46
nit: missing period
Leaf
2015/10/07 18:53:55
Done.
| |
| 1825 */ | |
| 1826 class ComputeLibraryCycleTask extends SourceBasedAnalysisTask { | |
| 1827 /** | |
| 1828 * The name of the [LIBRARY_ELEMENT2] input. | |
| 1829 */ | |
| 1830 static const String UNIT_INPUT = 'UNIT_INPUT'; | |
|
Brian Wilkerson
2015/10/06 19:04:46
Perhaps "LIBRARY_ELEMENT2_INPUT"? ("UNIT_INPUT" is
Leaf
2015/10/07 18:53:55
Done.
| |
| 1831 | |
| 1832 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | |
| 1833 'ComputeLibraryCycleForUnitTask', | |
| 1834 createTask, | |
| 1835 buildInputs, | |
| 1836 <ResultDescriptor>[LIBRARY_CYCLE, LIBRARY_CYCLE_UNITS]); | |
| 1837 | |
| 1838 ComputeLibraryCycleTask( | |
| 1839 InternalAnalysisContext context, AnalysisTarget target) | |
| 1840 : super(context, target); | |
| 1841 | |
| 1842 @override | |
| 1843 TaskDescriptor get descriptor => DESCRIPTOR; | |
| 1844 | |
| 1845 @override | |
| 1846 void internalPerform() { | |
| 1847 // | |
| 1848 // Record outputs. | |
| 1849 // | |
| 1850 if (context.analysisOptions.strongMode) { | |
| 1851 LibraryElementImpl library = getRequiredInput(UNIT_INPUT); | |
| 1852 List<LibraryElement> component = library.libraryCycle; | |
| 1853 outputs[LIBRARY_CYCLE] = component; | |
| 1854 outputs[LIBRARY_CYCLE_UNITS] = component.expand((l) => l.units).toList(); | |
| 1855 } else { | |
| 1856 outputs[LIBRARY_CYCLE] = []; | |
| 1857 outputs[LIBRARY_CYCLE_UNITS] = []; | |
| 1858 } | |
| 1859 } | |
| 1860 | |
| 1861 /** | |
| 1862 * Return a map from the names of the inputs of this kind of task to the task | |
| 1863 * input descriptors describing those inputs for a task with the | |
| 1864 * given [target]. | |
| 1865 */ | |
| 1866 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | |
| 1867 LibrarySpecificUnit unit = target; | |
| 1868 return <String, TaskInput>{ | |
| 1869 'resolveReachableLibraries': new _ImportExportSourceClosureTaskInput( | |
| 1870 unit.library, LIBRARY_ELEMENT2), | |
| 1871 UNIT_INPUT: LIBRARY_ELEMENT2.of(unit.library) | |
| 1872 }; | |
| 1873 } | |
| 1874 | |
| 1875 /** | |
| 1876 * Create a [ComputeLibraryCycleTask] based on the | |
| 1877 * given [target] in the given [context]. | |
| 1878 */ | |
| 1879 static ComputeLibraryCycleTask createTask( | |
| 1880 AnalysisContext context, AnalysisTarget target) { | |
| 1881 return new ComputeLibraryCycleTask(context, target); | |
| 1882 } | |
| 1883 } | |
| 1884 | |
| 1885 /** | |
| 1746 * A base class for analysis tasks whose target is expected to be a | 1886 * A base class for analysis tasks whose target is expected to be a |
| 1747 * [ConstantEvaluationTarget]. | 1887 * [ConstantEvaluationTarget]. |
| 1748 */ | 1888 */ |
| 1749 abstract class ConstantEvaluationAnalysisTask extends AnalysisTask { | 1889 abstract class ConstantEvaluationAnalysisTask extends AnalysisTask { |
| 1750 /** | 1890 /** |
| 1751 * Initialize a newly created task to perform analysis within the given | 1891 * Initialize a newly created task to perform analysis within the given |
| 1752 * [context] in order to produce results for the given [constant]. | 1892 * [context] in order to produce results for the given [constant]. |
| 1753 */ | 1893 */ |
| 1754 ConstantEvaluationAnalysisTask( | 1894 ConstantEvaluationAnalysisTask( |
| 1755 AnalysisContext context, ConstantEvaluationTarget constant) | 1895 AnalysisContext context, ConstantEvaluationTarget constant) |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1994 AnalysisContext context, AnalysisTarget target) { | 2134 AnalysisContext context, AnalysisTarget target) { |
| 1995 return new DartErrorsTask(context, target); | 2135 return new DartErrorsTask(context, target); |
| 1996 } | 2136 } |
| 1997 } | 2137 } |
| 1998 | 2138 |
| 1999 /** | 2139 /** |
| 2000 * A task that builds [RESOLVED_UNIT] for a unit. | 2140 * A task that builds [RESOLVED_UNIT] for a unit. |
| 2001 */ | 2141 */ |
| 2002 class EvaluateUnitConstantsTask extends SourceBasedAnalysisTask { | 2142 class EvaluateUnitConstantsTask extends SourceBasedAnalysisTask { |
| 2003 /** | 2143 /** |
| 2004 * The name of the [RESOLVED_UNIT8] input. | 2144 * The name of the [RESOLVED_UNIT9] input. |
| 2005 */ | 2145 */ |
| 2006 static const String UNIT_INPUT = 'UNIT_INPUT'; | 2146 static const String UNIT_INPUT = 'UNIT_INPUT'; |
| 2007 | 2147 |
| 2008 /** | 2148 /** |
| 2009 * The name of the [CONSTANT_VALUE] input. | 2149 * The name of the [CONSTANT_VALUE] input. |
| 2010 */ | 2150 */ |
| 2011 static const String CONSTANT_VALUES = 'CONSTANT_VALUES'; | 2151 static const String CONSTANT_VALUES = 'CONSTANT_VALUES'; |
| 2012 | 2152 |
| 2013 /** | 2153 /** |
| 2014 * The task descriptor describing this kind of task. | 2154 * The task descriptor describing this kind of task. |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 2035 | 2175 |
| 2036 /** | 2176 /** |
| 2037 * Return a map from the names of the inputs of this kind of task to the task | 2177 * Return a map from the names of the inputs of this kind of task to the task |
| 2038 * input descriptors describing those inputs for a task with the | 2178 * input descriptors describing those inputs for a task with the |
| 2039 * given [target]. | 2179 * given [target]. |
| 2040 */ | 2180 */ |
| 2041 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 2181 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 2042 LibrarySpecificUnit unit = target; | 2182 LibrarySpecificUnit unit = target; |
| 2043 return <String, TaskInput>{ | 2183 return <String, TaskInput>{ |
| 2044 'libraryElement': LIBRARY_ELEMENT.of(unit.library), | 2184 'libraryElement': LIBRARY_ELEMENT.of(unit.library), |
| 2045 UNIT_INPUT: RESOLVED_UNIT8.of(unit), | 2185 UNIT_INPUT: RESOLVED_UNIT9.of(unit), |
| 2046 CONSTANT_VALUES: | 2186 CONSTANT_VALUES: |
| 2047 COMPILATION_UNIT_CONSTANTS.of(unit).toListOf(CONSTANT_VALUE) | 2187 COMPILATION_UNIT_CONSTANTS.of(unit).toListOf(CONSTANT_VALUE) |
| 2048 }; | 2188 }; |
| 2049 } | 2189 } |
| 2050 | 2190 |
| 2051 /** | 2191 /** |
| 2052 * Create an [EvaluateUnitConstantsTask] based on the given [target] in | 2192 * Create an [EvaluateUnitConstantsTask] based on the given [target] in |
| 2053 * the given [context]. | 2193 * the given [context]. |
| 2054 */ | 2194 */ |
| 2055 static EvaluateUnitConstantsTask createTask( | 2195 static EvaluateUnitConstantsTask createTask( |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2159 } | 2299 } |
| 2160 return newNames; | 2300 return newNames; |
| 2161 } | 2301 } |
| 2162 } | 2302 } |
| 2163 | 2303 |
| 2164 /** | 2304 /** |
| 2165 * A task that builds [USED_IMPORTED_ELEMENTS] for a unit. | 2305 * A task that builds [USED_IMPORTED_ELEMENTS] for a unit. |
| 2166 */ | 2306 */ |
| 2167 class GatherUsedImportedElementsTask extends SourceBasedAnalysisTask { | 2307 class GatherUsedImportedElementsTask extends SourceBasedAnalysisTask { |
| 2168 /** | 2308 /** |
| 2169 * The name of the [RESOLVED_UNIT8] input. | 2309 * The name of the [RESOLVED_UNIT9] input. |
| 2170 */ | 2310 */ |
| 2171 static const String UNIT_INPUT = 'UNIT_INPUT'; | 2311 static const String UNIT_INPUT = 'UNIT_INPUT'; |
| 2172 | 2312 |
| 2173 /** | 2313 /** |
| 2174 * The task descriptor describing this kind of task. | 2314 * The task descriptor describing this kind of task. |
| 2175 */ | 2315 */ |
| 2176 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 2316 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 2177 'GatherUsedImportedElementsTask', | 2317 'GatherUsedImportedElementsTask', |
| 2178 createTask, | 2318 createTask, |
| 2179 buildInputs, | 2319 buildInputs, |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 2203 outputs[USED_IMPORTED_ELEMENTS] = visitor.usedElements; | 2343 outputs[USED_IMPORTED_ELEMENTS] = visitor.usedElements; |
| 2204 } | 2344 } |
| 2205 | 2345 |
| 2206 /** | 2346 /** |
| 2207 * Return a map from the names of the inputs of this kind of task to the task | 2347 * Return a map from the names of the inputs of this kind of task to the task |
| 2208 * input descriptors describing those inputs for a task with the | 2348 * input descriptors describing those inputs for a task with the |
| 2209 * given [target]. | 2349 * given [target]. |
| 2210 */ | 2350 */ |
| 2211 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 2351 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 2212 LibrarySpecificUnit unit = target; | 2352 LibrarySpecificUnit unit = target; |
| 2213 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT8.of(unit)}; | 2353 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT9.of(unit)}; |
| 2214 } | 2354 } |
| 2215 | 2355 |
| 2216 /** | 2356 /** |
| 2217 * Create a [GatherUsedImportedElementsTask] based on the given [target] in | 2357 * Create a [GatherUsedImportedElementsTask] based on the given [target] in |
| 2218 * the given [context]. | 2358 * the given [context]. |
| 2219 */ | 2359 */ |
| 2220 static GatherUsedImportedElementsTask createTask( | 2360 static GatherUsedImportedElementsTask createTask( |
| 2221 AnalysisContext context, AnalysisTarget target) { | 2361 AnalysisContext context, AnalysisTarget target) { |
| 2222 return new GatherUsedImportedElementsTask(context, target); | 2362 return new GatherUsedImportedElementsTask(context, target); |
| 2223 } | 2363 } |
| 2224 } | 2364 } |
| 2225 | 2365 |
| 2226 /** | 2366 /** |
| 2227 * A task that builds [USED_LOCAL_ELEMENTS] for a unit. | 2367 * A task that builds [USED_LOCAL_ELEMENTS] for a unit. |
| 2228 */ | 2368 */ |
| 2229 class GatherUsedLocalElementsTask extends SourceBasedAnalysisTask { | 2369 class GatherUsedLocalElementsTask extends SourceBasedAnalysisTask { |
| 2230 /** | 2370 /** |
| 2231 * The name of the [RESOLVED_UNIT8] input. | 2371 * The name of the [RESOLVED_UNIT9] input. |
| 2232 */ | 2372 */ |
| 2233 static const String UNIT_INPUT = 'UNIT_INPUT'; | 2373 static const String UNIT_INPUT = 'UNIT_INPUT'; |
| 2234 | 2374 |
| 2235 /** | 2375 /** |
| 2236 * The task descriptor describing this kind of task. | 2376 * The task descriptor describing this kind of task. |
| 2237 */ | 2377 */ |
| 2238 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 2378 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 2239 'GatherUsedLocalElementsTask', | 2379 'GatherUsedLocalElementsTask', |
| 2240 createTask, | 2380 createTask, |
| 2241 buildInputs, | 2381 buildInputs, |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 2265 outputs[USED_LOCAL_ELEMENTS] = visitor.usedElements; | 2405 outputs[USED_LOCAL_ELEMENTS] = visitor.usedElements; |
| 2266 } | 2406 } |
| 2267 | 2407 |
| 2268 /** | 2408 /** |
| 2269 * Return a map from the names of the inputs of this kind of task to the task | 2409 * Return a map from the names of the inputs of this kind of task to the task |
| 2270 * input descriptors describing those inputs for a task with the | 2410 * input descriptors describing those inputs for a task with the |
| 2271 * given [target]. | 2411 * given [target]. |
| 2272 */ | 2412 */ |
| 2273 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 2413 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 2274 LibrarySpecificUnit unit = target; | 2414 LibrarySpecificUnit unit = target; |
| 2275 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT8.of(unit)}; | 2415 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT9.of(unit)}; |
| 2276 } | 2416 } |
| 2277 | 2417 |
| 2278 /** | 2418 /** |
| 2279 * Create a [GatherUsedLocalElementsTask] based on the given [target] in | 2419 * Create a [GatherUsedLocalElementsTask] based on the given [target] in |
| 2280 * the given [context]. | 2420 * the given [context]. |
| 2281 */ | 2421 */ |
| 2282 static GatherUsedLocalElementsTask createTask( | 2422 static GatherUsedLocalElementsTask createTask( |
| 2283 AnalysisContext context, AnalysisTarget target) { | 2423 AnalysisContext context, AnalysisTarget target) { |
| 2284 return new GatherUsedLocalElementsTask(context, target); | 2424 return new GatherUsedLocalElementsTask(context, target); |
| 2285 } | 2425 } |
| 2286 } | 2426 } |
| 2287 | 2427 |
| 2288 /** | 2428 /** |
| 2289 * A task that generates [HINTS] for a unit. | 2429 * A task that generates [HINTS] for a unit. |
| 2290 */ | 2430 */ |
| 2291 class GenerateHintsTask extends SourceBasedAnalysisTask { | 2431 class GenerateHintsTask extends SourceBasedAnalysisTask { |
| 2292 /** | 2432 /** |
| 2293 * The name of the [RESOLVED_UNIT8] input. | 2433 * The name of the [RESOLVED_UNIT9] input. |
| 2294 */ | 2434 */ |
| 2295 static const String RESOLVED_UNIT_INPUT = 'RESOLVED_UNIT'; | 2435 static const String RESOLVED_UNIT_INPUT = 'RESOLVED_UNIT'; |
| 2296 | 2436 |
| 2297 /** | 2437 /** |
| 2298 * The name of a list of [USED_LOCAL_ELEMENTS] for each library unit input. | 2438 * The name of a list of [USED_LOCAL_ELEMENTS] for each library unit input. |
| 2299 */ | 2439 */ |
| 2300 static const String USED_LOCAL_ELEMENTS_INPUT = 'USED_LOCAL_ELEMENTS'; | 2440 static const String USED_LOCAL_ELEMENTS_INPUT = 'USED_LOCAL_ELEMENTS'; |
| 2301 | 2441 |
| 2302 /** | 2442 /** |
| 2303 * The name of a list of [USED_IMPORTED_ELEMENTS] for each library unit input. | 2443 * The name of a list of [USED_IMPORTED_ELEMENTS] for each library unit input. |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2434 */ | 2574 */ |
| 2435 static const String UNIT_INPUT = 'UNIT_INPUT'; | 2575 static const String UNIT_INPUT = 'UNIT_INPUT'; |
| 2436 | 2576 |
| 2437 /** | 2577 /** |
| 2438 * The task descriptor describing this kind of task. | 2578 * The task descriptor describing this kind of task. |
| 2439 */ | 2579 */ |
| 2440 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 2580 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 2441 'InferInstanceMembersInUnitTask', | 2581 'InferInstanceMembersInUnitTask', |
| 2442 createTask, | 2582 createTask, |
| 2443 buildInputs, | 2583 buildInputs, |
| 2444 <ResultDescriptor>[RESOLVED_UNIT7]); | 2584 <ResultDescriptor>[RESOLVED_UNIT8]); |
| 2445 | 2585 |
| 2446 /** | 2586 /** |
| 2447 * Initialize a newly created task to build a library element for the given | 2587 * Initialize a newly created task to build a library element for the given |
| 2448 * [unit] in the given [context]. | 2588 * [unit] in the given [context]. |
| 2449 */ | 2589 */ |
| 2450 InferInstanceMembersInUnitTask( | 2590 InferInstanceMembersInUnitTask( |
| 2451 InternalAnalysisContext context, LibrarySpecificUnit unit) | 2591 InternalAnalysisContext context, LibrarySpecificUnit unit) |
| 2452 : super(context, unit); | 2592 : super(context, unit); |
| 2453 | 2593 |
| 2454 @override | 2594 @override |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 2465 // Infer instance members. | 2605 // Infer instance members. |
| 2466 // | 2606 // |
| 2467 if (context.analysisOptions.strongMode) { | 2607 if (context.analysisOptions.strongMode) { |
| 2468 InstanceMemberInferrer inferrer = new InstanceMemberInferrer(typeProvider, | 2608 InstanceMemberInferrer inferrer = new InstanceMemberInferrer(typeProvider, |
| 2469 typeSystem: context.typeSystem); | 2609 typeSystem: context.typeSystem); |
| 2470 inferrer.inferCompilationUnit(unit.element); | 2610 inferrer.inferCompilationUnit(unit.element); |
| 2471 } | 2611 } |
| 2472 // | 2612 // |
| 2473 // Record outputs. | 2613 // Record outputs. |
| 2474 // | 2614 // |
| 2475 outputs[RESOLVED_UNIT7] = unit; | 2615 outputs[RESOLVED_UNIT8] = unit; |
| 2476 } | 2616 } |
| 2477 | 2617 |
| 2478 /** | 2618 /** |
| 2479 * Return a map from the names of the inputs of this kind of task to the task | 2619 * Return a map from the names of the inputs of this kind of task to the task |
| 2480 * input descriptors describing those inputs for a task with the given | 2620 * input descriptors describing those inputs for a task with the given |
| 2481 * [libSource]. | 2621 * [libSource]. |
| 2482 */ | 2622 */ |
| 2483 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 2623 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 2484 LibrarySpecificUnit unit = target; | 2624 LibrarySpecificUnit unit = target; |
| 2485 return <String, TaskInput>{ | 2625 return <String, TaskInput>{ |
| 2486 UNIT_INPUT: RESOLVED_UNIT6.of(unit), | 2626 UNIT_INPUT: RESOLVED_UNIT7.of(unit), |
| 2487 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) | 2627 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), |
| 2628 // In strong mode, add additional dependencies to enforce inference | |
| 2629 // ordering. | |
| 2630 | |
| 2631 // Require that field re-resolution be complete for all units in the | |
| 2632 // current library cycle. | |
| 2633 'orderLibraryCycleTasks': LIBRARY_CYCLE_UNITS.of(unit).toList( | |
| 2634 (CompilationUnitElementImpl unit) => RESOLVED_UNIT7 | |
| 2635 .of(new LibrarySpecificUnit(unit.librarySource, unit.source))), | |
| 2636 // Require that full inference be complete for all dependencies of the | |
| 2637 // current library cycle. | |
| 2638 'orderLibraryCycles': LIBRARY_CYCLE_DEPENDENCIES.of(unit).toList( | |
| 2639 (CompilationUnitElementImpl unit) => RESOLVED_UNIT8 | |
| 2640 .of(new LibrarySpecificUnit(unit.librarySource, unit.source))) | |
| 2488 }; | 2641 }; |
| 2489 } | 2642 } |
| 2490 | 2643 |
| 2491 /** | 2644 /** |
| 2492 * Create a [InferInstanceMembersInUnitTask] based on the given [target] in | 2645 * Create a [InferInstanceMembersInUnitTask] based on the given [target] in |
| 2493 * the given [context]. | 2646 * the given [context]. |
| 2494 */ | 2647 */ |
| 2495 static InferInstanceMembersInUnitTask createTask( | 2648 static InferInstanceMembersInUnitTask createTask( |
| 2496 AnalysisContext context, AnalysisTarget target) { | 2649 AnalysisContext context, AnalysisTarget target) { |
| 2497 return new InferInstanceMembersInUnitTask(context, target); | 2650 return new InferInstanceMembersInUnitTask(context, target); |
| 2498 } | 2651 } |
| 2499 } | 2652 } |
| 2500 | 2653 |
| 2501 /** | 2654 /** |
| 2655 * A task that ensures that all of the inferrable instance members in a | |
| 2656 * compilation unit have had their right hand sides re-resolved | |
| 2657 */ | |
| 2658 class ResolveInstanceFieldsInUnitTask extends SourceBasedAnalysisTask { | |
| 2659 /** | |
| 2660 * The name of the [TYPE_PROVIDER] input. | |
| 2661 */ | |
| 2662 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; | |
| 2663 | |
| 2664 /** | |
| 2665 * The name of the input whose value is the [RESOLVED_UNIT6] for the | |
| 2666 * compilation unit. | |
| 2667 */ | |
| 2668 static const String UNIT_INPUT = 'UNIT_INPUT'; | |
| 2669 | |
| 2670 /** | |
| 2671 * The task descriptor describing this kind of task. | |
| 2672 */ | |
| 2673 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | |
| 2674 'ResolveInstanceFieldsInUnitTask', | |
| 2675 createTask, | |
| 2676 buildInputs, | |
| 2677 <ResultDescriptor>[RESOLVED_UNIT7]); | |
| 2678 | |
| 2679 /** | |
| 2680 * Initialize a newly created task to build a library element for the given | |
| 2681 * [unit] in the given [context]. | |
| 2682 */ | |
| 2683 ResolveInstanceFieldsInUnitTask( | |
| 2684 InternalAnalysisContext context, LibrarySpecificUnit unit) | |
| 2685 : super(context, unit); | |
| 2686 | |
| 2687 @override | |
| 2688 TaskDescriptor get descriptor => DESCRIPTOR; | |
| 2689 | |
| 2690 @override | |
| 2691 void internalPerform() { | |
| 2692 // | |
| 2693 // Prepare inputs. | |
| 2694 // | |
| 2695 CompilationUnit unit = getRequiredInput(UNIT_INPUT); | |
| 2696 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); | |
| 2697 if (context.analysisOptions.strongMode) { | |
| 2698 // | |
| 2699 // Resolve instance fields. | |
| 2700 // | |
| 2701 CompilationUnitElement unitElement = unit.element; | |
| 2702 RecordingErrorListener errorListener = new RecordingErrorListener(); | |
|
Brian Wilkerson
2015/10/06 19:04:46
nit: In places where we are going to discard the e
Leaf
2015/10/07 18:53:55
Done.
| |
| 2703 for (CompilationUnitMember unitMember in unit.declarations) { | |
| 2704 if (unitMember is ClassDeclaration) { | |
| 2705 for (ClassMember member in unitMember.members) { | |
| 2706 if (member is FieldDeclaration && | |
| 2707 !(member.fields.isConst || member.isStatic)) { | |
| 2708 member.fields.variables.forEach((v) => _resolveVariable( | |
| 2709 v, unitElement, typeProvider, errorListener)); | |
| 2710 } | |
| 2711 } | |
| 2712 } | |
| 2713 } | |
| 2714 } | |
| 2715 // | |
| 2716 // Record outputs. | |
| 2717 // | |
| 2718 outputs[RESOLVED_UNIT7] = unit; | |
| 2719 } | |
| 2720 | |
| 2721 void _resolveVariable( | |
| 2722 VariableDeclaration variable, | |
| 2723 CompilationUnitElement unitElement, | |
| 2724 TypeProvider typeProvider, | |
| 2725 RecordingErrorListener errorListener) { | |
| 2726 ResolutionContext resolutionContext = | |
| 2727 ResolutionContextBuilder.contextFor(variable, errorListener); | |
| 2728 ResolverVisitor visitor = new ResolverVisitor( | |
| 2729 unitElement.library, unitElement.source, typeProvider, errorListener, | |
| 2730 nameScope: resolutionContext.scope); | |
| 2731 if (resolutionContext.enclosingClassDeclaration != null) { | |
| 2732 visitor.prepareToResolveMembersInClass( | |
| 2733 resolutionContext.enclosingClassDeclaration); | |
| 2734 } | |
| 2735 visitor.initForIncrementalResolution(variable); | |
| 2736 variable.accept(visitor); | |
| 2737 } | |
| 2738 | |
| 2739 /** | |
| 2740 * Return a map from the names of the inputs of this kind of task to the task | |
| 2741 * input descriptors describing those inputs for a task with the given | |
| 2742 * [libSource]. | |
| 2743 */ | |
| 2744 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | |
| 2745 LibrarySpecificUnit unit = target; | |
| 2746 return <String, TaskInput>{ | |
| 2747 UNIT_INPUT: RESOLVED_UNIT6.of(unit), | |
| 2748 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), | |
| 2749 // In strong mode, add additional dependencies to enforce inference | |
| 2750 // ordering. | |
| 2751 | |
| 2752 // Require that static variable inference be complete for all units in | |
| 2753 // the current library cycle. | |
| 2754 'orderLibraryCycleTasks': LIBRARY_CYCLE_UNITS.of(unit).toList( | |
| 2755 (CompilationUnitElementImpl unit) => RESOLVED_UNIT6 | |
| 2756 .of(new LibrarySpecificUnit(unit.librarySource, unit.source))), | |
| 2757 // Require that full inference be complete for all dependencies of the | |
| 2758 // current library cycle. | |
| 2759 'orderLibraryCycles': LIBRARY_CYCLE_DEPENDENCIES.of(unit).toList( | |
| 2760 (CompilationUnitElementImpl unit) => RESOLVED_UNIT8 | |
| 2761 .of(new LibrarySpecificUnit(unit.librarySource, unit.source))) | |
| 2762 }; | |
| 2763 } | |
| 2764 | |
| 2765 /** | |
| 2766 * Create a [ResolveInstanceFieldsInUnitTask] based on the given [target] in | |
| 2767 * the given [context]. | |
| 2768 */ | |
| 2769 static ResolveInstanceFieldsInUnitTask createTask( | |
| 2770 AnalysisContext context, AnalysisTarget target) { | |
| 2771 return new ResolveInstanceFieldsInUnitTask(context, target); | |
| 2772 } | |
| 2773 } | |
| 2774 | |
| 2775 /** | |
| 2502 * An abstract class that defines utility methods that are useful for tasks | 2776 * An abstract class that defines utility methods that are useful for tasks |
| 2503 * operating on static variables. | 2777 * operating on static variables. |
| 2504 */ | 2778 */ |
| 2505 abstract class InferStaticVariableTask extends ConstantEvaluationAnalysisTask { | 2779 abstract class InferStaticVariableTask extends ConstantEvaluationAnalysisTask { |
| 2506 InferStaticVariableTask( | 2780 InferStaticVariableTask( |
| 2507 InternalAnalysisContext context, VariableElement variable) | 2781 InternalAnalysisContext context, VariableElement variable) |
| 2508 : super(context, variable); | 2782 : super(context, variable); |
| 2509 | 2783 |
| 2510 /** | 2784 /** |
| 2511 * Return the declaration of the target within the given compilation [unit]. | 2785 * Return the declaration of the target within the given compilation [unit]. |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 2536 */ | 2810 */ |
| 2537 static const String UNIT_INPUT = 'UNIT_INPUT'; | 2811 static const String UNIT_INPUT = 'UNIT_INPUT'; |
| 2538 | 2812 |
| 2539 /** | 2813 /** |
| 2540 * The name of the input whose value is a list of the inferrable static | 2814 * The name of the input whose value is a list of the inferrable static |
| 2541 * variables whose types have been computed. | 2815 * variables whose types have been computed. |
| 2542 */ | 2816 */ |
| 2543 static const String INFERRED_VARIABLES_INPUT = 'INFERRED_VARIABLES_INPUT'; | 2817 static const String INFERRED_VARIABLES_INPUT = 'INFERRED_VARIABLES_INPUT'; |
| 2544 | 2818 |
| 2545 /** | 2819 /** |
| 2546 * The name of the input whose value is a list of the errors produced while | |
| 2547 * inferring types for static variables. | |
| 2548 */ | |
| 2549 static const String INFER_STATIC_VARIABLE_ERRORS_INPUT = | |
| 2550 'INFER_STATIC_VARIABLE_ERRORS'; | |
| 2551 | |
| 2552 /** | |
| 2553 * The task descriptor describing this kind of task. | 2820 * The task descriptor describing this kind of task. |
| 2554 */ | 2821 */ |
| 2555 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 2822 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 2556 'InferStaticVariableTypesInUnitTask', | 2823 'InferStaticVariableTypesInUnitTask', |
| 2557 createTask, | 2824 createTask, |
| 2558 buildInputs, | 2825 buildInputs, |
| 2559 <ResultDescriptor>[INFER_STATIC_VARIABLE_TYPES_ERRORS, RESOLVED_UNIT6]); | 2826 <ResultDescriptor>[RESOLVED_UNIT6]); |
| 2560 | 2827 |
| 2561 /** | 2828 /** |
| 2562 * Initialize a newly created task to build a library element for the given | 2829 * Initialize a newly created task to build a library element for the given |
| 2563 * [unit] in the given [context]. | 2830 * [unit] in the given [context]. |
| 2564 */ | 2831 */ |
| 2565 InferStaticVariableTypesInUnitTask( | 2832 InferStaticVariableTypesInUnitTask( |
| 2566 InternalAnalysisContext context, LibrarySpecificUnit unit) | 2833 InternalAnalysisContext context, LibrarySpecificUnit unit) |
| 2567 : super(context, unit); | 2834 : super(context, unit); |
| 2568 | 2835 |
| 2569 @override | 2836 @override |
| 2570 TaskDescriptor get descriptor => DESCRIPTOR; | 2837 TaskDescriptor get descriptor => DESCRIPTOR; |
| 2571 | 2838 |
| 2572 @override | 2839 @override |
| 2573 void internalPerform() { | 2840 void internalPerform() { |
| 2574 // | 2841 // |
| 2575 // Prepare inputs. | 2842 // Prepare inputs. |
| 2576 // | 2843 // |
| 2577 CompilationUnit unit = getRequiredInput(UNIT_INPUT); | 2844 CompilationUnit unit = getRequiredInput(UNIT_INPUT); |
| 2578 List<List<AnalysisError>> perVariableErrors = | |
| 2579 getRequiredInput(INFER_STATIC_VARIABLE_ERRORS_INPUT); | |
| 2580 List<AnalysisError> errors = <AnalysisError>[]; | |
| 2581 for (List<AnalysisError> variableErrors in perVariableErrors) { | |
| 2582 errors.addAll(variableErrors); | |
| 2583 } | |
| 2584 // | 2845 // |
| 2585 // Record outputs. There is no additional work to be done at this time | 2846 // Record outputs. There is no additional work to be done at this time |
| 2586 // because the work has implicitly been done by virtue of the task model | 2847 // because the work has implicitly been done by virtue of the task model |
| 2587 // preparing all of the inputs. | 2848 // preparing all of the inputs. |
| 2588 // | 2849 // |
| 2589 outputs[INFER_STATIC_VARIABLE_TYPES_ERRORS] = errors; | |
| 2590 outputs[RESOLVED_UNIT6] = unit; | 2850 outputs[RESOLVED_UNIT6] = unit; |
| 2591 } | 2851 } |
| 2592 | 2852 |
| 2593 /** | 2853 /** |
| 2594 * Return a map from the names of the inputs of this kind of task to the task | 2854 * Return a map from the names of the inputs of this kind of task to the task |
| 2595 * input descriptors describing those inputs for a task with the given | 2855 * input descriptors describing those inputs for a task with the given |
| 2596 * [libSource]. | 2856 * [libSource]. |
| 2597 */ | 2857 */ |
| 2598 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 2858 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 2599 LibrarySpecificUnit unit = target; | 2859 LibrarySpecificUnit unit = target; |
| 2600 return <String, TaskInput>{ | 2860 return <String, TaskInput>{ |
| 2601 INFERRED_VARIABLES_INPUT: INFERABLE_STATIC_VARIABLES_IN_UNIT | 2861 INFERRED_VARIABLES_INPUT: INFERABLE_STATIC_VARIABLES_IN_UNIT |
| 2602 .of(unit) | 2862 .of(unit) |
| 2603 .toListOf(INFERRED_STATIC_VARIABLE), | 2863 .toListOf(INFERRED_STATIC_VARIABLE), |
| 2604 INFER_STATIC_VARIABLE_ERRORS_INPUT: INFERABLE_STATIC_VARIABLES_IN_UNIT | |
| 2605 .of(unit) | |
| 2606 .toListOf(INFER_STATIC_VARIABLE_ERRORS), | |
| 2607 UNIT_INPUT: RESOLVED_UNIT5.of(unit) | 2864 UNIT_INPUT: RESOLVED_UNIT5.of(unit) |
| 2608 }; | 2865 }; |
| 2609 } | 2866 } |
| 2610 | 2867 |
| 2611 /** | 2868 /** |
| 2612 * Create a [InferStaticVariableTypesInUnitTask] based on the given [target] | 2869 * Create a [InferStaticVariableTypesInUnitTask] based on the given [target] |
| 2613 * in the given [context]. | 2870 * in the given [context]. |
| 2614 */ | 2871 */ |
| 2615 static InferStaticVariableTypesInUnitTask createTask( | 2872 static InferStaticVariableTypesInUnitTask createTask( |
| 2616 AnalysisContext context, AnalysisTarget target) { | 2873 AnalysisContext context, AnalysisTarget target) { |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 2635 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; | 2892 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; |
| 2636 | 2893 |
| 2637 /** | 2894 /** |
| 2638 * The name of the [RESOLVED_UNIT5] input. | 2895 * The name of the [RESOLVED_UNIT5] input. |
| 2639 */ | 2896 */ |
| 2640 static const String UNIT_INPUT = 'UNIT_INPUT'; | 2897 static const String UNIT_INPUT = 'UNIT_INPUT'; |
| 2641 | 2898 |
| 2642 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 2899 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 2643 'InferStaticVariableTypeTask', | 2900 'InferStaticVariableTypeTask', |
| 2644 createTask, | 2901 createTask, |
| 2645 buildInputs, <ResultDescriptor>[ | 2902 buildInputs, |
| 2646 INFER_STATIC_VARIABLE_ERRORS, | 2903 <ResultDescriptor>[INFERRED_STATIC_VARIABLE]); |
| 2647 INFERRED_STATIC_VARIABLE | |
| 2648 ]); | |
| 2649 | 2904 |
| 2650 InferStaticVariableTypeTask( | 2905 InferStaticVariableTypeTask( |
| 2651 InternalAnalysisContext context, VariableElement variable) | 2906 InternalAnalysisContext context, VariableElement variable) |
| 2652 : super(context, variable); | 2907 : super(context, variable); |
| 2653 | 2908 |
| 2654 @override | 2909 @override |
| 2655 TaskDescriptor get descriptor => DESCRIPTOR; | 2910 TaskDescriptor get descriptor => DESCRIPTOR; |
| 2656 | 2911 |
| 2657 @override | 2912 @override |
| 2658 bool get handlesDependencyCycles => true; | 2913 bool get handlesDependencyCycles => true; |
| 2659 | 2914 |
| 2660 @override | 2915 @override |
| 2661 void internalPerform() { | 2916 void internalPerform() { |
| 2662 // | 2917 // |
| 2663 // Prepare inputs. | 2918 // Prepare inputs. |
| 2664 // | 2919 // |
| 2665 // Note: DEPENDENCIES_INPUT is not needed. It is merely a bookkeeping | 2920 // Note: DEPENDENCIES_INPUT is not needed. It is merely a bookkeeping |
| 2666 // dependency to ensure that the variables that this variable references | 2921 // dependency to ensure that the variables that this variable references |
| 2667 // have types inferred before inferring the type of this variable. | 2922 // have types inferred before inferring the type of this variable. |
| 2668 // | 2923 // |
| 2669 VariableElementImpl variable = target; | 2924 VariableElementImpl variable = target; |
| 2670 | 2925 |
| 2671 CompilationUnit unit = getRequiredInput(UNIT_INPUT); | 2926 CompilationUnit unit = getRequiredInput(UNIT_INPUT); |
| 2672 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); | 2927 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); |
| 2673 RecordingErrorListener errorListener = new RecordingErrorListener(); | 2928 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 2674 VariableDeclaration declaration = getDeclaration(unit); | |
| 2675 // | |
| 2676 // Re-resolve the variable's initializer so that the inferred types of other | |
| 2677 // variables will be propagated. | |
| 2678 // | |
| 2679 Expression initializer = declaration.initializer; | |
| 2680 ResolutionEraser.erase(initializer, eraseDeclarations: false); | |
| 2681 ResolutionContext resolutionContext = | |
| 2682 ResolutionContextBuilder.contextFor(initializer, errorListener); | |
| 2683 ResolverVisitor visitor = new ResolverVisitor( | |
| 2684 variable.library, variable.source, typeProvider, errorListener, | |
| 2685 nameScope: resolutionContext.scope); | |
| 2686 if (resolutionContext.enclosingClassDeclaration != null) { | |
| 2687 visitor.prepareToResolveMembersInClass( | |
| 2688 resolutionContext.enclosingClassDeclaration); | |
| 2689 } | |
| 2690 visitor.initForIncrementalResolution(); | |
| 2691 initializer.accept(visitor); | |
| 2692 | 2929 |
| 2693 // If we're not in a dependency cycle, and we have no type annotation, | 2930 // If we're not in a dependency cycle, and we have no type annotation, |
| 2694 // do inference. | 2931 // re-resolve the right hand side and do inference. |
| 2695 if (dependencyCycle == null && variable.hasImplicitType) { | 2932 if (dependencyCycle == null && variable.hasImplicitType) { |
| 2933 VariableDeclaration declaration = getDeclaration(unit); | |
| 2934 // | |
| 2935 // Re-resolve the variable's initializer so that the inferred types | |
| 2936 // of other variables will be propagated. | |
| 2937 // | |
| 2938 Expression initializer = declaration.initializer; | |
| 2939 ResolutionContext resolutionContext = | |
| 2940 ResolutionContextBuilder.contextFor(initializer, errorListener); | |
| 2941 ResolverVisitor visitor = new ResolverVisitor( | |
| 2942 variable.library, variable.source, typeProvider, errorListener, | |
| 2943 nameScope: resolutionContext.scope); | |
| 2944 if (resolutionContext.enclosingClassDeclaration != null) { | |
| 2945 visitor.prepareToResolveMembersInClass( | |
| 2946 resolutionContext.enclosingClassDeclaration); | |
| 2947 } | |
| 2948 visitor.initForIncrementalResolution(); | |
| 2949 initializer.accept(visitor); | |
| 2950 | |
| 2696 // | 2951 // |
| 2697 // Record the type of the variable. | 2952 // Record the type of the variable. |
| 2698 // | 2953 // |
| 2699 DartType newType = initializer.staticType; | 2954 DartType newType = initializer.staticType; |
| 2700 if (newType == null || newType.isBottom) { | 2955 if (newType == null || newType.isBottom) { |
| 2701 newType = typeProvider.dynamicType; | 2956 newType = typeProvider.dynamicType; |
| 2702 } | 2957 } |
| 2703 variable.type = newType; | 2958 variable.type = newType; |
| 2704 (variable.initializer as ExecutableElementImpl).returnType = newType; | 2959 (variable.initializer as ExecutableElementImpl).returnType = newType; |
| 2705 if (variable is PropertyInducingElementImpl) { | 2960 if (variable is PropertyInducingElementImpl) { |
| 2706 setReturnType(variable.getter, newType); | 2961 setReturnType(variable.getter, newType); |
| 2707 if (!variable.isFinal && !variable.isConst) { | 2962 if (!variable.isFinal && !variable.isConst) { |
| 2708 setParameterType(variable.setter, newType); | 2963 setParameterType(variable.setter, newType); |
| 2709 } | 2964 } |
| 2710 } | 2965 } |
| 2711 } else { | 2966 } else { |
| 2712 // TODO(brianwilkerson) For now we simply don't infer any type for | 2967 // TODO(brianwilkerson) For now we simply don't infer any type for |
| 2713 // variables or fields involved in a cycle. We could try to be smarter | 2968 // variables or fields involved in a cycle. We could try to be smarter |
| 2714 // by re-resolving the initializer in a context in which the types of all | 2969 // by re-resolving the initializer in a context in which the types of all |
| 2715 // of the variables in the cycle are assumed to be `null`, but it isn't | 2970 // of the variables in the cycle are assumed to be `null`, but it isn't |
| 2716 // clear to me that this would produce better results often enough to | 2971 // clear to me that this would produce better results often enough to |
| 2717 // warrant the extra effort. | 2972 // warrant the extra effort. |
| 2718 } | 2973 } |
| 2719 // | 2974 // |
| 2720 // Record outputs. | 2975 // Record outputs. |
| 2721 // | 2976 // |
| 2722 outputs[INFERRED_STATIC_VARIABLE] = variable; | 2977 outputs[INFERRED_STATIC_VARIABLE] = variable; |
| 2723 outputs[INFER_STATIC_VARIABLE_ERRORS] = errorListener.errors; | |
| 2724 } | 2978 } |
| 2725 | 2979 |
| 2726 /** | 2980 /** |
| 2727 * Return a map from the names of the inputs of this kind of task to the task | 2981 * Return a map from the names of the inputs of this kind of task to the task |
| 2728 * input descriptors describing those inputs for a task with the given | 2982 * input descriptors describing those inputs for a task with the given |
| 2729 * [target]. | 2983 * [target]. |
| 2730 */ | 2984 */ |
| 2731 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 2985 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 2732 VariableElement variable = target; | 2986 VariableElement variable = target; |
| 2733 LibrarySpecificUnit unit = | 2987 LibrarySpecificUnit unit = |
| 2734 new LibrarySpecificUnit(variable.library.source, variable.source); | 2988 new LibrarySpecificUnit(variable.library.source, variable.source); |
| 2735 return <String, TaskInput>{ | 2989 return <String, TaskInput>{ |
| 2736 DEPENDENCIES_INPUT: INFERABLE_STATIC_VARIABLE_DEPENDENCIES | 2990 DEPENDENCIES_INPUT: INFERABLE_STATIC_VARIABLE_DEPENDENCIES |
| 2737 .of(variable) | 2991 .of(variable) |
| 2738 .toListOf(INFERRED_STATIC_VARIABLE), | 2992 .toListOf(INFERRED_STATIC_VARIABLE), |
| 2739 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), | 2993 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), |
| 2740 UNIT_INPUT: RESOLVED_UNIT5.of(unit) | 2994 UNIT_INPUT: RESOLVED_UNIT5.of(unit), |
| 2995 // In strong mode, add additional dependencies to enforce inference | |
| 2996 // ordering. | |
| 2997 | |
| 2998 // Require that full inference be complete for all dependencies of the | |
| 2999 // current library cycle. | |
| 3000 'orderLibraryCycles': LIBRARY_CYCLE_DEPENDENCIES.of(unit).toList( | |
| 3001 (CompilationUnitElementImpl unit) => RESOLVED_UNIT8 | |
| 3002 .of(new LibrarySpecificUnit(unit.librarySource, unit.source))) | |
| 2741 }; | 3003 }; |
| 2742 } | 3004 } |
| 2743 | 3005 |
| 2744 /** | 3006 /** |
| 2745 * Create a [InferStaticVariableTypeTask] based on the given [target] in the | 3007 * Create a [InferStaticVariableTypeTask] based on the given [target] in the |
| 2746 * given [context]. | 3008 * given [context]. |
| 2747 */ | 3009 */ |
| 2748 static InferStaticVariableTypeTask createTask( | 3010 static InferStaticVariableTypeTask createTask( |
| 2749 AnalysisContext context, AnalysisTarget target) { | 3011 AnalysisContext context, AnalysisTarget target) { |
| 2750 return new InferStaticVariableTypeTask(context, target); | 3012 return new InferStaticVariableTypeTask(context, target); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2812 * The name of the [BUILD_LIBRARY_ERRORS] input. | 3074 * The name of the [BUILD_LIBRARY_ERRORS] input. |
| 2813 */ | 3075 */ |
| 2814 static const String BUILD_LIBRARY_ERRORS_INPUT = 'BUILD_LIBRARY_ERRORS'; | 3076 static const String BUILD_LIBRARY_ERRORS_INPUT = 'BUILD_LIBRARY_ERRORS'; |
| 2815 | 3077 |
| 2816 /** | 3078 /** |
| 2817 * The name of the [HINTS] input. | 3079 * The name of the [HINTS] input. |
| 2818 */ | 3080 */ |
| 2819 static const String HINTS_INPUT = 'HINTS'; | 3081 static const String HINTS_INPUT = 'HINTS'; |
| 2820 | 3082 |
| 2821 /** | 3083 /** |
| 2822 * The name of the [INFER_STATIC_VARIABLE_TYPES_ERRORS] input. | |
| 2823 */ | |
| 2824 static const String INFER_STATIC_VARIABLE_TYPES_ERRORS_INPUT = | |
| 2825 'INFER_STATIC_VARIABLE_TYPES_ERRORS'; | |
| 2826 | |
| 2827 /** | |
| 2828 * The name of the [PARTIALLY_RESOLVE_REFERENCES_ERRORS] input. | |
| 2829 */ | |
| 2830 static const String PARTIALLY_RESOLVE_REFERENCES_ERRORS_INPUT = | |
| 2831 'PARTIALLY_RESOLVE_REFERENCES_ERRORS'; | |
| 2832 | |
| 2833 /** | |
| 2834 * The name of the [RESOLVE_FUNCTION_BODIES_ERRORS] input. | |
| 2835 */ | |
| 2836 static const String RESOLVE_FUNCTION_BODIES_ERRORS_INPUT = | |
| 2837 'RESOLVE_FUNCTION_BODIES_ERRORS'; | |
| 2838 | |
| 2839 /** | |
| 2840 * The name of the [RESOLVE_TYPE_NAMES_ERRORS] input. | 3084 * The name of the [RESOLVE_TYPE_NAMES_ERRORS] input. |
| 2841 */ | 3085 */ |
| 2842 static const String RESOLVE_TYPE_NAMES_ERRORS_INPUT = | 3086 static const String RESOLVE_TYPE_NAMES_ERRORS_INPUT = |
| 2843 'RESOLVE_TYPE_NAMES_ERRORS'; | 3087 'RESOLVE_TYPE_NAMES_ERRORS'; |
| 2844 | 3088 |
| 2845 /** | 3089 /** |
| 3090 * The name of the [RESOLVE_UNIT_ERRORS] input. | |
| 3091 */ | |
| 3092 static const String RESOLVE_UNIT_ERRORS_INPUT = 'RESOLVE_UNIT_ERRORS'; | |
| 3093 | |
| 3094 /** | |
| 2846 * The name of the [VARIABLE_REFERENCE_ERRORS] input. | 3095 * The name of the [VARIABLE_REFERENCE_ERRORS] input. |
| 2847 */ | 3096 */ |
| 2848 static const String VARIABLE_REFERENCE_ERRORS_INPUT = | 3097 static const String VARIABLE_REFERENCE_ERRORS_INPUT = |
| 2849 'VARIABLE_REFERENCE_ERRORS'; | 3098 'VARIABLE_REFERENCE_ERRORS'; |
| 2850 | 3099 |
| 2851 /** | 3100 /** |
| 2852 * The name of the [VERIFY_ERRORS] input. | 3101 * The name of the [VERIFY_ERRORS] input. |
| 2853 */ | 3102 */ |
| 2854 static const String VERIFY_ERRORS_INPUT = 'VERIFY_ERRORS'; | 3103 static const String VERIFY_ERRORS_INPUT = 'VERIFY_ERRORS'; |
| 2855 | 3104 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 2870 | 3119 |
| 2871 @override | 3120 @override |
| 2872 void internalPerform() { | 3121 void internalPerform() { |
| 2873 // | 3122 // |
| 2874 // Prepare inputs. | 3123 // Prepare inputs. |
| 2875 // | 3124 // |
| 2876 List<List<AnalysisError>> errorLists = <List<AnalysisError>>[]; | 3125 List<List<AnalysisError>> errorLists = <List<AnalysisError>>[]; |
| 2877 errorLists.add(getRequiredInput(BUILD_DIRECTIVES_ERRORS_INPUT)); | 3126 errorLists.add(getRequiredInput(BUILD_DIRECTIVES_ERRORS_INPUT)); |
| 2878 errorLists.add(getRequiredInput(BUILD_LIBRARY_ERRORS_INPUT)); | 3127 errorLists.add(getRequiredInput(BUILD_LIBRARY_ERRORS_INPUT)); |
| 2879 errorLists.add(getRequiredInput(HINTS_INPUT)); | 3128 errorLists.add(getRequiredInput(HINTS_INPUT)); |
| 2880 errorLists.add(getRequiredInput(INFER_STATIC_VARIABLE_TYPES_ERRORS_INPUT)); | |
| 2881 errorLists.add(getRequiredInput(PARTIALLY_RESOLVE_REFERENCES_ERRORS_INPUT)); | |
| 2882 errorLists.add(getRequiredInput(RESOLVE_FUNCTION_BODIES_ERRORS_INPUT)); | |
| 2883 errorLists.add(getRequiredInput(RESOLVE_TYPE_NAMES_ERRORS_INPUT)); | 3129 errorLists.add(getRequiredInput(RESOLVE_TYPE_NAMES_ERRORS_INPUT)); |
| 3130 errorLists.add(getRequiredInput(RESOLVE_UNIT_ERRORS_INPUT)); | |
| 2884 errorLists.add(getRequiredInput(VARIABLE_REFERENCE_ERRORS_INPUT)); | 3131 errorLists.add(getRequiredInput(VARIABLE_REFERENCE_ERRORS_INPUT)); |
| 2885 errorLists.add(getRequiredInput(VERIFY_ERRORS_INPUT)); | 3132 errorLists.add(getRequiredInput(VERIFY_ERRORS_INPUT)); |
| 2886 // | 3133 // |
| 2887 // Record outputs. | 3134 // Record outputs. |
| 2888 // | 3135 // |
| 2889 outputs[LIBRARY_UNIT_ERRORS] = AnalysisError.mergeLists(errorLists); | 3136 outputs[LIBRARY_UNIT_ERRORS] = AnalysisError.mergeLists(errorLists); |
| 2890 } | 3137 } |
| 2891 | 3138 |
| 2892 /** | 3139 /** |
| 2893 * Return a map from the names of the inputs of this kind of task to the task | 3140 * Return a map from the names of the inputs of this kind of task to the task |
| 2894 * input descriptors describing those inputs for a task with the | 3141 * input descriptors describing those inputs for a task with the |
| 2895 * given [unit]. | 3142 * given [unit]. |
| 2896 */ | 3143 */ |
| 2897 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 3144 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 2898 LibrarySpecificUnit unit = target; | 3145 LibrarySpecificUnit unit = target; |
| 2899 Map<String, TaskInput> inputs = <String, TaskInput>{ | 3146 Map<String, TaskInput> inputs = <String, TaskInput>{ |
| 2900 HINTS_INPUT: HINTS.of(unit), | 3147 HINTS_INPUT: HINTS.of(unit), |
| 2901 INFER_STATIC_VARIABLE_TYPES_ERRORS_INPUT: | |
| 2902 INFER_STATIC_VARIABLE_TYPES_ERRORS.of(unit), | |
| 2903 PARTIALLY_RESOLVE_REFERENCES_ERRORS_INPUT: | |
| 2904 PARTIALLY_RESOLVE_REFERENCES_ERRORS.of(unit), | |
| 2905 RESOLVE_FUNCTION_BODIES_ERRORS_INPUT: | |
| 2906 RESOLVE_FUNCTION_BODIES_ERRORS.of(unit), | |
| 2907 RESOLVE_TYPE_NAMES_ERRORS_INPUT: RESOLVE_TYPE_NAMES_ERRORS.of(unit), | 3148 RESOLVE_TYPE_NAMES_ERRORS_INPUT: RESOLVE_TYPE_NAMES_ERRORS.of(unit), |
| 3149 RESOLVE_UNIT_ERRORS_INPUT: RESOLVE_UNIT_ERRORS.of(unit), | |
| 2908 VARIABLE_REFERENCE_ERRORS_INPUT: VARIABLE_REFERENCE_ERRORS.of(unit), | 3150 VARIABLE_REFERENCE_ERRORS_INPUT: VARIABLE_REFERENCE_ERRORS.of(unit), |
| 2909 VERIFY_ERRORS_INPUT: VERIFY_ERRORS.of(unit) | 3151 VERIFY_ERRORS_INPUT: VERIFY_ERRORS.of(unit) |
| 2910 }; | 3152 }; |
| 2911 Source source = unit.source; | 3153 Source source = unit.source; |
| 2912 if (unit.library == source) { | 3154 if (unit.library == source) { |
| 2913 inputs[BUILD_DIRECTIVES_ERRORS_INPUT] = | 3155 inputs[BUILD_DIRECTIVES_ERRORS_INPUT] = |
| 2914 BUILD_DIRECTIVES_ERRORS.of(source); | 3156 BUILD_DIRECTIVES_ERRORS.of(source); |
| 2915 inputs[BUILD_LIBRARY_ERRORS_INPUT] = BUILD_LIBRARY_ERRORS.of(source); | 3157 inputs[BUILD_LIBRARY_ERRORS_INPUT] = BUILD_LIBRARY_ERRORS.of(source); |
| 2916 } else { | 3158 } else { |
| 2917 inputs[BUILD_DIRECTIVES_ERRORS_INPUT] = | 3159 inputs[BUILD_DIRECTIVES_ERRORS_INPUT] = |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3138 * The name of the [TYPE_PROVIDER] input. | 3380 * The name of the [TYPE_PROVIDER] input. |
| 3139 */ | 3381 */ |
| 3140 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; | 3382 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; |
| 3141 | 3383 |
| 3142 /** | 3384 /** |
| 3143 * The task descriptor describing this kind of task. | 3385 * The task descriptor describing this kind of task. |
| 3144 */ | 3386 */ |
| 3145 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 3387 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 3146 'PartiallyResolveUnitReferencesTask', | 3388 'PartiallyResolveUnitReferencesTask', |
| 3147 createTask, | 3389 createTask, |
| 3148 buildInputs, <ResultDescriptor>[ | 3390 buildInputs, |
| 3149 INFERABLE_STATIC_VARIABLES_IN_UNIT, | 3391 <ResultDescriptor>[INFERABLE_STATIC_VARIABLES_IN_UNIT, RESOLVED_UNIT5]); |
| 3150 PARTIALLY_RESOLVE_REFERENCES_ERRORS, | |
| 3151 RESOLVED_UNIT5 | |
| 3152 ]); | |
| 3153 | 3392 |
| 3154 PartiallyResolveUnitReferencesTask( | 3393 PartiallyResolveUnitReferencesTask( |
| 3155 InternalAnalysisContext context, AnalysisTarget target) | 3394 InternalAnalysisContext context, AnalysisTarget target) |
| 3156 : super(context, target); | 3395 : super(context, target); |
| 3157 | 3396 |
| 3158 @override | 3397 @override |
| 3159 TaskDescriptor get descriptor => DESCRIPTOR; | 3398 TaskDescriptor get descriptor => DESCRIPTOR; |
| 3160 | 3399 |
| 3161 @override | 3400 @override |
| 3162 void internalPerform() { | 3401 void internalPerform() { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 3174 InheritanceManager inheritanceManager = | 3413 InheritanceManager inheritanceManager = |
| 3175 new InheritanceManager(libraryElement); | 3414 new InheritanceManager(libraryElement); |
| 3176 PartialResolverVisitor visitor = new PartialResolverVisitor( | 3415 PartialResolverVisitor visitor = new PartialResolverVisitor( |
| 3177 libraryElement, unitElement.source, typeProvider, errorListener, | 3416 libraryElement, unitElement.source, typeProvider, errorListener, |
| 3178 inheritanceManager: inheritanceManager); | 3417 inheritanceManager: inheritanceManager); |
| 3179 unit.accept(visitor); | 3418 unit.accept(visitor); |
| 3180 // | 3419 // |
| 3181 // Record outputs. | 3420 // Record outputs. |
| 3182 // | 3421 // |
| 3183 outputs[INFERABLE_STATIC_VARIABLES_IN_UNIT] = visitor.variablesAndFields; | 3422 outputs[INFERABLE_STATIC_VARIABLES_IN_UNIT] = visitor.variablesAndFields; |
| 3184 outputs[PARTIALLY_RESOLVE_REFERENCES_ERRORS] = | |
| 3185 removeDuplicateErrors(errorListener.errors); | |
| 3186 outputs[RESOLVED_UNIT5] = unit; | 3423 outputs[RESOLVED_UNIT5] = unit; |
| 3187 } | 3424 } |
| 3188 | 3425 |
| 3189 /** | 3426 /** |
| 3190 * Return a map from the names of the inputs of this kind of task to the task | 3427 * Return a map from the names of the inputs of this kind of task to the task |
| 3191 * input descriptors describing those inputs for a task with the | 3428 * input descriptors describing those inputs for a task with the |
| 3192 * given [target]. | 3429 * given [target]. |
| 3193 */ | 3430 */ |
| 3194 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 3431 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 3195 LibrarySpecificUnit unit = target; | 3432 LibrarySpecificUnit unit = target; |
| 3196 return <String, TaskInput>{ | 3433 return <String, TaskInput>{ |
| 3197 'fullyBuiltLibraryElements': IMPORT_EXPORT_SOURCE_CLOSURE | 3434 'fullyBuiltLibraryElements': IMPORT_EXPORT_SOURCE_CLOSURE |
| 3198 .of(unit.library) | 3435 .of(unit.library) |
| 3199 .toListOf(LIBRARY_ELEMENT5), | 3436 .toListOf(LIBRARY_ELEMENT5), |
| 3200 LIBRARY_INPUT: LIBRARY_ELEMENT5.of(unit.library), | 3437 LIBRARY_INPUT: LIBRARY_ELEMENT5.of(unit.library), |
| 3201 UNIT_INPUT: RESOLVED_UNIT4.of(unit), | 3438 UNIT_INPUT: RESOLVED_UNIT4.of(unit), |
| 3202 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) | 3439 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), |
| 3440 // In strong mode, add additional dependencies to enforce inference | |
| 3441 // ordering. | |
| 3442 | |
| 3443 // Require that full inference be complete for all dependencies of the | |
| 3444 // current library cycle. | |
| 3445 'orderLibraryCycles': LIBRARY_CYCLE_DEPENDENCIES.of(unit).toList( | |
| 3446 (CompilationUnitElementImpl unit) => RESOLVED_UNIT8 | |
| 3447 .of(new LibrarySpecificUnit(unit.librarySource, unit.source))) | |
| 3203 }; | 3448 }; |
| 3204 } | 3449 } |
| 3205 | 3450 |
| 3206 /** | 3451 /** |
| 3207 * Create a [PartiallyResolveUnitReferencesTask] based on the given [target] | 3452 * Create a [PartiallyResolveUnitReferencesTask] based on the given [target] |
| 3208 * in the given [context]. | 3453 * in the given [context]. |
| 3209 */ | 3454 */ |
| 3210 static PartiallyResolveUnitReferencesTask createTask( | 3455 static PartiallyResolveUnitReferencesTask createTask( |
| 3211 AnalysisContext context, AnalysisTarget target) { | 3456 AnalysisContext context, AnalysisTarget target) { |
| 3212 return new PartiallyResolveUnitReferencesTask(context, target); | 3457 return new PartiallyResolveUnitReferencesTask(context, target); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3347 dependsOn.add(name); | 3592 dependsOn.add(name); |
| 3348 } | 3593 } |
| 3349 } | 3594 } |
| 3350 } | 3595 } |
| 3351 } | 3596 } |
| 3352 | 3597 |
| 3353 /** | 3598 /** |
| 3354 * A task that resolves the bodies of top-level functions, constructors, and | 3599 * A task that resolves the bodies of top-level functions, constructors, and |
| 3355 * methods within a single compilation unit. | 3600 * methods within a single compilation unit. |
| 3356 */ | 3601 */ |
| 3357 class ResolveFunctionBodiesInUnitTask extends SourceBasedAnalysisTask { | 3602 class ResolveUnitTask extends SourceBasedAnalysisTask { |
| 3603 /** | |
| 3604 * The name of the input whose value is the defining [LIBRARY_ELEMENT5]. | |
| 3605 */ | |
| 3606 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; | |
| 3607 | |
| 3358 /** | 3608 /** |
| 3359 * The name of the [TYPE_PROVIDER] input. | 3609 * The name of the [TYPE_PROVIDER] input. |
| 3360 */ | 3610 */ |
| 3361 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; | 3611 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; |
| 3362 | 3612 |
| 3363 /** | 3613 /** |
| 3364 * The name of the [RESOLVED_UNIT7] input. | 3614 * The name of the [RESOLVED_UNIT8] input. |
| 3365 */ | 3615 */ |
| 3366 static const String UNIT_INPUT = 'UNIT_INPUT'; | 3616 static const String UNIT_INPUT = 'UNIT_INPUT'; |
| 3367 | 3617 |
| 3368 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 3618 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 3369 'ResolveFunctionBodiesInUnitTask', | 3619 'ResolveUnitTask', |
| 3370 createTask, | 3620 createTask, |
| 3371 buildInputs, | 3621 buildInputs, |
| 3372 <ResultDescriptor>[RESOLVE_FUNCTION_BODIES_ERRORS, RESOLVED_UNIT8]); | 3622 <ResultDescriptor>[RESOLVE_UNIT_ERRORS, RESOLVED_UNIT9]); |
| 3373 | 3623 |
| 3374 ResolveFunctionBodiesInUnitTask( | 3624 ResolveUnitTask( |
| 3375 InternalAnalysisContext context, LibrarySpecificUnit compilationUnit) | 3625 InternalAnalysisContext context, LibrarySpecificUnit compilationUnit) |
| 3376 : super(context, compilationUnit); | 3626 : super(context, compilationUnit); |
| 3377 | 3627 |
| 3378 @override | 3628 @override |
| 3379 TaskDescriptor get descriptor => DESCRIPTOR; | 3629 TaskDescriptor get descriptor => DESCRIPTOR; |
| 3380 | 3630 |
| 3381 @override | 3631 @override |
| 3382 void internalPerform() { | 3632 void internalPerform() { |
| 3383 // | 3633 // |
| 3384 // Prepare inputs. | 3634 // Prepare inputs. |
| 3385 // | 3635 // |
| 3636 LibraryElement libraryElement = getRequiredInput(LIBRARY_INPUT); | |
| 3386 CompilationUnit unit = getRequiredInput(UNIT_INPUT); | 3637 CompilationUnit unit = getRequiredInput(UNIT_INPUT); |
| 3387 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); | 3638 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); |
| 3388 // | 3639 // |
| 3389 // Resolve function bodies. | 3640 // Resolve everything |
| 3390 // | 3641 // |
| 3391 CompilationUnitElement unitElement = unit.element; | 3642 CompilationUnitElement unitElement = unit.element; |
| 3392 RecordingErrorListener errorListener = new RecordingErrorListener(); | 3643 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 3393 for (CompilationUnitMember unitMember in unit.declarations) { | 3644 ResolverVisitor visitor = new ResolverVisitor( |
| 3394 if (unitMember is FunctionDeclaration) { | 3645 libraryElement, unitElement.source, typeProvider, errorListener); |
| 3395 _resolveFunctionBody(unitMember.functionExpression.body, unitElement, | 3646 unit.accept(visitor); |
| 3396 typeProvider, errorListener); | |
| 3397 } else if (unitMember is ClassDeclaration) { | |
| 3398 for (ClassMember classMember in unitMember.members) { | |
| 3399 if (classMember is ConstructorDeclaration) { | |
| 3400 _resolveFunctionBody( | |
| 3401 classMember.body, unitElement, typeProvider, errorListener); | |
| 3402 } else if (classMember is MethodDeclaration) { | |
| 3403 _resolveFunctionBody( | |
| 3404 classMember.body, unitElement, typeProvider, errorListener); | |
| 3405 } | |
| 3406 } | |
| 3407 } | |
| 3408 } | |
| 3409 // | 3647 // |
| 3410 // Record outputs. | 3648 // Record outputs. |
| 3411 // | 3649 // |
| 3412 outputs[RESOLVE_FUNCTION_BODIES_ERRORS] = errorListener.errors; | 3650 outputs[RESOLVE_UNIT_ERRORS] = errorListener.errors; |
| 3413 outputs[RESOLVED_UNIT8] = unit; | 3651 outputs[RESOLVED_UNIT9] = unit; |
| 3414 } | |
| 3415 | |
| 3416 void _resolveFunctionBody( | |
| 3417 FunctionBody functionBody, | |
| 3418 CompilationUnitElement unitElement, | |
| 3419 TypeProvider typeProvider, | |
| 3420 RecordingErrorListener errorListener) { | |
| 3421 ResolutionContext resolutionContext = | |
| 3422 ResolutionContextBuilder.contextFor(functionBody, errorListener); | |
| 3423 ResolverVisitor visitor = new ResolverVisitor( | |
| 3424 unitElement.library, unitElement.source, typeProvider, errorListener, | |
| 3425 nameScope: resolutionContext.scope); | |
| 3426 if (resolutionContext.enclosingClassDeclaration != null) { | |
| 3427 visitor.prepareToResolveMembersInClass( | |
| 3428 resolutionContext.enclosingClassDeclaration); | |
| 3429 } | |
| 3430 Declaration declaration = functionBody.getAncestor((AstNode node) => | |
| 3431 node is ConstructorDeclaration || | |
| 3432 node is FunctionDeclaration || | |
| 3433 node is MethodDeclaration); | |
| 3434 visitor.initForIncrementalResolution(declaration); | |
| 3435 functionBody.accept(visitor); | |
| 3436 if (declaration is FunctionDeclaration) { | |
| 3437 // This is in the wrong place. The propagated return type is stored | |
| 3438 // locally in the resolver, not in the declaration (or element). Hence, | |
| 3439 // this needs to happen later. | |
| 3440 declaration.accept(visitor.typeAnalyzer); | |
| 3441 } | |
| 3442 } | 3652 } |
| 3443 | 3653 |
| 3444 /** | 3654 /** |
| 3445 * Return a map from the names of the inputs of this kind of task to the task | 3655 * Return a map from the names of the inputs of this kind of task to the task |
| 3446 * input descriptors describing those inputs for a task with the given | 3656 * input descriptors describing those inputs for a task with the given |
| 3447 * [target]. | 3657 * [target]. |
| 3448 */ | 3658 */ |
| 3449 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 3659 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 3450 LibrarySpecificUnit unit = target; | 3660 LibrarySpecificUnit unit = target; |
| 3451 return <String, TaskInput>{ | 3661 return <String, TaskInput>{ |
| 3662 LIBRARY_INPUT: LIBRARY_ELEMENT5.of(unit.library), | |
| 3452 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), | 3663 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), |
| 3453 UNIT_INPUT: RESOLVED_UNIT7.of(unit) | 3664 UNIT_INPUT: RESOLVED_UNIT8.of(unit), |
| 3665 // In strong mode, add additional dependencies to enforce inference | |
| 3666 // ordering. | |
| 3667 | |
| 3668 // Require that inference be complete for all units in the | |
| 3669 // current library cycle. | |
| 3670 'orderLibraryCycleTasks': LIBRARY_CYCLE_UNITS.of(unit).toList( | |
| 3671 (CompilationUnitElementImpl unit) => RESOLVED_UNIT8 | |
| 3672 .of(new LibrarySpecificUnit(unit.librarySource, unit.source))) | |
| 3454 }; | 3673 }; |
| 3455 } | 3674 } |
| 3456 | 3675 |
| 3457 /** | 3676 /** |
| 3458 * Create a [ResolveFunctionBodiesInUnitTask] based on the given [target] in | 3677 * Create a [ResolveUnitTask] based on the given [target] in |
| 3459 * the given [context]. | 3678 * the given [context]. |
| 3460 */ | 3679 */ |
| 3461 static ResolveFunctionBodiesInUnitTask createTask( | 3680 static ResolveUnitTask createTask( |
| 3462 AnalysisContext context, AnalysisTarget target) { | 3681 AnalysisContext context, AnalysisTarget target) { |
| 3463 return new ResolveFunctionBodiesInUnitTask(context, target); | 3682 return new ResolveUnitTask(context, target); |
| 3464 } | 3683 } |
| 3465 } | 3684 } |
| 3466 | 3685 |
| 3467 /** | 3686 /** |
| 3468 * A task that finishes resolution by requesting [RESOLVED_UNIT_NO_CONSTANTS] fo r every | 3687 * A task that finishes resolution by requesting [RESOLVED_UNIT_NO_CONSTANTS] fo r every |
| 3469 * unit in the libraries closure and produces [LIBRARY_ELEMENT]. | 3688 * unit in the libraries closure and produces [LIBRARY_ELEMENT]. |
| 3470 */ | 3689 */ |
| 3471 class ResolveLibraryReferencesTask extends SourceBasedAnalysisTask { | 3690 class ResolveLibraryReferencesTask extends SourceBasedAnalysisTask { |
| 3472 /** | 3691 /** |
| 3473 * The name of the [LIBRARY_ELEMENT5] input. | 3692 * The name of the [LIBRARY_ELEMENT5] input. |
| 3474 */ | 3693 */ |
| 3475 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; | 3694 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; |
| 3476 | 3695 |
| 3477 /** | 3696 /** |
| 3478 * The name of the list of [RESOLVED_UNIT8] input. | 3697 * The name of the list of [RESOLVED_UNIT9] input. |
| 3479 */ | 3698 */ |
| 3480 static const String UNITS_INPUT = 'UNITS_INPUT'; | 3699 static const String UNITS_INPUT = 'UNITS_INPUT'; |
| 3481 | 3700 |
| 3482 /** | 3701 /** |
| 3483 * The task descriptor describing this kind of task. | 3702 * The task descriptor describing this kind of task. |
| 3484 */ | 3703 */ |
| 3485 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 3704 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 3486 'ResolveLibraryReferencesTask', | 3705 'ResolveLibraryReferencesTask', |
| 3487 createTask, | 3706 createTask, |
| 3488 buildInputs, | 3707 buildInputs, |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 3517 /** | 3736 /** |
| 3518 * Return a map from the names of the inputs of this kind of task to the task | 3737 * Return a map from the names of the inputs of this kind of task to the task |
| 3519 * input descriptors describing those inputs for a task with the | 3738 * input descriptors describing those inputs for a task with the |
| 3520 * given [target]. | 3739 * given [target]. |
| 3521 */ | 3740 */ |
| 3522 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 3741 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 3523 Source source = target; | 3742 Source source = target; |
| 3524 return <String, TaskInput>{ | 3743 return <String, TaskInput>{ |
| 3525 LIBRARY_INPUT: LIBRARY_ELEMENT5.of(source), | 3744 LIBRARY_INPUT: LIBRARY_ELEMENT5.of(source), |
| 3526 UNITS_INPUT: UNITS.of(source).toList((Source unit) => | 3745 UNITS_INPUT: UNITS.of(source).toList((Source unit) => |
| 3527 RESOLVED_UNIT8.of(new LibrarySpecificUnit(source, unit))), | 3746 RESOLVED_UNIT9.of(new LibrarySpecificUnit(source, unit))), |
| 3528 'resolvedUnits': IMPORT_EXPORT_SOURCE_CLOSURE | 3747 'resolvedUnits': IMPORT_EXPORT_SOURCE_CLOSURE |
| 3529 .of(source) | 3748 .of(source) |
| 3530 .toMapOf(UNITS) | 3749 .toMapOf(UNITS) |
| 3531 .toFlattenList((Source library, Source unit) => | 3750 .toFlattenList((Source library, Source unit) => |
| 3532 RESOLVED_UNIT8.of(new LibrarySpecificUnit(library, unit))), | 3751 RESOLVED_UNIT9.of(new LibrarySpecificUnit(library, unit))), |
| 3533 }; | 3752 }; |
| 3534 } | 3753 } |
| 3535 | 3754 |
| 3536 /** | 3755 /** |
| 3537 * Create a [ResolveLibraryReferencesTask] based on the given [target] in | 3756 * Create a [ResolveLibraryReferencesTask] based on the given [target] in |
| 3538 * the given [context]. | 3757 * the given [context]. |
| 3539 */ | 3758 */ |
| 3540 static ResolveLibraryReferencesTask createTask( | 3759 static ResolveLibraryReferencesTask createTask( |
| 3541 AnalysisContext context, AnalysisTarget target) { | 3760 AnalysisContext context, AnalysisTarget target) { |
| 3542 return new ResolveLibraryReferencesTask(context, target); | 3761 return new ResolveLibraryReferencesTask(context, target); |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4126 | 4345 |
| 4127 @override | 4346 @override |
| 4128 bool moveNext() { | 4347 bool moveNext() { |
| 4129 if (_newSources.isEmpty) { | 4348 if (_newSources.isEmpty) { |
| 4130 return false; | 4349 return false; |
| 4131 } | 4350 } |
| 4132 currentTarget = _newSources.removeLast(); | 4351 currentTarget = _newSources.removeLast(); |
| 4133 return true; | 4352 return true; |
| 4134 } | 4353 } |
| 4135 } | 4354 } |
| OLD | NEW |