| 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 test.src.task.dart_test; | 5 library test.src.task.dart_test; |
| 6 | 6 |
| 7 import 'package:analyzer/file_system/file_system.dart'; | 7 import 'package:analyzer/file_system/file_system.dart'; |
| 8 import 'package:analyzer/file_system/memory_file_system.dart'; | 8 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 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 24 matching lines...) Expand all Loading... |
| 35 runReflectiveTests(BuildCompilationUnitElementTaskTest); | 35 runReflectiveTests(BuildCompilationUnitElementTaskTest); |
| 36 runReflectiveTests(BuildDirectiveElementsTaskTest); | 36 runReflectiveTests(BuildDirectiveElementsTaskTest); |
| 37 runReflectiveTests(BuildEnumMemberElementsTaskTest); | 37 runReflectiveTests(BuildEnumMemberElementsTaskTest); |
| 38 runReflectiveTests(BuildSourceClosuresTaskTest); | 38 runReflectiveTests(BuildSourceClosuresTaskTest); |
| 39 runReflectiveTests(BuildExportNamespaceTaskTest); | 39 runReflectiveTests(BuildExportNamespaceTaskTest); |
| 40 runReflectiveTests(BuildFunctionTypeAliasesTaskTest); | 40 runReflectiveTests(BuildFunctionTypeAliasesTaskTest); |
| 41 runReflectiveTests(BuildLibraryConstructorsTaskTest); | 41 runReflectiveTests(BuildLibraryConstructorsTaskTest); |
| 42 runReflectiveTests(BuildLibraryElementTaskTest); | 42 runReflectiveTests(BuildLibraryElementTaskTest); |
| 43 runReflectiveTests(BuildPublicNamespaceTaskTest); | 43 runReflectiveTests(BuildPublicNamespaceTaskTest); |
| 44 runReflectiveTests(BuildTypeProviderTaskTest); | 44 runReflectiveTests(BuildTypeProviderTaskTest); |
| 45 runReflectiveTests(GatherUsedElementsTaskTest); |
| 45 runReflectiveTests(GenerateHintsTaskTest); | 46 runReflectiveTests(GenerateHintsTaskTest); |
| 46 runReflectiveTests(ParseDartTaskTest); | 47 runReflectiveTests(ParseDartTaskTest); |
| 47 runReflectiveTests(ResolveUnitTypeNamesTaskTest); | 48 runReflectiveTests(ResolveUnitTypeNamesTaskTest); |
| 48 runReflectiveTests(ResolveLibraryTypeNamesTaskTest); | 49 runReflectiveTests(ResolveLibraryTypeNamesTaskTest); |
| 49 runReflectiveTests(ResolveReferencesTaskTest); | 50 runReflectiveTests(ResolveReferencesTaskTest); |
| 50 runReflectiveTests(ResolveVariableReferencesTaskTest); | 51 runReflectiveTests(ResolveVariableReferencesTaskTest); |
| 51 runReflectiveTests(ScanDartTaskTest); | 52 runReflectiveTests(ScanDartTaskTest); |
| 52 runReflectiveTests(VerifyUnitTaskTest); | 53 runReflectiveTests(VerifyUnitTaskTest); |
| 53 } | 54 } |
| 54 | 55 |
| (...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1115 // validate | 1116 // validate |
| 1116 TypeProvider typeProvider = outputs[TYPE_PROVIDER]; | 1117 TypeProvider typeProvider = outputs[TYPE_PROVIDER]; |
| 1117 expect(typeProvider, isNotNull); | 1118 expect(typeProvider, isNotNull); |
| 1118 expect(typeProvider.boolType, isNotNull); | 1119 expect(typeProvider.boolType, isNotNull); |
| 1119 expect(typeProvider.intType, isNotNull); | 1120 expect(typeProvider.intType, isNotNull); |
| 1120 expect(typeProvider.futureType, isNotNull); | 1121 expect(typeProvider.futureType, isNotNull); |
| 1121 } | 1122 } |
| 1122 } | 1123 } |
| 1123 | 1124 |
| 1124 @reflectiveTest | 1125 @reflectiveTest |
| 1126 class GatherUsedElementsTaskTest extends _AbstractDartTaskTest { |
| 1127 UsedElements usedElements; |
| 1128 Set<String> usedElementNames; |
| 1129 |
| 1130 test_perform_localVariable() { |
| 1131 Source source = _newSource('/test.dart', r''' |
| 1132 main() { |
| 1133 var v1 = 1; |
| 1134 var v2 = 2; |
| 1135 print(v2); |
| 1136 }'''); |
| 1137 _computeUsedElements(source); |
| 1138 // validate |
| 1139 expect(usedElementNames, unorderedEquals(['v2'])); |
| 1140 } |
| 1141 |
| 1142 test_perform_method() { |
| 1143 Source source = _newSource('/test.dart', r''' |
| 1144 class A { |
| 1145 _m1() {} |
| 1146 _m2() {} |
| 1147 } |
| 1148 |
| 1149 main(A a, p) { |
| 1150 a._m2(); |
| 1151 p._m3(); |
| 1152 } |
| 1153 '''); |
| 1154 _computeUsedElements(source); |
| 1155 // validate |
| 1156 print(usedElementNames); |
| 1157 print(usedElements.members); |
| 1158 expect(usedElementNames, unorderedEquals(['A', 'a', 'p', '_m2'])); |
| 1159 expect(usedElements.members, unorderedEquals(['_m2', '_m3'])); |
| 1160 } |
| 1161 |
| 1162 void _computeUsedElements(Source source) { |
| 1163 LibraryUnitTarget target = new LibraryUnitTarget(source, source); |
| 1164 _computeResult(target, USED_ELEMENTS); |
| 1165 expect(task, new isInstanceOf<GatherUsedElementsTask>()); |
| 1166 usedElements = outputs[USED_ELEMENTS]; |
| 1167 usedElementNames = usedElements.elements.map((e) => e.name).toSet(); |
| 1168 } |
| 1169 } |
| 1170 |
| 1171 @reflectiveTest |
| 1125 class GenerateHintsTaskTest extends _AbstractDartTaskTest { | 1172 class GenerateHintsTaskTest extends _AbstractDartTaskTest { |
| 1126 test_perform_bestPractices_missingReturn() { | 1173 test_perform_bestPractices_missingReturn() { |
| 1127 Source source = _newSource('/test.dart', ''' | 1174 Source source = _newSource('/test.dart', ''' |
| 1128 int main() { | 1175 int main() { |
| 1129 } | 1176 } |
| 1130 '''); | 1177 '''); |
| 1131 LibraryUnitTarget target = new LibraryUnitTarget(source, source); | 1178 LibraryUnitTarget target = new LibraryUnitTarget(source, source); |
| 1132 _computeResult(target, HINTS); | 1179 _computeResult(target, HINTS); |
| 1133 expect(task, new isInstanceOf<GenerateHintsTask>()); | 1180 expect(task, new isInstanceOf<GenerateHintsTask>()); |
| 1134 // validate | 1181 // validate |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1658 taskManager.addTaskDescriptor(BuildCompilationUnitElementTask.DESCRIPTOR); | 1705 taskManager.addTaskDescriptor(BuildCompilationUnitElementTask.DESCRIPTOR); |
| 1659 taskManager.addTaskDescriptor(BuildLibraryConstructorsTask.DESCRIPTOR); | 1706 taskManager.addTaskDescriptor(BuildLibraryConstructorsTask.DESCRIPTOR); |
| 1660 taskManager.addTaskDescriptor(BuildLibraryElementTask.DESCRIPTOR); | 1707 taskManager.addTaskDescriptor(BuildLibraryElementTask.DESCRIPTOR); |
| 1661 taskManager.addTaskDescriptor(BuildPublicNamespaceTask.DESCRIPTOR); | 1708 taskManager.addTaskDescriptor(BuildPublicNamespaceTask.DESCRIPTOR); |
| 1662 taskManager.addTaskDescriptor(BuildDirectiveElementsTask.DESCRIPTOR); | 1709 taskManager.addTaskDescriptor(BuildDirectiveElementsTask.DESCRIPTOR); |
| 1663 taskManager.addTaskDescriptor(BuildSourceClosuresTask.DESCRIPTOR); | 1710 taskManager.addTaskDescriptor(BuildSourceClosuresTask.DESCRIPTOR); |
| 1664 taskManager.addTaskDescriptor(BuildExportNamespaceTask.DESCRIPTOR); | 1711 taskManager.addTaskDescriptor(BuildExportNamespaceTask.DESCRIPTOR); |
| 1665 taskManager.addTaskDescriptor(BuildEnumMemberElementsTask.DESCRIPTOR); | 1712 taskManager.addTaskDescriptor(BuildEnumMemberElementsTask.DESCRIPTOR); |
| 1666 taskManager.addTaskDescriptor(BuildFunctionTypeAliasesTask.DESCRIPTOR); | 1713 taskManager.addTaskDescriptor(BuildFunctionTypeAliasesTask.DESCRIPTOR); |
| 1667 taskManager.addTaskDescriptor(BuildTypeProviderTask.DESCRIPTOR); | 1714 taskManager.addTaskDescriptor(BuildTypeProviderTask.DESCRIPTOR); |
| 1715 taskManager.addTaskDescriptor(GatherUsedElementsTask.DESCRIPTOR); |
| 1668 taskManager.addTaskDescriptor(GenerateHintsTask.DESCRIPTOR); | 1716 taskManager.addTaskDescriptor(GenerateHintsTask.DESCRIPTOR); |
| 1669 taskManager.addTaskDescriptor(ResolveUnitTypeNamesTask.DESCRIPTOR); | 1717 taskManager.addTaskDescriptor(ResolveUnitTypeNamesTask.DESCRIPTOR); |
| 1670 taskManager.addTaskDescriptor(ResolveLibraryTypeNamesTask.DESCRIPTOR); | 1718 taskManager.addTaskDescriptor(ResolveLibraryTypeNamesTask.DESCRIPTOR); |
| 1671 taskManager.addTaskDescriptor(ResolveReferencesTask.DESCRIPTOR); | 1719 taskManager.addTaskDescriptor(ResolveReferencesTask.DESCRIPTOR); |
| 1672 taskManager.addTaskDescriptor(ResolveVariableReferencesTask.DESCRIPTOR); | 1720 taskManager.addTaskDescriptor(ResolveVariableReferencesTask.DESCRIPTOR); |
| 1673 taskManager.addTaskDescriptor(VerifyUnitTask.DESCRIPTOR); | 1721 taskManager.addTaskDescriptor(VerifyUnitTask.DESCRIPTOR); |
| 1674 // prepare AnalysisDriver | 1722 // prepare AnalysisDriver |
| 1675 analysisDriver = new AnalysisDriver(taskManager, context); | 1723 analysisDriver = new AnalysisDriver(taskManager, context); |
| 1676 } | 1724 } |
| 1677 | 1725 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1723 return entryMap.putIfAbsent(target, () => new CacheEntry()); | 1771 return entryMap.putIfAbsent(target, () => new CacheEntry()); |
| 1724 } | 1772 } |
| 1725 | 1773 |
| 1726 TimestampedData<String> getContents(Source source) => source.contents; | 1774 TimestampedData<String> getContents(Source source) => source.contents; |
| 1727 | 1775 |
| 1728 noSuchMethod(Invocation invocation) { | 1776 noSuchMethod(Invocation invocation) { |
| 1729 print('noSuchMethod: ${invocation.memberName}'); | 1777 print('noSuchMethod: ${invocation.memberName}'); |
| 1730 return super.noSuchMethod(invocation); | 1778 return super.noSuchMethod(invocation); |
| 1731 } | 1779 } |
| 1732 } | 1780 } |
| OLD | NEW |