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