| 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 import 'dart:math' as math; | 8 import 'dart:math' as math; |
| 9 | 9 |
| 10 import 'package:analyzer/src/context/cache.dart'; | 10 import 'package:analyzer/src/context/cache.dart'; |
| 11 import 'package:analyzer/src/generated/ast.dart'; | 11 import 'package:analyzer/src/generated/ast.dart'; |
| 12 import 'package:analyzer/src/generated/constant.dart'; | 12 import 'package:analyzer/src/generated/constant.dart'; |
| 13 import 'package:analyzer/src/generated/element.dart'; | 13 import 'package:analyzer/src/generated/element.dart'; |
| 14 import 'package:analyzer/src/generated/engine.dart' | 14 import 'package:analyzer/src/generated/engine.dart' |
| 15 hide AnalysisCache, AnalysisTask; | 15 hide AnalysisCache, AnalysisTask; |
| 16 import 'package:analyzer/src/generated/error.dart'; | 16 import 'package:analyzer/src/generated/error.dart'; |
| 17 import 'package:analyzer/src/generated/error_verifier.dart'; | 17 import 'package:analyzer/src/generated/error_verifier.dart'; |
| 18 import 'package:analyzer/src/generated/java_engine.dart'; | 18 import 'package:analyzer/src/generated/java_engine.dart'; |
| 19 import 'package:analyzer/src/generated/parser.dart'; | 19 import 'package:analyzer/src/generated/parser.dart'; |
| 20 import 'package:analyzer/src/generated/resolver.dart'; | 20 import 'package:analyzer/src/generated/resolver.dart'; |
| 21 import 'package:analyzer/src/generated/scanner.dart'; | 21 import 'package:analyzer/src/generated/scanner.dart'; |
| 22 import 'package:analyzer/src/generated/sdk.dart'; | 22 import 'package:analyzer/src/generated/sdk.dart'; |
| 23 import 'package:analyzer/src/generated/source.dart'; | 23 import 'package:analyzer/src/generated/source.dart'; |
| 24 import 'package:analyzer/src/task/driver.dart'; | 24 import 'package:analyzer/src/task/driver.dart'; |
| 25 import 'package:analyzer/src/task/general.dart'; | 25 import 'package:analyzer/src/task/general.dart'; |
| 26 import 'package:analyzer/src/task/html.dart'; |
| 26 import 'package:analyzer/src/task/inputs.dart'; | 27 import 'package:analyzer/src/task/inputs.dart'; |
| 27 import 'package:analyzer/src/task/model.dart'; | 28 import 'package:analyzer/src/task/model.dart'; |
| 28 import 'package:analyzer/task/dart.dart'; | 29 import 'package:analyzer/task/dart.dart'; |
| 29 import 'package:analyzer/task/general.dart'; | 30 import 'package:analyzer/task/general.dart'; |
| 30 import 'package:analyzer/task/model.dart'; | 31 import 'package:analyzer/task/model.dart'; |
| 31 | 32 |
| 32 /** | 33 /** |
| 33 * The [ResultCachingPolicy] for ASTs. | 34 * The [ResultCachingPolicy] for ASTs. |
| 34 */ | 35 */ |
| 35 const ResultCachingPolicy AST_CACHING_POLICY = | 36 const ResultCachingPolicy AST_CACHING_POLICY = |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 outputs[CONSTRUCTORS] = classElement.constructors; | 537 outputs[CONSTRUCTORS] = classElement.constructors; |
| 537 outputs[CONSTRUCTORS_ERRORS] = errors; | 538 outputs[CONSTRUCTORS_ERRORS] = errors; |
| 538 } | 539 } |
| 539 } | 540 } |
| 540 | 541 |
| 541 /** | 542 /** |
| 542 * Return a map from the names of the inputs of this kind of task to the task | 543 * Return a map from the names of the inputs of this kind of task to the task |
| 543 * input descriptors describing those inputs for a task with the | 544 * input descriptors describing those inputs for a task with the |
| 544 * given [classElement]. | 545 * given [classElement]. |
| 545 */ | 546 */ |
| 546 static Map<String, TaskInput> buildInputs(ClassElement classElement) { | 547 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 547 Source librarySource = classElement.library.source; | 548 ClassElement element = target; |
| 548 DartType superType = classElement.supertype; | 549 Source librarySource = element.library.source; |
| 550 DartType superType = element.supertype; |
| 549 if (superType is InterfaceType) { | 551 if (superType is InterfaceType) { |
| 550 if (classElement.isMixinApplication || classElement.mixins.isNotEmpty) { | 552 if (element.isMixinApplication || element.mixins.isNotEmpty) { |
| 551 ClassElement superElement = superType.element; | 553 ClassElement superElement = superType.element; |
| 552 return <String, TaskInput>{ | 554 return <String, TaskInput>{ |
| 553 'libraryDep': LIBRARY_ELEMENT5.of(librarySource), | 555 'libraryDep': LIBRARY_ELEMENT5.of(librarySource), |
| 554 SUPER_CONSTRUCTORS: CONSTRUCTORS.of(superElement) | 556 SUPER_CONSTRUCTORS: CONSTRUCTORS.of(superElement) |
| 555 }; | 557 }; |
| 556 } | 558 } |
| 557 } | 559 } |
| 558 // No implicit constructors. | 560 // No implicit constructors. |
| 559 // Depend on LIBRARY_ELEMENT5 for invalidation. | 561 // Depend on LIBRARY_ELEMENT5 for invalidation. |
| 560 return <String, TaskInput>{ | 562 return <String, TaskInput>{ |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 outputs[COMPILATION_UNIT_ELEMENT] = element; | 746 outputs[COMPILATION_UNIT_ELEMENT] = element; |
| 745 outputs[RESOLVED_UNIT1] = unit; | 747 outputs[RESOLVED_UNIT1] = unit; |
| 746 outputs[COMPILATION_UNIT_CONSTANTS] = constants; | 748 outputs[COMPILATION_UNIT_CONSTANTS] = constants; |
| 747 } | 749 } |
| 748 | 750 |
| 749 /** | 751 /** |
| 750 * Return a map from the names of the inputs of this kind of task to the task | 752 * Return a map from the names of the inputs of this kind of task to the task |
| 751 * input descriptors describing those inputs for a task with the given | 753 * input descriptors describing those inputs for a task with the given |
| 752 * [target]. | 754 * [target]. |
| 753 */ | 755 */ |
| 754 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { | 756 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 757 LibrarySpecificUnit unit = target; |
| 755 return <String, TaskInput>{ | 758 return <String, TaskInput>{ |
| 756 PARSED_UNIT_INPUT_NAME: PARSED_UNIT.of(target.unit) | 759 PARSED_UNIT_INPUT_NAME: PARSED_UNIT.of(unit.unit) |
| 757 }; | 760 }; |
| 758 } | 761 } |
| 759 | 762 |
| 760 /** | 763 /** |
| 761 * Create a [BuildCompilationUnitElementTask] based on the given [target] in | 764 * Create a [BuildCompilationUnitElementTask] based on the given [target] in |
| 762 * the given [context]. | 765 * the given [context]. |
| 763 */ | 766 */ |
| 764 static BuildCompilationUnitElementTask createTask( | 767 static BuildCompilationUnitElementTask createTask( |
| 765 AnalysisContext context, AnalysisTarget target) { | 768 AnalysisContext context, AnalysisTarget target) { |
| 766 return new BuildCompilationUnitElementTask(context, target); | 769 return new BuildCompilationUnitElementTask(context, target); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 // | 948 // |
| 946 outputs[LIBRARY_ELEMENT2] = libraryElement; | 949 outputs[LIBRARY_ELEMENT2] = libraryElement; |
| 947 outputs[BUILD_DIRECTIVES_ERRORS] = errors; | 950 outputs[BUILD_DIRECTIVES_ERRORS] = errors; |
| 948 } | 951 } |
| 949 | 952 |
| 950 /** | 953 /** |
| 951 * Return a map from the names of the inputs of this kind of task to the task | 954 * Return a map from the names of the inputs of this kind of task to the task |
| 952 * input descriptors describing those inputs for a task with the | 955 * input descriptors describing those inputs for a task with the |
| 953 * given library [libSource]. | 956 * given library [libSource]. |
| 954 */ | 957 */ |
| 955 static Map<String, TaskInput> buildInputs(Source libSource) { | 958 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 959 Source source = target; |
| 956 return <String, TaskInput>{ | 960 return <String, TaskInput>{ |
| 957 LIBRARY_INPUT: LIBRARY_ELEMENT1.of(libSource), | 961 LIBRARY_INPUT: LIBRARY_ELEMENT1.of(source), |
| 958 UNIT_INPUT_NAME: | 962 UNIT_INPUT_NAME: |
| 959 RESOLVED_UNIT1.of(new LibrarySpecificUnit(libSource, libSource)), | 963 RESOLVED_UNIT1.of(new LibrarySpecificUnit(source, source)), |
| 960 IMPORTS_LIBRARY_ELEMENT_INPUT_NAME: | 964 IMPORTS_LIBRARY_ELEMENT_INPUT_NAME: |
| 961 IMPORTED_LIBRARIES.of(libSource).toMapOf(LIBRARY_ELEMENT1), | 965 IMPORTED_LIBRARIES.of(source).toMapOf(LIBRARY_ELEMENT1), |
| 962 EXPORTS_LIBRARY_ELEMENT_INPUT_NAME: | 966 EXPORTS_LIBRARY_ELEMENT_INPUT_NAME: |
| 963 EXPORTED_LIBRARIES.of(libSource).toMapOf(LIBRARY_ELEMENT1), | 967 EXPORTED_LIBRARIES.of(source).toMapOf(LIBRARY_ELEMENT1), |
| 964 IMPORTS_SOURCE_KIND_INPUT_NAME: | 968 IMPORTS_SOURCE_KIND_INPUT_NAME: |
| 965 IMPORTED_LIBRARIES.of(libSource).toMapOf(SOURCE_KIND), | 969 IMPORTED_LIBRARIES.of(source).toMapOf(SOURCE_KIND), |
| 966 EXPORTS_SOURCE_KIND_INPUT_NAME: | 970 EXPORTS_SOURCE_KIND_INPUT_NAME: |
| 967 EXPORTED_LIBRARIES.of(libSource).toMapOf(SOURCE_KIND) | 971 EXPORTED_LIBRARIES.of(source).toMapOf(SOURCE_KIND) |
| 968 }; | 972 }; |
| 969 } | 973 } |
| 970 | 974 |
| 971 /** | 975 /** |
| 972 * Create a [BuildDirectiveElementsTask] based on the given [target] in | 976 * Create a [BuildDirectiveElementsTask] based on the given [target] in |
| 973 * the given [context]. | 977 * the given [context]. |
| 974 */ | 978 */ |
| 975 static BuildDirectiveElementsTask createTask( | 979 static BuildDirectiveElementsTask createTask( |
| 976 AnalysisContext context, AnalysisTarget target) { | 980 AnalysisContext context, AnalysisTarget target) { |
| 977 return new BuildDirectiveElementsTask(context, target); | 981 return new BuildDirectiveElementsTask(context, target); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1050 EnumMemberBuilder builder = new EnumMemberBuilder(typeProvider); | 1054 EnumMemberBuilder builder = new EnumMemberBuilder(typeProvider); |
| 1051 unit.accept(builder); | 1055 unit.accept(builder); |
| 1052 outputs[RESOLVED_UNIT2] = unit; | 1056 outputs[RESOLVED_UNIT2] = unit; |
| 1053 } | 1057 } |
| 1054 | 1058 |
| 1055 /** | 1059 /** |
| 1056 * Return a map from the names of the inputs of this kind of task to the task | 1060 * Return a map from the names of the inputs of this kind of task to the task |
| 1057 * input descriptors describing those inputs for a task with the | 1061 * input descriptors describing those inputs for a task with the |
| 1058 * given [target]. | 1062 * given [target]. |
| 1059 */ | 1063 */ |
| 1060 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { | 1064 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 1065 LibrarySpecificUnit unit = target; |
| 1061 return <String, TaskInput>{ | 1066 return <String, TaskInput>{ |
| 1062 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), | 1067 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), |
| 1063 UNIT_INPUT: RESOLVED_UNIT1.of(target) | 1068 UNIT_INPUT: RESOLVED_UNIT1.of(unit) |
| 1064 }; | 1069 }; |
| 1065 } | 1070 } |
| 1066 | 1071 |
| 1067 /** | 1072 /** |
| 1068 * Create a [BuildEnumMemberElementsTask] based on the given [target] in | 1073 * Create a [BuildEnumMemberElementsTask] based on the given [target] in |
| 1069 * the given [context]. | 1074 * the given [context]. |
| 1070 */ | 1075 */ |
| 1071 static BuildEnumMemberElementsTask createTask( | 1076 static BuildEnumMemberElementsTask createTask( |
| 1072 AnalysisContext context, AnalysisTarget target) { | 1077 AnalysisContext context, AnalysisTarget target) { |
| 1073 return new BuildEnumMemberElementsTask(context, target); | 1078 return new BuildEnumMemberElementsTask(context, target); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1119 // Record outputs. | 1124 // Record outputs. |
| 1120 // | 1125 // |
| 1121 outputs[LIBRARY_ELEMENT4] = library; | 1126 outputs[LIBRARY_ELEMENT4] = library; |
| 1122 } | 1127 } |
| 1123 | 1128 |
| 1124 /** | 1129 /** |
| 1125 * Return a map from the names of the inputs of this kind of task to the task | 1130 * Return a map from the names of the inputs of this kind of task to the task |
| 1126 * input descriptors describing those inputs for a task with the | 1131 * input descriptors describing those inputs for a task with the |
| 1127 * given library [libSource]. | 1132 * given library [libSource]. |
| 1128 */ | 1133 */ |
| 1129 static Map<String, TaskInput> buildInputs(Source libSource) { | 1134 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 1135 Source source = target; |
| 1130 return <String, TaskInput>{ | 1136 return <String, TaskInput>{ |
| 1131 LIBRARY_INPUT: LIBRARY_ELEMENT3.of(libSource), | 1137 LIBRARY_INPUT: LIBRARY_ELEMENT3.of(source), |
| 1132 'exportsLibraryPublicNamespace': | 1138 'exportsLibraryPublicNamespace': |
| 1133 EXPORT_SOURCE_CLOSURE.of(libSource).toMapOf(LIBRARY_ELEMENT3) | 1139 EXPORT_SOURCE_CLOSURE.of(source).toMapOf(LIBRARY_ELEMENT3) |
| 1134 }; | 1140 }; |
| 1135 } | 1141 } |
| 1136 | 1142 |
| 1137 /** | 1143 /** |
| 1138 * Create a [BuildExportNamespaceTask] based on the given [target] in | 1144 * Create a [BuildExportNamespaceTask] based on the given [target] in |
| 1139 * the given [context]. | 1145 * the given [context]. |
| 1140 */ | 1146 */ |
| 1141 static BuildExportNamespaceTask createTask( | 1147 static BuildExportNamespaceTask createTask( |
| 1142 AnalysisContext context, AnalysisTarget target) { | 1148 AnalysisContext context, AnalysisTarget target) { |
| 1143 return new BuildExportNamespaceTask(context, target); | 1149 return new BuildExportNamespaceTask(context, target); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1204 removeDuplicateErrors(errorListener.errors); | 1210 removeDuplicateErrors(errorListener.errors); |
| 1205 outputs[RESOLVED_UNIT3] = unit; | 1211 outputs[RESOLVED_UNIT3] = unit; |
| 1206 } | 1212 } |
| 1207 | 1213 |
| 1208 /** | 1214 /** |
| 1209 * Return a map from the names of the inputs of this kind of task to the task | 1215 * Return a map from the names of the inputs of this kind of task to the task |
| 1210 * input descriptors describing those inputs for a task with the | 1216 * input descriptors describing those inputs for a task with the |
| 1211 * given [target]. | 1217 * given [target]. |
| 1212 */ | 1218 */ |
| 1213 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { | 1219 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { |
| 1220 LibrarySpecificUnit unit = target; |
| 1214 return <String, TaskInput>{ | 1221 return <String, TaskInput>{ |
| 1215 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), | 1222 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), |
| 1216 'importsExportNamespace': | 1223 'importsExportNamespace': |
| 1217 IMPORTED_LIBRARIES.of(target.library).toMapOf(LIBRARY_ELEMENT4), | 1224 IMPORTED_LIBRARIES.of(unit.library).toMapOf(LIBRARY_ELEMENT4), |
| 1218 LIBRARY_INPUT: LIBRARY_ELEMENT4.of(target.library), | 1225 LIBRARY_INPUT: LIBRARY_ELEMENT4.of(unit.library), |
| 1219 UNIT_INPUT: RESOLVED_UNIT2.of(target) | 1226 UNIT_INPUT: RESOLVED_UNIT2.of(unit) |
| 1220 }; | 1227 }; |
| 1221 } | 1228 } |
| 1222 | 1229 |
| 1223 /** | 1230 /** |
| 1224 * Create a [BuildFunctionTypeAliasesTask] based on the given [target] in | 1231 * Create a [BuildFunctionTypeAliasesTask] based on the given [target] in |
| 1225 * the given [context]. | 1232 * the given [context]. |
| 1226 */ | 1233 */ |
| 1227 static BuildFunctionTypeAliasesTask createTask( | 1234 static BuildFunctionTypeAliasesTask createTask( |
| 1228 AnalysisContext context, AnalysisTarget target) { | 1235 AnalysisContext context, AnalysisTarget target) { |
| 1229 return new BuildFunctionTypeAliasesTask(context, target); | 1236 return new BuildFunctionTypeAliasesTask(context, target); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1258 void internalPerform() { | 1265 void internalPerform() { |
| 1259 LibraryElement library = getRequiredInput(LIBRARY_INPUT); | 1266 LibraryElement library = getRequiredInput(LIBRARY_INPUT); |
| 1260 outputs[LIBRARY_ELEMENT6] = library; | 1267 outputs[LIBRARY_ELEMENT6] = library; |
| 1261 } | 1268 } |
| 1262 | 1269 |
| 1263 /** | 1270 /** |
| 1264 * Return a map from the names of the inputs of this kind of task to the task | 1271 * Return a map from the names of the inputs of this kind of task to the task |
| 1265 * input descriptors describing those inputs for a task with the | 1272 * input descriptors describing those inputs for a task with the |
| 1266 * given [target]. | 1273 * given [target]. |
| 1267 */ | 1274 */ |
| 1268 static Map<String, TaskInput> buildInputs(Source libSource) { | 1275 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 1276 Source source = target; |
| 1269 return <String, TaskInput>{ | 1277 return <String, TaskInput>{ |
| 1270 LIBRARY_INPUT: LIBRARY_ELEMENT5.of(libSource), | 1278 LIBRARY_INPUT: LIBRARY_ELEMENT5.of(source), |
| 1271 'resolvedConstructors': | 1279 'resolvedConstructors': CLASS_ELEMENTS.of(source).toListOf(CONSTRUCTORS), |
| 1272 CLASS_ELEMENTS.of(libSource).toListOf(CONSTRUCTORS), | |
| 1273 }; | 1280 }; |
| 1274 } | 1281 } |
| 1275 | 1282 |
| 1276 /** | 1283 /** |
| 1277 * Create a [BuildLibraryConstructorsTask] based on the given [target] in | 1284 * Create a [BuildLibraryConstructorsTask] based on the given [target] in |
| 1278 * the given [context]. | 1285 * the given [context]. |
| 1279 */ | 1286 */ |
| 1280 static BuildLibraryConstructorsTask createTask( | 1287 static BuildLibraryConstructorsTask createTask( |
| 1281 AnalysisContext context, AnalysisTarget target) { | 1288 AnalysisContext context, AnalysisTarget target) { |
| 1282 return new BuildLibraryConstructorsTask(context, target); | 1289 return new BuildLibraryConstructorsTask(context, target); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1530 (setter as PropertyAccessorElementImpl).variable = variable; | 1537 (setter as PropertyAccessorElementImpl).variable = variable; |
| 1531 } | 1538 } |
| 1532 } | 1539 } |
| 1533 } | 1540 } |
| 1534 | 1541 |
| 1535 /** | 1542 /** |
| 1536 * Return a map from the names of the inputs of this kind of task to the task | 1543 * Return a map from the names of the inputs of this kind of task to the task |
| 1537 * input descriptors describing those inputs for a task with the given | 1544 * input descriptors describing those inputs for a task with the given |
| 1538 * [libSource]. | 1545 * [libSource]. |
| 1539 */ | 1546 */ |
| 1540 static Map<String, TaskInput> buildInputs(Source libSource) { | 1547 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 1548 Source source = target; |
| 1541 return <String, TaskInput>{ | 1549 return <String, TaskInput>{ |
| 1542 DEFINING_UNIT_INPUT: | 1550 DEFINING_UNIT_INPUT: |
| 1543 RESOLVED_UNIT1.of(new LibrarySpecificUnit(libSource, libSource)), | 1551 RESOLVED_UNIT1.of(new LibrarySpecificUnit(source, source)), |
| 1544 PARTS_UNIT_INPUT: INCLUDED_PARTS.of(libSource).toList((Source unit) { | 1552 PARTS_UNIT_INPUT: INCLUDED_PARTS.of(source).toList((Source unit) { |
| 1545 return RESOLVED_UNIT1.of(new LibrarySpecificUnit(libSource, unit)); | 1553 return RESOLVED_UNIT1.of(new LibrarySpecificUnit(source, unit)); |
| 1546 }) | 1554 }) |
| 1547 }; | 1555 }; |
| 1548 } | 1556 } |
| 1549 | 1557 |
| 1550 /** | 1558 /** |
| 1551 * Create a [BuildLibraryElementTask] based on the given [target] in the | 1559 * Create a [BuildLibraryElementTask] based on the given [target] in the |
| 1552 * given [context]. | 1560 * given [context]. |
| 1553 */ | 1561 */ |
| 1554 static BuildLibraryElementTask createTask( | 1562 static BuildLibraryElementTask createTask( |
| 1555 AnalysisContext context, AnalysisTarget target) { | 1563 AnalysisContext context, AnalysisTarget target) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1585 LibraryElementImpl library = getRequiredInput(LIBRARY_INPUT); | 1593 LibraryElementImpl library = getRequiredInput(LIBRARY_INPUT); |
| 1586 library.publicNamespace = new PublicNamespaceBuilder().build(library); | 1594 library.publicNamespace = new PublicNamespaceBuilder().build(library); |
| 1587 outputs[LIBRARY_ELEMENT3] = library; | 1595 outputs[LIBRARY_ELEMENT3] = library; |
| 1588 } | 1596 } |
| 1589 | 1597 |
| 1590 /** | 1598 /** |
| 1591 * Return a map from the names of the inputs of this kind of task to the task | 1599 * Return a map from the names of the inputs of this kind of task to the task |
| 1592 * input descriptors describing those inputs for a task with the | 1600 * input descriptors describing those inputs for a task with the |
| 1593 * given library [libSource]. | 1601 * given library [libSource]. |
| 1594 */ | 1602 */ |
| 1595 static Map<String, TaskInput> buildInputs(Source libSource) { | 1603 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 1596 return <String, TaskInput>{LIBRARY_INPUT: LIBRARY_ELEMENT2.of(libSource)}; | 1604 Source source = target; |
| 1605 return <String, TaskInput>{LIBRARY_INPUT: LIBRARY_ELEMENT2.of(source)}; |
| 1597 } | 1606 } |
| 1598 | 1607 |
| 1599 /** | 1608 /** |
| 1600 * Create a [BuildPublicNamespaceTask] based on the given [target] in | 1609 * Create a [BuildPublicNamespaceTask] based on the given [target] in |
| 1601 * the given [context]. | 1610 * the given [context]. |
| 1602 */ | 1611 */ |
| 1603 static BuildPublicNamespaceTask createTask( | 1612 static BuildPublicNamespaceTask createTask( |
| 1604 AnalysisContext context, AnalysisTarget target) { | 1613 AnalysisContext context, AnalysisTarget target) { |
| 1605 return new BuildPublicNamespaceTask(context, target); | 1614 return new BuildPublicNamespaceTask(context, target); |
| 1606 } | 1615 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1657 outputs[EXPORT_SOURCE_CLOSURE] = exportClosure; | 1666 outputs[EXPORT_SOURCE_CLOSURE] = exportClosure; |
| 1658 outputs[IMPORT_EXPORT_SOURCE_CLOSURE] = importExportClosure; | 1667 outputs[IMPORT_EXPORT_SOURCE_CLOSURE] = importExportClosure; |
| 1659 outputs[IS_CLIENT] = importExportClosure.contains(htmlSource); | 1668 outputs[IS_CLIENT] = importExportClosure.contains(htmlSource); |
| 1660 } | 1669 } |
| 1661 | 1670 |
| 1662 /** | 1671 /** |
| 1663 * Return a map from the names of the inputs of this kind of task to the task | 1672 * Return a map from the names of the inputs of this kind of task to the task |
| 1664 * input descriptors describing those inputs for a task with the | 1673 * input descriptors describing those inputs for a task with the |
| 1665 * given library [libSource]. | 1674 * given library [libSource]. |
| 1666 */ | 1675 */ |
| 1667 static Map<String, TaskInput> buildInputs(Source libSource) { | 1676 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 1677 Source source = target; |
| 1668 return <String, TaskInput>{ | 1678 return <String, TaskInput>{ |
| 1669 IMPORT_INPUT: new _ImportSourceClosureTaskInput(libSource), | 1679 IMPORT_INPUT: new _ImportSourceClosureTaskInput(source), |
| 1670 EXPORT_INPUT: new _ExportSourceClosureTaskInput(libSource), | 1680 EXPORT_INPUT: new _ExportSourceClosureTaskInput(source), |
| 1671 IMPORT_EXPORT_INPUT: new _ImportExportSourceClosureTaskInput(libSource) | 1681 IMPORT_EXPORT_INPUT: new _ImportExportSourceClosureTaskInput(source) |
| 1672 }; | 1682 }; |
| 1673 } | 1683 } |
| 1674 | 1684 |
| 1675 /** | 1685 /** |
| 1676 * Create a [BuildSourceClosuresTask] based on the given [target] in | 1686 * Create a [BuildSourceClosuresTask] based on the given [target] in |
| 1677 * the given [context]. | 1687 * the given [context]. |
| 1678 */ | 1688 */ |
| 1679 static BuildSourceClosuresTask createTask( | 1689 static BuildSourceClosuresTask createTask( |
| 1680 AnalysisContext context, AnalysisTarget target) { | 1690 AnalysisContext context, AnalysisTarget target) { |
| 1681 return new BuildSourceClosuresTask(context, target); | 1691 return new BuildSourceClosuresTask(context, target); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1718 Namespace asyncNamespace = asyncLibrary.publicNamespace; | 1728 Namespace asyncNamespace = asyncLibrary.publicNamespace; |
| 1719 // | 1729 // |
| 1720 // Record outputs. | 1730 // Record outputs. |
| 1721 // | 1731 // |
| 1722 TypeProvider typeProvider = | 1732 TypeProvider typeProvider = |
| 1723 new TypeProviderImpl.forNamespaces(coreNamespace, asyncNamespace); | 1733 new TypeProviderImpl.forNamespaces(coreNamespace, asyncNamespace); |
| 1724 (context as InternalAnalysisContext).typeProvider = typeProvider; | 1734 (context as InternalAnalysisContext).typeProvider = typeProvider; |
| 1725 outputs[TYPE_PROVIDER] = typeProvider; | 1735 outputs[TYPE_PROVIDER] = typeProvider; |
| 1726 } | 1736 } |
| 1727 | 1737 |
| 1728 static Map<String, TaskInput> buildInputs(AnalysisContextTarget target) { | 1738 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 1729 SourceFactory sourceFactory = target.context.sourceFactory; | 1739 AnalysisContextTarget contextTarget = target; |
| 1740 SourceFactory sourceFactory = contextTarget.context.sourceFactory; |
| 1730 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE); | 1741 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE); |
| 1731 Source asyncSource = sourceFactory.forUri(DartSdk.DART_ASYNC); | 1742 Source asyncSource = sourceFactory.forUri(DartSdk.DART_ASYNC); |
| 1732 return <String, TaskInput>{ | 1743 return <String, TaskInput>{ |
| 1733 CORE_INPUT: LIBRARY_ELEMENT3.of(coreSource), | 1744 CORE_INPUT: LIBRARY_ELEMENT3.of(coreSource), |
| 1734 ASYNC_INPUT: LIBRARY_ELEMENT3.of(asyncSource) | 1745 ASYNC_INPUT: LIBRARY_ELEMENT3.of(asyncSource) |
| 1735 }; | 1746 }; |
| 1736 } | 1747 } |
| 1737 | 1748 |
| 1738 /** | 1749 /** |
| 1739 * Create a [BuildTypeProviderTask] based on the given [context]. | 1750 * Create a [BuildTypeProviderTask] based on the given [context]. |
| 1740 */ | 1751 */ |
| 1741 static BuildTypeProviderTask createTask( | 1752 static BuildTypeProviderTask createTask( |
| 1742 AnalysisContext context, AnalysisContextTarget target) { | 1753 AnalysisContext context, AnalysisTarget target) { |
| 1743 return new BuildTypeProviderTask(context, target); | 1754 return new BuildTypeProviderTask(context, target); |
| 1744 } | 1755 } |
| 1745 } | 1756 } |
| 1746 | 1757 |
| 1747 /** | 1758 /** |
| 1748 * A task that computes [CONSTANT_DEPENDENCIES] for a constant. | 1759 * A task that computes [CONSTANT_DEPENDENCIES] for a constant. |
| 1749 */ | 1760 */ |
| 1750 class ComputeConstantDependenciesTask extends ConstantEvaluationAnalysisTask { | 1761 class ComputeConstantDependenciesTask extends ConstantEvaluationAnalysisTask { |
| 1751 /** | 1762 /** |
| 1752 * The name of the [RESOLVED_UNIT6] input. | 1763 * The name of the [RESOLVED_UNIT6] input. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1791 // Record outputs. | 1802 // Record outputs. |
| 1792 // | 1803 // |
| 1793 outputs[CONSTANT_DEPENDENCIES] = dependencies; | 1804 outputs[CONSTANT_DEPENDENCIES] = dependencies; |
| 1794 } | 1805 } |
| 1795 | 1806 |
| 1796 /** | 1807 /** |
| 1797 * Return a map from the names of the inputs of this kind of task to the task | 1808 * Return a map from the names of the inputs of this kind of task to the task |
| 1798 * input descriptors describing those inputs for a task with the | 1809 * input descriptors describing those inputs for a task with the |
| 1799 * given [target]. | 1810 * given [target]. |
| 1800 */ | 1811 */ |
| 1801 static Map<String, TaskInput> buildInputs(ConstantEvaluationTarget target) { | 1812 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 1802 if (target is Element) { | 1813 if (target is Element) { |
| 1803 CompilationUnitElementImpl unit = (target as Element) | 1814 CompilationUnitElementImpl unit = target |
| 1804 .getAncestor((Element element) => element is CompilationUnitElement); | 1815 .getAncestor((Element element) => element is CompilationUnitElement); |
| 1805 return <String, TaskInput>{ | 1816 return <String, TaskInput>{ |
| 1806 UNIT_INPUT: RESOLVED_UNIT6 | 1817 UNIT_INPUT: RESOLVED_UNIT6 |
| 1807 .of(new LibrarySpecificUnit(unit.librarySource, target.source)), | 1818 .of(new LibrarySpecificUnit(unit.librarySource, target.source)), |
| 1808 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) | 1819 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) |
| 1809 }; | 1820 }; |
| 1810 } else if (target is ConstantEvaluationTarget_Annotation) { | 1821 } else if (target is ConstantEvaluationTarget_Annotation) { |
| 1811 return <String, TaskInput>{ | 1822 return <String, TaskInput>{ |
| 1812 UNIT_INPUT: RESOLVED_UNIT6 | 1823 UNIT_INPUT: RESOLVED_UNIT6 |
| 1813 .of(new LibrarySpecificUnit(target.librarySource, target.source)), | 1824 .of(new LibrarySpecificUnit(target.librarySource, target.source)), |
| 1814 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) | 1825 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) |
| 1815 }; | 1826 }; |
| 1816 } else { | |
| 1817 // Should never happen. | |
| 1818 assert(false); | |
| 1819 return <String, TaskInput>{}; | |
| 1820 } | 1827 } |
| 1828 throw new AnalysisException( |
| 1829 'Cannot build inputs for a ${target.runtimeType}'); |
| 1821 } | 1830 } |
| 1822 | 1831 |
| 1823 /** | 1832 /** |
| 1824 * Create a [ResolveUnitReferencesTask] based on the given [target] in | 1833 * Create a [ResolveUnitReferencesTask] based on the given [target] in |
| 1825 * the given [context]. | 1834 * the given [context]. |
| 1826 */ | 1835 */ |
| 1827 static ComputeConstantDependenciesTask createTask( | 1836 static ComputeConstantDependenciesTask createTask( |
| 1828 AnalysisContext context, AnalysisTarget target) { | 1837 AnalysisContext context, AnalysisTarget target) { |
| 1829 return new ComputeConstantDependenciesTask(context, target); | 1838 return new ComputeConstantDependenciesTask(context, target); |
| 1830 } | 1839 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1894 // Record outputs. | 1903 // Record outputs. |
| 1895 // | 1904 // |
| 1896 outputs[CONSTANT_VALUE] = constant; | 1905 outputs[CONSTANT_VALUE] = constant; |
| 1897 } | 1906 } |
| 1898 | 1907 |
| 1899 /** | 1908 /** |
| 1900 * Return a map from the names of the inputs of this kind of task to the task | 1909 * Return a map from the names of the inputs of this kind of task to the task |
| 1901 * input descriptors describing those inputs for a task with the given | 1910 * input descriptors describing those inputs for a task with the given |
| 1902 * [target]. | 1911 * [target]. |
| 1903 */ | 1912 */ |
| 1904 static Map<String, TaskInput> buildInputs(ConstantEvaluationTarget target) { | 1913 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 1914 ConstantEvaluationTarget evaluationTarget = target; |
| 1905 return <String, TaskInput>{ | 1915 return <String, TaskInput>{ |
| 1906 DEPENDENCIES_INPUT: | 1916 DEPENDENCIES_INPUT: |
| 1907 CONSTANT_DEPENDENCIES.of(target).toListOf(CONSTANT_VALUE), | 1917 CONSTANT_DEPENDENCIES.of(evaluationTarget).toListOf(CONSTANT_VALUE), |
| 1908 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) | 1918 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) |
| 1909 }; | 1919 }; |
| 1910 } | 1920 } |
| 1911 | 1921 |
| 1912 /** | 1922 /** |
| 1913 * Create a [ComputeConstantValueTask] based on the given [target] in the | 1923 * Create a [ComputeConstantValueTask] based on the given [target] in the |
| 1914 * given [context]. | 1924 * given [context]. |
| 1915 */ | 1925 */ |
| 1916 static ComputeConstantValueTask createTask( | 1926 static ComputeConstantValueTask createTask( |
| 1917 AnalysisContext context, AnalysisTarget target) { | 1927 AnalysisContext context, AnalysisTarget target) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1977 // cache appropriately. | 1987 // cache appropriately. |
| 1978 Source source = getRequiredSource(); | 1988 Source source = getRequiredSource(); |
| 1979 outputs[CONTAINING_LIBRARIES] = context.getLibrariesContaining(source); | 1989 outputs[CONTAINING_LIBRARIES] = context.getLibrariesContaining(source); |
| 1980 } | 1990 } |
| 1981 | 1991 |
| 1982 /** | 1992 /** |
| 1983 * Return a map from the names of the inputs of this kind of task to the task | 1993 * Return a map from the names of the inputs of this kind of task to the task |
| 1984 * input descriptors describing those inputs for a task with the | 1994 * input descriptors describing those inputs for a task with the |
| 1985 * given [target]. | 1995 * given [target]. |
| 1986 */ | 1996 */ |
| 1987 static Map<String, TaskInput> buildInputs(Source target) { | 1997 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 1988 return <String, TaskInput>{}; | 1998 return <String, TaskInput>{}; |
| 1989 } | 1999 } |
| 1990 | 2000 |
| 1991 /** | 2001 /** |
| 1992 * Create a [ContainingLibrariesTask] based on the given [target] in the given | 2002 * Create a [ContainingLibrariesTask] based on the given [target] in the given |
| 1993 * [context]. | 2003 * [context]. |
| 1994 */ | 2004 */ |
| 1995 static ContainingLibrariesTask createTask( | 2005 static ContainingLibrariesTask createTask( |
| 1996 AnalysisContext context, AnalysisTarget target) { | 2006 AnalysisContext context, AnalysisTarget target) { |
| 1997 return new ContainingLibrariesTask(context, target); | 2007 return new ContainingLibrariesTask(context, target); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2059 // Record outputs. | 2069 // Record outputs. |
| 2060 // | 2070 // |
| 2061 outputs[DART_ERRORS] = AnalysisError.mergeLists(errorLists); | 2071 outputs[DART_ERRORS] = AnalysisError.mergeLists(errorLists); |
| 2062 } | 2072 } |
| 2063 | 2073 |
| 2064 /** | 2074 /** |
| 2065 * Return a map from the names of the inputs of this kind of task to the task | 2075 * Return a map from the names of the inputs of this kind of task to the task |
| 2066 * input descriptors describing those inputs for a task with the | 2076 * input descriptors describing those inputs for a task with the |
| 2067 * given [target]. | 2077 * given [target]. |
| 2068 */ | 2078 */ |
| 2069 static Map<String, TaskInput> buildInputs(Source target) { | 2079 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 2080 Source source = target; |
| 2070 return <String, TaskInput>{ | 2081 return <String, TaskInput>{ |
| 2071 BUILD_DIRECTIVES_ERRORS_INPUT: BUILD_DIRECTIVES_ERRORS.of(target), | 2082 BUILD_DIRECTIVES_ERRORS_INPUT: BUILD_DIRECTIVES_ERRORS.of(source), |
| 2072 BUILD_LIBRARY_ERRORS_INPUT: BUILD_LIBRARY_ERRORS.of(target), | 2083 BUILD_LIBRARY_ERRORS_INPUT: BUILD_LIBRARY_ERRORS.of(source), |
| 2073 PARSE_ERRORS_INPUT: PARSE_ERRORS.of(target), | 2084 PARSE_ERRORS_INPUT: PARSE_ERRORS.of(source), |
| 2074 SCAN_ERRORS_INPUT: SCAN_ERRORS.of(target), | 2085 SCAN_ERRORS_INPUT: SCAN_ERRORS.of(source), |
| 2075 LIBRARY_UNIT_ERRORS_INPUT: CONTAINING_LIBRARIES | 2086 LIBRARY_UNIT_ERRORS_INPUT: CONTAINING_LIBRARIES |
| 2076 .of(target) | 2087 .of(source) |
| 2077 .toMap((Source library) { | 2088 .toMap((Source library) { |
| 2078 LibrarySpecificUnit unit = new LibrarySpecificUnit(library, target); | 2089 LibrarySpecificUnit unit = new LibrarySpecificUnit(library, source); |
| 2079 return LIBRARY_UNIT_ERRORS.of(unit); | 2090 return LIBRARY_UNIT_ERRORS.of(unit); |
| 2080 }) | 2091 }) |
| 2081 }; | 2092 }; |
| 2082 } | 2093 } |
| 2083 | 2094 |
| 2084 /** | 2095 /** |
| 2085 * Create a [DartErrorsTask] based on the given [target] in the given | 2096 * Create a [DartErrorsTask] based on the given [target] in the given |
| 2086 * [context]. | 2097 * [context]. |
| 2087 */ | 2098 */ |
| 2088 static DartErrorsTask createTask( | 2099 static DartErrorsTask createTask( |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2124 // all constants are evaluated before this method is called. | 2135 // all constants are evaluated before this method is called. |
| 2125 CompilationUnit unit = getRequiredInput(UNIT_INPUT); | 2136 CompilationUnit unit = getRequiredInput(UNIT_INPUT); |
| 2126 outputs[RESOLVED_UNIT] = unit; | 2137 outputs[RESOLVED_UNIT] = unit; |
| 2127 } | 2138 } |
| 2128 | 2139 |
| 2129 /** | 2140 /** |
| 2130 * Return a map from the names of the inputs of this kind of task to the task | 2141 * Return a map from the names of the inputs of this kind of task to the task |
| 2131 * input descriptors describing those inputs for a task with the | 2142 * input descriptors describing those inputs for a task with the |
| 2132 * given [target]. | 2143 * given [target]. |
| 2133 */ | 2144 */ |
| 2134 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { | 2145 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 2146 LibrarySpecificUnit unit = target; |
| 2135 return <String, TaskInput>{ | 2147 return <String, TaskInput>{ |
| 2136 'libraryElement': LIBRARY_ELEMENT.of(target.library), | 2148 'libraryElement': LIBRARY_ELEMENT.of(unit.library), |
| 2137 UNIT_INPUT: RESOLVED_UNIT6.of(target), | 2149 UNIT_INPUT: RESOLVED_UNIT6.of(unit), |
| 2138 CONSTANT_VALUES: | 2150 CONSTANT_VALUES: |
| 2139 COMPILATION_UNIT_CONSTANTS.of(target).toListOf(CONSTANT_VALUE) | 2151 COMPILATION_UNIT_CONSTANTS.of(unit).toListOf(CONSTANT_VALUE) |
| 2140 }; | 2152 }; |
| 2141 } | 2153 } |
| 2142 | 2154 |
| 2143 /** | 2155 /** |
| 2144 * Create an [EvaluateUnitConstantsTask] based on the given [target] in | 2156 * Create an [EvaluateUnitConstantsTask] based on the given [target] in |
| 2145 * the given [context]. | 2157 * the given [context]. |
| 2146 */ | 2158 */ |
| 2147 static EvaluateUnitConstantsTask createTask( | 2159 static EvaluateUnitConstantsTask createTask( |
| 2148 AnalysisContext context, LibrarySpecificUnit target) { | 2160 AnalysisContext context, AnalysisTarget target) { |
| 2149 return new EvaluateUnitConstantsTask(context, target); | 2161 return new EvaluateUnitConstantsTask(context, target); |
| 2150 } | 2162 } |
| 2151 } | 2163 } |
| 2152 | 2164 |
| 2153 /** | 2165 /** |
| 2154 * The helper for building the export [Namespace] of a [LibraryElement]. | 2166 * The helper for building the export [Namespace] of a [LibraryElement]. |
| 2155 */ | 2167 */ |
| 2156 class ExportNamespaceBuilder { | 2168 class ExportNamespaceBuilder { |
| 2157 /** | 2169 /** |
| 2158 * Build the export [Namespace] of the given [LibraryElement]. | 2170 * Build the export [Namespace] of the given [LibraryElement]. |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2291 // Record outputs. | 2303 // Record outputs. |
| 2292 // | 2304 // |
| 2293 outputs[USED_IMPORTED_ELEMENTS] = visitor.usedElements; | 2305 outputs[USED_IMPORTED_ELEMENTS] = visitor.usedElements; |
| 2294 } | 2306 } |
| 2295 | 2307 |
| 2296 /** | 2308 /** |
| 2297 * Return a map from the names of the inputs of this kind of task to the task | 2309 * Return a map from the names of the inputs of this kind of task to the task |
| 2298 * input descriptors describing those inputs for a task with the | 2310 * input descriptors describing those inputs for a task with the |
| 2299 * given [target]. | 2311 * given [target]. |
| 2300 */ | 2312 */ |
| 2301 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { | 2313 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 2302 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT6.of(target)}; | 2314 LibrarySpecificUnit unit = target; |
| 2315 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT6.of(unit)}; |
| 2303 } | 2316 } |
| 2304 | 2317 |
| 2305 /** | 2318 /** |
| 2306 * Create a [GatherUsedImportedElementsTask] based on the given [target] in | 2319 * Create a [GatherUsedImportedElementsTask] based on the given [target] in |
| 2307 * the given [context]. | 2320 * the given [context]. |
| 2308 */ | 2321 */ |
| 2309 static GatherUsedImportedElementsTask createTask( | 2322 static GatherUsedImportedElementsTask createTask( |
| 2310 AnalysisContext context, LibrarySpecificUnit target) { | 2323 AnalysisContext context, AnalysisTarget target) { |
| 2311 return new GatherUsedImportedElementsTask(context, target); | 2324 return new GatherUsedImportedElementsTask(context, target); |
| 2312 } | 2325 } |
| 2313 } | 2326 } |
| 2314 | 2327 |
| 2315 /** | 2328 /** |
| 2316 * A task that builds [USED_LOCAL_ELEMENTS] for a unit. | 2329 * A task that builds [USED_LOCAL_ELEMENTS] for a unit. |
| 2317 */ | 2330 */ |
| 2318 class GatherUsedLocalElementsTask extends SourceBasedAnalysisTask { | 2331 class GatherUsedLocalElementsTask extends SourceBasedAnalysisTask { |
| 2319 /** | 2332 /** |
| 2320 * The name of the [RESOLVED_UNIT6] input. | 2333 * The name of the [RESOLVED_UNIT6] input. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2350 // Record outputs. | 2363 // Record outputs. |
| 2351 // | 2364 // |
| 2352 outputs[USED_LOCAL_ELEMENTS] = visitor.usedElements; | 2365 outputs[USED_LOCAL_ELEMENTS] = visitor.usedElements; |
| 2353 } | 2366 } |
| 2354 | 2367 |
| 2355 /** | 2368 /** |
| 2356 * Return a map from the names of the inputs of this kind of task to the task | 2369 * Return a map from the names of the inputs of this kind of task to the task |
| 2357 * input descriptors describing those inputs for a task with the | 2370 * input descriptors describing those inputs for a task with the |
| 2358 * given [target]. | 2371 * given [target]. |
| 2359 */ | 2372 */ |
| 2360 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { | 2373 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 2361 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT6.of(target)}; | 2374 LibrarySpecificUnit unit = target; |
| 2375 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT6.of(unit)}; |
| 2362 } | 2376 } |
| 2363 | 2377 |
| 2364 /** | 2378 /** |
| 2365 * Create a [GatherUsedLocalElementsTask] based on the given [target] in | 2379 * Create a [GatherUsedLocalElementsTask] based on the given [target] in |
| 2366 * the given [context]. | 2380 * the given [context]. |
| 2367 */ | 2381 */ |
| 2368 static GatherUsedLocalElementsTask createTask( | 2382 static GatherUsedLocalElementsTask createTask( |
| 2369 AnalysisContext context, LibrarySpecificUnit target) { | 2383 AnalysisContext context, AnalysisTarget target) { |
| 2370 return new GatherUsedLocalElementsTask(context, target); | 2384 return new GatherUsedLocalElementsTask(context, target); |
| 2371 } | 2385 } |
| 2372 } | 2386 } |
| 2373 | 2387 |
| 2374 /** | 2388 /** |
| 2375 * A task that generates [HINTS] for a unit. | 2389 * A task that generates [HINTS] for a unit. |
| 2376 */ | 2390 */ |
| 2377 class GenerateHintsTask extends SourceBasedAnalysisTask { | 2391 class GenerateHintsTask extends SourceBasedAnalysisTask { |
| 2378 /** | 2392 /** |
| 2379 * The name of the [RESOLVED_UNIT6] input. | 2393 * The name of the [RESOLVED_UNIT6] input. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2466 // Record outputs. | 2480 // Record outputs. |
| 2467 // | 2481 // |
| 2468 outputs[HINTS] = errorListener.errors; | 2482 outputs[HINTS] = errorListener.errors; |
| 2469 } | 2483 } |
| 2470 | 2484 |
| 2471 /** | 2485 /** |
| 2472 * Return a map from the names of the inputs of this kind of task to the task | 2486 * Return a map from the names of the inputs of this kind of task to the task |
| 2473 * input descriptors describing those inputs for a task with the | 2487 * input descriptors describing those inputs for a task with the |
| 2474 * given [target]. | 2488 * given [target]. |
| 2475 */ | 2489 */ |
| 2476 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { | 2490 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 2477 Source libSource = target.library; | 2491 LibrarySpecificUnit unit = target; |
| 2492 Source libSource = unit.library; |
| 2478 return <String, TaskInput>{ | 2493 return <String, TaskInput>{ |
| 2479 RESOLVED_UNIT_INPUT: RESOLVED_UNIT.of(target), | 2494 RESOLVED_UNIT_INPUT: RESOLVED_UNIT.of(unit), |
| 2480 USED_LOCAL_ELEMENTS_INPUT: UNITS.of(libSource).toList((unit) { | 2495 USED_LOCAL_ELEMENTS_INPUT: UNITS.of(libSource).toList((unit) { |
| 2481 LibrarySpecificUnit target = new LibrarySpecificUnit(libSource, unit); | 2496 LibrarySpecificUnit target = new LibrarySpecificUnit(libSource, unit); |
| 2482 return USED_LOCAL_ELEMENTS.of(target); | 2497 return USED_LOCAL_ELEMENTS.of(target); |
| 2483 }), | 2498 }), |
| 2484 USED_IMPORTED_ELEMENTS_INPUT: UNITS.of(libSource).toList((unit) { | 2499 USED_IMPORTED_ELEMENTS_INPUT: UNITS.of(libSource).toList((unit) { |
| 2485 LibrarySpecificUnit target = new LibrarySpecificUnit(libSource, unit); | 2500 LibrarySpecificUnit target = new LibrarySpecificUnit(libSource, unit); |
| 2486 return USED_IMPORTED_ELEMENTS.of(target); | 2501 return USED_IMPORTED_ELEMENTS.of(target); |
| 2487 }), | 2502 }), |
| 2488 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) | 2503 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) |
| 2489 }; | 2504 }; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2520 @override | 2535 @override |
| 2521 void internalPerform() { | 2536 void internalPerform() { |
| 2522 outputs[LIBRARY_ERRORS_READY] = true; | 2537 outputs[LIBRARY_ERRORS_READY] = true; |
| 2523 } | 2538 } |
| 2524 | 2539 |
| 2525 /** | 2540 /** |
| 2526 * Return a map from the names of the inputs of this kind of task to the task | 2541 * Return a map from the names of the inputs of this kind of task to the task |
| 2527 * input descriptors describing those inputs for a task with the | 2542 * input descriptors describing those inputs for a task with the |
| 2528 * given [library]. | 2543 * given [library]. |
| 2529 */ | 2544 */ |
| 2530 static Map<String, TaskInput> buildInputs(Source library) { | 2545 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 2546 Source source = target; |
| 2531 return <String, TaskInput>{ | 2547 return <String, TaskInput>{ |
| 2532 'allErrors': UNITS.of(library).toListOf(DART_ERRORS) | 2548 'allErrors': UNITS.of(source).toListOf(DART_ERRORS) |
| 2533 }; | 2549 }; |
| 2534 } | 2550 } |
| 2535 | 2551 |
| 2536 /** | 2552 /** |
| 2537 * Create a [LibraryErrorsReadyTask] based on the given [target] in the given | 2553 * Create a [LibraryErrorsReadyTask] based on the given [target] in the given |
| 2538 * [context]. | 2554 * [context]. |
| 2539 */ | 2555 */ |
| 2540 static LibraryErrorsReadyTask createTask( | 2556 static LibraryErrorsReadyTask createTask( |
| 2541 AnalysisContext context, AnalysisTarget target) { | 2557 AnalysisContext context, AnalysisTarget target) { |
| 2542 return new LibraryErrorsReadyTask(context, target); | 2558 return new LibraryErrorsReadyTask(context, target); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2617 // Record outputs. | 2633 // Record outputs. |
| 2618 // | 2634 // |
| 2619 outputs[LIBRARY_UNIT_ERRORS] = AnalysisError.mergeLists(errorLists); | 2635 outputs[LIBRARY_UNIT_ERRORS] = AnalysisError.mergeLists(errorLists); |
| 2620 } | 2636 } |
| 2621 | 2637 |
| 2622 /** | 2638 /** |
| 2623 * Return a map from the names of the inputs of this kind of task to the task | 2639 * Return a map from the names of the inputs of this kind of task to the task |
| 2624 * input descriptors describing those inputs for a task with the | 2640 * input descriptors describing those inputs for a task with the |
| 2625 * given [unit]. | 2641 * given [unit]. |
| 2626 */ | 2642 */ |
| 2627 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit unit) { | 2643 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 2644 LibrarySpecificUnit unit = target; |
| 2628 return <String, TaskInput>{ | 2645 return <String, TaskInput>{ |
| 2629 BUILD_FUNCTION_TYPE_ALIASES_ERRORS_INPUT: | 2646 BUILD_FUNCTION_TYPE_ALIASES_ERRORS_INPUT: |
| 2630 BUILD_FUNCTION_TYPE_ALIASES_ERRORS.of(unit), | 2647 BUILD_FUNCTION_TYPE_ALIASES_ERRORS.of(unit), |
| 2631 CONSTRUCTORS_ERRORS_INPUT: COMPILATION_UNIT_ELEMENT | 2648 CONSTRUCTORS_ERRORS_INPUT: COMPILATION_UNIT_ELEMENT |
| 2632 .of(unit) | 2649 .of(unit) |
| 2633 .mappedToList((CompilationUnitElement element) => element.types) | 2650 .mappedToList((CompilationUnitElement element) => element.types) |
| 2634 .toListOf(CONSTRUCTORS_ERRORS), | 2651 .toListOf(CONSTRUCTORS_ERRORS), |
| 2635 HINTS_INPUT: HINTS.of(unit), | 2652 HINTS_INPUT: HINTS.of(unit), |
| 2636 RESOLVE_REFERENCES_ERRORS_INPUT: RESOLVE_REFERENCES_ERRORS.of(unit), | 2653 RESOLVE_REFERENCES_ERRORS_INPUT: RESOLVE_REFERENCES_ERRORS.of(unit), |
| 2637 RESOLVE_TYPE_NAMES_ERRORS_INPUT: RESOLVE_TYPE_NAMES_ERRORS.of(unit), | 2654 RESOLVE_TYPE_NAMES_ERRORS_INPUT: RESOLVE_TYPE_NAMES_ERRORS.of(unit), |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2693 ParseDartTask(InternalAnalysisContext context, AnalysisTarget target) | 2710 ParseDartTask(InternalAnalysisContext context, AnalysisTarget target) |
| 2694 : super(context, target); | 2711 : super(context, target); |
| 2695 | 2712 |
| 2696 @override | 2713 @override |
| 2697 TaskDescriptor get descriptor => DESCRIPTOR; | 2714 TaskDescriptor get descriptor => DESCRIPTOR; |
| 2698 | 2715 |
| 2699 @override | 2716 @override |
| 2700 void internalPerform() { | 2717 void internalPerform() { |
| 2701 Source source = getRequiredSource(); | 2718 Source source = getRequiredSource(); |
| 2702 LineInfo lineInfo = getRequiredInput(LINE_INFO_INPUT_NAME); | 2719 LineInfo lineInfo = getRequiredInput(LINE_INFO_INPUT_NAME); |
| 2703 int modificationTime = getRequiredInput(MODIFICATION_TIME_INPUT_NAME); | |
| 2704 Token tokenStream = getRequiredInput(TOKEN_STREAM_INPUT_NAME); | 2720 Token tokenStream = getRequiredInput(TOKEN_STREAM_INPUT_NAME); |
| 2705 | 2721 |
| 2706 RecordingErrorListener errorListener = new RecordingErrorListener(); | 2722 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 2707 Parser parser = new Parser(source, errorListener); | 2723 Parser parser = new Parser(source, errorListener); |
| 2708 AnalysisOptions options = context.analysisOptions; | 2724 AnalysisOptions options = context.analysisOptions; |
| 2709 parser.parseFunctionBodies = options.analyzeFunctionBodiesPredicate(source); | 2725 parser.parseFunctionBodies = options.analyzeFunctionBodiesPredicate(source); |
| 2710 CompilationUnit unit = parser.parseCompilationUnit(tokenStream); | 2726 CompilationUnit unit = parser.parseCompilationUnit(tokenStream); |
| 2711 unit.lineInfo = lineInfo; | 2727 unit.lineInfo = lineInfo; |
| 2712 | 2728 |
| 2713 bool hasNonPartOfDirective = false; | 2729 bool hasNonPartOfDirective = false; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2742 // Always include "dart:core" source. | 2758 // Always include "dart:core" source. |
| 2743 // | 2759 // |
| 2744 HashSet<Source> importedSourceSet = | 2760 HashSet<Source> importedSourceSet = |
| 2745 new HashSet.from(explicitlyImportedSourceSet); | 2761 new HashSet.from(explicitlyImportedSourceSet); |
| 2746 Source coreLibrarySource = context.sourceFactory.forUri(DartSdk.DART_CORE); | 2762 Source coreLibrarySource = context.sourceFactory.forUri(DartSdk.DART_CORE); |
| 2747 importedSourceSet.add(coreLibrarySource); | 2763 importedSourceSet.add(coreLibrarySource); |
| 2748 // | 2764 // |
| 2749 // Compute kind. | 2765 // Compute kind. |
| 2750 // | 2766 // |
| 2751 SourceKind sourceKind = SourceKind.LIBRARY; | 2767 SourceKind sourceKind = SourceKind.LIBRARY; |
| 2752 if (modificationTime == -1) { | 2768 if (hasPartOfDirective && !hasNonPartOfDirective) { |
| 2753 sourceKind = SourceKind.UNKNOWN; | |
| 2754 } else if (hasPartOfDirective && !hasNonPartOfDirective) { | |
| 2755 sourceKind = SourceKind.PART; | 2769 sourceKind = SourceKind.PART; |
| 2756 } | 2770 } |
| 2757 // | 2771 // |
| 2758 // Record outputs. | 2772 // Record outputs. |
| 2759 // | 2773 // |
| 2760 List<Source> explicitlyImportedSources = | 2774 List<Source> explicitlyImportedSources = |
| 2761 explicitlyImportedSourceSet.toList(); | 2775 explicitlyImportedSourceSet.toList(); |
| 2762 List<Source> exportedSources = exportedSourceSet.toList(); | 2776 List<Source> exportedSources = exportedSourceSet.toList(); |
| 2763 List<Source> importedSources = importedSourceSet.toList(); | 2777 List<Source> importedSources = importedSourceSet.toList(); |
| 2764 List<Source> includedSources = includedSourceSet.toList(); | 2778 List<Source> includedSources = includedSourceSet.toList(); |
| 2765 List<AnalysisError> parseErrors = | 2779 List<AnalysisError> parseErrors = |
| 2766 removeDuplicateErrors(errorListener.errors); | 2780 removeDuplicateErrors(errorListener.errors); |
| 2767 List<Source> unitSources = <Source>[source]..addAll(includedSourceSet); | 2781 List<Source> unitSources = <Source>[source]..addAll(includedSourceSet); |
| 2768 outputs[EXPLICITLY_IMPORTED_LIBRARIES] = explicitlyImportedSources; | 2782 outputs[EXPLICITLY_IMPORTED_LIBRARIES] = explicitlyImportedSources; |
| 2769 outputs[EXPORTED_LIBRARIES] = exportedSources; | 2783 outputs[EXPORTED_LIBRARIES] = exportedSources; |
| 2770 outputs[IMPORTED_LIBRARIES] = importedSources; | 2784 outputs[IMPORTED_LIBRARIES] = importedSources; |
| 2771 outputs[INCLUDED_PARTS] = includedSources; | 2785 outputs[INCLUDED_PARTS] = includedSources; |
| 2772 outputs[PARSE_ERRORS] = parseErrors; | 2786 outputs[PARSE_ERRORS] = parseErrors; |
| 2773 outputs[PARSED_UNIT] = unit; | 2787 outputs[PARSED_UNIT] = unit; |
| 2774 outputs[SOURCE_KIND] = sourceKind; | 2788 outputs[SOURCE_KIND] = sourceKind; |
| 2775 outputs[UNITS] = unitSources; | 2789 outputs[UNITS] = unitSources; |
| 2776 } | 2790 } |
| 2777 | 2791 |
| 2778 /** | 2792 /** |
| 2779 * Return a map from the names of the inputs of this kind of task to the task | 2793 * Return a map from the names of the inputs of this kind of task to the task |
| 2780 * input descriptors describing those inputs for a task with the given | 2794 * input descriptors describing those inputs for a task with the given |
| 2781 * [source]. | 2795 * [source]. |
| 2782 */ | 2796 */ |
| 2783 static Map<String, TaskInput> buildInputs(Source source) { | 2797 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 2784 return <String, TaskInput>{ | 2798 return <String, TaskInput>{ |
| 2785 LINE_INFO_INPUT_NAME: LINE_INFO.of(source), | 2799 LINE_INFO_INPUT_NAME: LINE_INFO.of(target), |
| 2786 MODIFICATION_TIME_INPUT_NAME: MODIFICATION_TIME.of(source), | 2800 TOKEN_STREAM_INPUT_NAME: TOKEN_STREAM.of(target) |
| 2787 TOKEN_STREAM_INPUT_NAME: TOKEN_STREAM.of(source) | |
| 2788 }; | 2801 }; |
| 2789 } | 2802 } |
| 2790 | 2803 |
| 2791 /** | 2804 /** |
| 2792 * Create a [ParseDartTask] based on the given [target] in the given | 2805 * Create a [ParseDartTask] based on the given [target] in the given |
| 2793 * [context]. | 2806 * [context]. |
| 2794 */ | 2807 */ |
| 2795 static ParseDartTask createTask( | 2808 static ParseDartTask createTask( |
| 2796 AnalysisContext context, AnalysisTarget target) { | 2809 AnalysisContext context, AnalysisTarget target) { |
| 2797 return new ParseDartTask(context, target); | 2810 return new ParseDartTask(context, target); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2904 void internalPerform() { | 2917 void internalPerform() { |
| 2905 LibraryElement library = getRequiredInput(LIBRARY_INPUT); | 2918 LibraryElement library = getRequiredInput(LIBRARY_INPUT); |
| 2906 outputs[LIBRARY_ELEMENT] = library; | 2919 outputs[LIBRARY_ELEMENT] = library; |
| 2907 } | 2920 } |
| 2908 | 2921 |
| 2909 /** | 2922 /** |
| 2910 * Return a map from the names of the inputs of this kind of task to the task | 2923 * Return a map from the names of the inputs of this kind of task to the task |
| 2911 * input descriptors describing those inputs for a task with the | 2924 * input descriptors describing those inputs for a task with the |
| 2912 * given [target]. | 2925 * given [target]. |
| 2913 */ | 2926 */ |
| 2914 static Map<String, TaskInput> buildInputs(Source libSource) { | 2927 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 2928 Source source = target; |
| 2915 return <String, TaskInput>{ | 2929 return <String, TaskInput>{ |
| 2916 LIBRARY_INPUT: LIBRARY_ELEMENT6.of(libSource), | 2930 LIBRARY_INPUT: LIBRARY_ELEMENT6.of(source), |
| 2917 'resolvedUnits': IMPORT_EXPORT_SOURCE_CLOSURE | 2931 'resolvedUnits': IMPORT_EXPORT_SOURCE_CLOSURE |
| 2918 .of(libSource) | 2932 .of(source) |
| 2919 .toMapOf(UNITS) | 2933 .toMapOf(UNITS) |
| 2920 .toFlattenList((Source library, Source unit) => | 2934 .toFlattenList((Source library, Source unit) => |
| 2921 RESOLVED_UNIT6.of(new LibrarySpecificUnit(library, unit))), | 2935 RESOLVED_UNIT6.of(new LibrarySpecificUnit(library, unit))), |
| 2922 }; | 2936 }; |
| 2923 } | 2937 } |
| 2924 | 2938 |
| 2925 /** | 2939 /** |
| 2926 * Create a [ResolveLibraryReferencesTask] based on the given [target] in | 2940 * Create a [ResolveLibraryReferencesTask] based on the given [target] in |
| 2927 * the given [context]. | 2941 * the given [context]. |
| 2928 */ | 2942 */ |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2960 void internalPerform() { | 2974 void internalPerform() { |
| 2961 LibraryElement library = getRequiredInput(LIBRARY_INPUT); | 2975 LibraryElement library = getRequiredInput(LIBRARY_INPUT); |
| 2962 outputs[LIBRARY_ELEMENT5] = library; | 2976 outputs[LIBRARY_ELEMENT5] = library; |
| 2963 } | 2977 } |
| 2964 | 2978 |
| 2965 /** | 2979 /** |
| 2966 * Return a map from the names of the inputs of this kind of task to the task | 2980 * Return a map from the names of the inputs of this kind of task to the task |
| 2967 * input descriptors describing those inputs for a task with the | 2981 * input descriptors describing those inputs for a task with the |
| 2968 * given [target]. | 2982 * given [target]. |
| 2969 */ | 2983 */ |
| 2970 static Map<String, TaskInput> buildInputs(Source libSource) { | 2984 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 2985 Source source = target; |
| 2971 return <String, TaskInput>{ | 2986 return <String, TaskInput>{ |
| 2972 LIBRARY_INPUT: LIBRARY_ELEMENT4.of(libSource), | 2987 LIBRARY_INPUT: LIBRARY_ELEMENT4.of(source), |
| 2973 'resolvedUnits': IMPORT_EXPORT_SOURCE_CLOSURE | 2988 'resolvedUnits': IMPORT_EXPORT_SOURCE_CLOSURE |
| 2974 .of(libSource) | 2989 .of(source) |
| 2975 .toMapOf(UNITS) | 2990 .toMapOf(UNITS) |
| 2976 .toFlattenList((Source library, Source unit) => | 2991 .toFlattenList((Source library, Source unit) => |
| 2977 RESOLVED_UNIT4.of(new LibrarySpecificUnit(library, unit))), | 2992 RESOLVED_UNIT4.of(new LibrarySpecificUnit(library, unit))), |
| 2978 }; | 2993 }; |
| 2979 } | 2994 } |
| 2980 | 2995 |
| 2981 /** | 2996 /** |
| 2982 * Create a [ResolveLibraryTypeNamesTask] based on the given [target] in | 2997 * Create a [ResolveLibraryTypeNamesTask] based on the given [target] in |
| 2983 * the given [context]. | 2998 * the given [context]. |
| 2984 */ | 2999 */ |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3047 outputs[RESOLVE_REFERENCES_ERRORS] = | 3062 outputs[RESOLVE_REFERENCES_ERRORS] = |
| 3048 removeDuplicateErrors(errorListener.errors); | 3063 removeDuplicateErrors(errorListener.errors); |
| 3049 outputs[RESOLVED_UNIT6] = unit; | 3064 outputs[RESOLVED_UNIT6] = unit; |
| 3050 } | 3065 } |
| 3051 | 3066 |
| 3052 /** | 3067 /** |
| 3053 * Return a map from the names of the inputs of this kind of task to the task | 3068 * Return a map from the names of the inputs of this kind of task to the task |
| 3054 * input descriptors describing those inputs for a task with the | 3069 * input descriptors describing those inputs for a task with the |
| 3055 * given [target]. | 3070 * given [target]. |
| 3056 */ | 3071 */ |
| 3057 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { | 3072 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 3073 LibrarySpecificUnit unit = target; |
| 3058 return <String, TaskInput>{ | 3074 return <String, TaskInput>{ |
| 3059 LIBRARY_INPUT: LIBRARY_ELEMENT6.of(target.library), | 3075 LIBRARY_INPUT: LIBRARY_ELEMENT6.of(unit.library), |
| 3060 UNIT_INPUT: RESOLVED_UNIT5.of(target), | 3076 UNIT_INPUT: RESOLVED_UNIT5.of(unit), |
| 3061 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) | 3077 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) |
| 3062 }; | 3078 }; |
| 3063 } | 3079 } |
| 3064 | 3080 |
| 3065 /** | 3081 /** |
| 3066 * Create a [ResolveUnitReferencesTask] based on the given [target] in | 3082 * Create a [ResolveUnitReferencesTask] based on the given [target] in |
| 3067 * the given [context]. | 3083 * the given [context]. |
| 3068 */ | 3084 */ |
| 3069 static ResolveUnitReferencesTask createTask( | 3085 static ResolveUnitReferencesTask createTask( |
| 3070 AnalysisContext context, AnalysisTarget target) { | 3086 AnalysisContext context, AnalysisTarget target) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3129 outputs[RESOLVE_TYPE_NAMES_ERRORS] = | 3145 outputs[RESOLVE_TYPE_NAMES_ERRORS] = |
| 3130 removeDuplicateErrors(errorListener.errors); | 3146 removeDuplicateErrors(errorListener.errors); |
| 3131 outputs[RESOLVED_UNIT4] = unit; | 3147 outputs[RESOLVED_UNIT4] = unit; |
| 3132 } | 3148 } |
| 3133 | 3149 |
| 3134 /** | 3150 /** |
| 3135 * Return a map from the names of the inputs of this kind of task to the task | 3151 * Return a map from the names of the inputs of this kind of task to the task |
| 3136 * input descriptors describing those inputs for a task with the | 3152 * input descriptors describing those inputs for a task with the |
| 3137 * given [target]. | 3153 * given [target]. |
| 3138 */ | 3154 */ |
| 3139 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { | 3155 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 3156 LibrarySpecificUnit unit = target; |
| 3140 return <String, TaskInput>{ | 3157 return <String, TaskInput>{ |
| 3141 LIBRARY_INPUT: LIBRARY_ELEMENT4.of(target.library), | 3158 LIBRARY_INPUT: LIBRARY_ELEMENT4.of(unit.library), |
| 3142 UNIT_INPUT: RESOLVED_UNIT3.of(target), | 3159 UNIT_INPUT: RESOLVED_UNIT3.of(unit), |
| 3143 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) | 3160 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) |
| 3144 }; | 3161 }; |
| 3145 } | 3162 } |
| 3146 | 3163 |
| 3147 /** | 3164 /** |
| 3148 * Create a [ResolveUnitTypeNamesTask] based on the given [target] in | 3165 * Create a [ResolveUnitTypeNamesTask] based on the given [target] in |
| 3149 * the given [context]. | 3166 * the given [context]. |
| 3150 */ | 3167 */ |
| 3151 static ResolveUnitTypeNamesTask createTask( | 3168 static ResolveUnitTypeNamesTask createTask( |
| 3152 AnalysisContext context, AnalysisTarget target) { | 3169 AnalysisContext context, AnalysisTarget target) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3210 outputs[RESOLVED_UNIT5] = unit; | 3227 outputs[RESOLVED_UNIT5] = unit; |
| 3211 outputs[VARIABLE_REFERENCE_ERRORS] = | 3228 outputs[VARIABLE_REFERENCE_ERRORS] = |
| 3212 removeDuplicateErrors(errorListener.errors); | 3229 removeDuplicateErrors(errorListener.errors); |
| 3213 } | 3230 } |
| 3214 | 3231 |
| 3215 /** | 3232 /** |
| 3216 * Return a map from the names of the inputs of this kind of task to the task | 3233 * Return a map from the names of the inputs of this kind of task to the task |
| 3217 * input descriptors describing those inputs for a task with the | 3234 * input descriptors describing those inputs for a task with the |
| 3218 * given [target]. | 3235 * given [target]. |
| 3219 */ | 3236 */ |
| 3220 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { | 3237 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 3238 LibrarySpecificUnit unit = target; |
| 3221 return <String, TaskInput>{ | 3239 return <String, TaskInput>{ |
| 3222 'fullyBuiltLibraryElements': IMPORT_EXPORT_SOURCE_CLOSURE | 3240 'fullyBuiltLibraryElements': IMPORT_EXPORT_SOURCE_CLOSURE |
| 3223 .of(target.library) | 3241 .of(unit.library) |
| 3224 .toListOf(LIBRARY_ELEMENT6), | 3242 .toListOf(LIBRARY_ELEMENT6), |
| 3225 LIBRARY_INPUT: LIBRARY_ELEMENT6.of(target.library), | 3243 LIBRARY_INPUT: LIBRARY_ELEMENT6.of(unit.library), |
| 3226 UNIT_INPUT: RESOLVED_UNIT4.of(target), | 3244 UNIT_INPUT: RESOLVED_UNIT4.of(unit), |
| 3227 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) | 3245 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) |
| 3228 }; | 3246 }; |
| 3229 } | 3247 } |
| 3230 | 3248 |
| 3231 /** | 3249 /** |
| 3232 * Create a [ResolveVariableReferencesTask] based on the given [target] in | 3250 * Create a [ResolveVariableReferencesTask] based on the given [target] in |
| 3233 * the given [context]. | 3251 * the given [context]. |
| 3234 */ | 3252 */ |
| 3235 static ResolveVariableReferencesTask createTask( | 3253 static ResolveVariableReferencesTask createTask( |
| 3236 AnalysisContext context, AnalysisTarget target) { | 3254 AnalysisContext context, AnalysisTarget target) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 3263 */ | 3281 */ |
| 3264 ScanDartTask(InternalAnalysisContext context, AnalysisTarget target) | 3282 ScanDartTask(InternalAnalysisContext context, AnalysisTarget target) |
| 3265 : super(context, target); | 3283 : super(context, target); |
| 3266 | 3284 |
| 3267 @override | 3285 @override |
| 3268 TaskDescriptor get descriptor => DESCRIPTOR; | 3286 TaskDescriptor get descriptor => DESCRIPTOR; |
| 3269 | 3287 |
| 3270 @override | 3288 @override |
| 3271 void internalPerform() { | 3289 void internalPerform() { |
| 3272 Source source = getRequiredSource(); | 3290 Source source = getRequiredSource(); |
| 3273 String content = getRequiredInput(CONTENT_INPUT_NAME); | 3291 if (target is DartScript) { |
| 3292 DartScript script = target; |
| 3293 List<ScriptFragment> fragments = script.fragments; |
| 3294 if (fragments.length < 1) { |
| 3295 throw new AnalysisException('Cannot scan scripts with no fragments'); |
| 3296 } else if (fragments.length > 1) { |
| 3297 throw new AnalysisException( |
| 3298 'Cannot scan scripts with multiple fragments'); |
| 3299 } |
| 3300 ScriptFragment fragment = fragments[0]; |
| 3274 | 3301 |
| 3275 RecordingErrorListener errorListener = new RecordingErrorListener(); | 3302 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 3276 Scanner scanner = | 3303 Scanner scanner = new Scanner(source, |
| 3277 new Scanner(source, new CharSequenceReader(content), errorListener); | 3304 new SubSequenceReader(fragment.content, fragment.offset), |
| 3278 scanner.preserveComments = context.analysisOptions.preserveComments; | 3305 errorListener); |
| 3279 scanner.enableNullAwareOperators = | 3306 scanner.setSourceStart(fragment.line, fragment.column); |
| 3280 context.analysisOptions.enableNullAwareOperators; | 3307 scanner.preserveComments = context.analysisOptions.preserveComments; |
| 3308 scanner.enableNullAwareOperators = |
| 3309 context.analysisOptions.enableNullAwareOperators; |
| 3281 | 3310 |
| 3282 outputs[TOKEN_STREAM] = scanner.tokenize(); | 3311 outputs[TOKEN_STREAM] = scanner.tokenize(); |
| 3283 outputs[LINE_INFO] = new LineInfo(scanner.lineStarts); | 3312 outputs[LINE_INFO] = new LineInfo(scanner.lineStarts); |
| 3284 outputs[SCAN_ERRORS] = removeDuplicateErrors(errorListener.errors); | 3313 outputs[SCAN_ERRORS] = removeDuplicateErrors(errorListener.errors); |
| 3314 } else if (target is Source) { |
| 3315 String content = getRequiredInput(CONTENT_INPUT_NAME); |
| 3316 |
| 3317 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 3318 Scanner scanner = |
| 3319 new Scanner(source, new CharSequenceReader(content), errorListener); |
| 3320 scanner.preserveComments = context.analysisOptions.preserveComments; |
| 3321 scanner.enableNullAwareOperators = |
| 3322 context.analysisOptions.enableNullAwareOperators; |
| 3323 |
| 3324 outputs[TOKEN_STREAM] = scanner.tokenize(); |
| 3325 outputs[LINE_INFO] = new LineInfo(scanner.lineStarts); |
| 3326 outputs[SCAN_ERRORS] = removeDuplicateErrors(errorListener.errors); |
| 3327 } else { |
| 3328 throw new AnalysisException( |
| 3329 'Cannot scan Dart code from a ${target.runtimeType}'); |
| 3330 } |
| 3285 } | 3331 } |
| 3286 | 3332 |
| 3287 /** | 3333 /** |
| 3288 * Return a map from the names of the inputs of this kind of task to the task | 3334 * Return a map from the names of the inputs of this kind of task to the task |
| 3289 * input descriptors describing those inputs for a task with the given | 3335 * input descriptors describing those inputs for a task with the given |
| 3290 * [source]. | 3336 * [source]. |
| 3291 */ | 3337 */ |
| 3292 static Map<String, TaskInput> buildInputs(Source source) { | 3338 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 3293 return <String, TaskInput>{CONTENT_INPUT_NAME: CONTENT.of(source)}; | 3339 if (target is Source) { |
| 3340 return <String, TaskInput>{CONTENT_INPUT_NAME: CONTENT.of(target)}; |
| 3341 } else if (target is DartScript) { |
| 3342 // This task does not use the following input; it is included only to add |
| 3343 // a dependency between this value and the containing source so that when |
| 3344 // the containing source is modified these results will be invalidated. |
| 3345 return <String, TaskInput>{'-': DART_SCRIPTS.of(target.source)}; |
| 3346 } |
| 3347 throw new AnalysisException( |
| 3348 'Cannot build inputs for a ${target.runtimeType}'); |
| 3294 } | 3349 } |
| 3295 | 3350 |
| 3296 /** | 3351 /** |
| 3297 * Create a [ScanDartTask] based on the given [target] in the given [context]. | 3352 * Create a [ScanDartTask] based on the given [target] in the given [context]. |
| 3298 */ | 3353 */ |
| 3299 static ScanDartTask createTask( | 3354 static ScanDartTask createTask( |
| 3300 AnalysisContext context, AnalysisTarget target) { | 3355 AnalysisContext context, AnalysisTarget target) { |
| 3301 return new ScanDartTask(context, target); | 3356 return new ScanDartTask(context, target); |
| 3302 } | 3357 } |
| 3303 } | 3358 } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3398 StringLiteral uriLiteral = directive.uri; | 3453 StringLiteral uriLiteral = directive.uri; |
| 3399 errorReporter.reportErrorForNode(CompileTimeErrorCode.URI_DOES_NOT_EXIST, | 3454 errorReporter.reportErrorForNode(CompileTimeErrorCode.URI_DOES_NOT_EXIST, |
| 3400 uriLiteral, [directive.uriContent]); | 3455 uriLiteral, [directive.uriContent]); |
| 3401 } | 3456 } |
| 3402 | 3457 |
| 3403 /** | 3458 /** |
| 3404 * Return a map from the names of the inputs of this kind of task to the task | 3459 * Return a map from the names of the inputs of this kind of task to the task |
| 3405 * input descriptors describing those inputs for a task with the | 3460 * input descriptors describing those inputs for a task with the |
| 3406 * given [target]. | 3461 * given [target]. |
| 3407 */ | 3462 */ |
| 3408 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { | 3463 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 3464 LibrarySpecificUnit unit = target; |
| 3409 return <String, TaskInput>{ | 3465 return <String, TaskInput>{ |
| 3410 'resolvedUnits': IMPORT_EXPORT_SOURCE_CLOSURE | 3466 'resolvedUnits': IMPORT_EXPORT_SOURCE_CLOSURE |
| 3411 .of(target.library) | 3467 .of(unit.library) |
| 3412 .toMapOf(UNITS) | 3468 .toMapOf(UNITS) |
| 3413 .toFlattenList((Source library, Source unit) => | 3469 .toFlattenList((Source library, Source unit) => |
| 3414 RESOLVED_UNIT.of(new LibrarySpecificUnit(library, unit))), | 3470 RESOLVED_UNIT.of(new LibrarySpecificUnit(library, unit))), |
| 3415 UNIT_INPUT: RESOLVED_UNIT.of(target), | 3471 UNIT_INPUT: RESOLVED_UNIT.of(unit), |
| 3416 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) | 3472 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) |
| 3417 }; | 3473 }; |
| 3418 } | 3474 } |
| 3419 | 3475 |
| 3420 /** | 3476 /** |
| 3421 * Create a [VerifyUnitTask] based on the given [target] in | 3477 * Create a [VerifyUnitTask] based on the given [target] in |
| 3422 * the given [context]. | 3478 * the given [context]. |
| 3423 */ | 3479 */ |
| 3424 static VerifyUnitTask createTask( | 3480 static VerifyUnitTask createTask( |
| 3425 AnalysisContext context, AnalysisTarget target) { | 3481 AnalysisContext context, AnalysisTarget target) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3527 @override | 3583 @override |
| 3528 bool moveNext() { | 3584 bool moveNext() { |
| 3529 if (_newSources.isEmpty) { | 3585 if (_newSources.isEmpty) { |
| 3530 return false; | 3586 return false; |
| 3531 } | 3587 } |
| 3532 currentTarget = _newSources.first; | 3588 currentTarget = _newSources.first; |
| 3533 _newSources.remove(currentTarget); | 3589 _newSources.remove(currentTarget); |
| 3534 return true; | 3590 return true; |
| 3535 } | 3591 } |
| 3536 } | 3592 } |
| OLD | NEW |