Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: pkg/analyzer/lib/src/dart/analysis/driver.dart

Issue 3010463002: Make creating LibraryContext async, so all its transitive clients. (Closed)
Patch Set: tweak Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/src/dart/analysis/driver_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:collection'; 6 import 'dart:collection';
7 import 'dart:typed_data'; 7 import 'dart:typed_data';
8 8
9 import 'package:analyzer/context/context_root.dart'; 9 import 'package:analyzer/context/context_root.dart';
10 import 'package:analyzer/context/declared_variables.dart'; 10 import 'package:analyzer/context/declared_variables.dart';
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 * be analyzed, the [Future] completes with `null`. 561 * be analyzed, the [Future] completes with `null`.
562 * 562 *
563 * The [path] must be absolute and normalized. 563 * The [path] must be absolute and normalized.
564 * 564 *
565 * This method does not use analysis priorities, and must not be used in 565 * This method does not use analysis priorities, and must not be used in
566 * interactive analysis, such as Analysis Server or its plugins. 566 * interactive analysis, such as Analysis Server or its plugins.
567 */ 567 */
568 Future<ErrorsResult> getErrors(String path) async { 568 Future<ErrorsResult> getErrors(String path) async {
569 // Ask the analysis result without unit, so return cached errors. 569 // Ask the analysis result without unit, so return cached errors.
570 // If no cached analysis result, it will be computed. 570 // If no cached analysis result, it will be computed.
571 AnalysisResult analysisResult = _computeAnalysisResult(path); 571 AnalysisResult analysisResult = await _computeAnalysisResult(path);
572
573 // Check for asynchronous changes during computing the result.
574 await _runTestAsyncWorkDuringAnalysis(path);
575 if (_fileTracker.hasChangedFiles) {
576 analysisResult = null;
577 }
572 578
573 // If not computed yet, because a part file without a known library, 579 // If not computed yet, because a part file without a known library,
574 // we have to compute the full analysis result, with the unit. 580 // we have to compute the full analysis result, with the unit.
575 analysisResult ??= await getResult(path); 581 analysisResult ??= await getResult(path);
576 if (analysisResult == null) { 582 if (analysisResult == null) {
577 return null; 583 return null;
578 } 584 }
579 585
580 return new ErrorsResult(currentSession, path, analysisResult.uri, 586 return new ErrorsResult(currentSession, path, analysisResult.uri,
581 analysisResult.lineInfo, analysisResult.errors); 587 analysisResult.lineInfo, analysisResult.errors);
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 @override 805 @override
800 Future<Null> performWork() async { 806 Future<Null> performWork() async {
801 if (_fileTracker.verifyChangedFilesIfNeeded()) { 807 if (_fileTracker.verifyChangedFilesIfNeeded()) {
802 return; 808 return;
803 } 809 }
804 810
805 // Analyze a requested file. 811 // Analyze a requested file.
806 if (_requestedFiles.isNotEmpty) { 812 if (_requestedFiles.isNotEmpty) {
807 String path = _requestedFiles.keys.first; 813 String path = _requestedFiles.keys.first;
808 try { 814 try {
809 AnalysisResult result = _computeAnalysisResult(path, withUnit: true); 815 AnalysisResult result =
816 await _computeAnalysisResult(path, withUnit: true);
817 // Check for asynchronous changes during computing the result.
818 await _runTestAsyncWorkDuringAnalysis(path);
819 if (_fileTracker.hasChangedFiles) {
820 return;
821 }
810 // If a part without a library, delay its analysis. 822 // If a part without a library, delay its analysis.
811 if (result == null) { 823 if (result == null) {
812 _requestedParts 824 _requestedParts
813 .putIfAbsent(path, () => []) 825 .putIfAbsent(path, () => [])
814 .addAll(_requestedFiles.remove(path)); 826 .addAll(_requestedFiles.remove(path));
815 return; 827 return;
816 } 828 }
817 // Notify the completers. 829 // Notify the completers.
818 _requestedFiles.remove(path).forEach((completer) { 830 _requestedFiles.remove(path).forEach((completer) {
819 completer.complete(result); 831 completer.complete(result);
820 }); 832 });
821 // Remove from to be analyzed and produce it now. 833 // Remove from to be analyzed and produce it now.
822 _fileTracker.fileWasAnalyzed(path); 834 _fileTracker.fileWasAnalyzed(path);
823 _resultController.add(result); 835 _resultController.add(result);
824 } catch (exception, stackTrace) { 836 } catch (exception, stackTrace) {
825 _fileTracker.fileWasAnalyzed(path); 837 _fileTracker.fileWasAnalyzed(path);
826 _requestedFiles.remove(path).forEach((completer) { 838 _requestedFiles.remove(path).forEach((completer) {
827 completer.completeError(exception, stackTrace); 839 completer.completeError(exception, stackTrace);
828 }); 840 });
829 } 841 }
830 return; 842 return;
831 } 843 }
832 844
833 // Process an index request. 845 // Process an index request.
834 if (_indexRequestedFiles.isNotEmpty) { 846 if (_indexRequestedFiles.isNotEmpty) {
835 String path = _indexRequestedFiles.keys.first; 847 String path = _indexRequestedFiles.keys.first;
836 AnalysisDriverUnitIndex index = _computeIndex(path); 848 AnalysisDriverUnitIndex index = await _computeIndex(path);
837 _indexRequestedFiles.remove(path).forEach((completer) { 849 _indexRequestedFiles.remove(path).forEach((completer) {
838 completer.complete(index); 850 completer.complete(index);
839 }); 851 });
840 return; 852 return;
841 } 853 }
842 854
843 // Process a unit element key request. 855 // Process a unit element key request.
844 if (_unitElementSignatureRequests.isNotEmpty) { 856 if (_unitElementSignatureRequests.isNotEmpty) {
845 String path = _unitElementSignatureRequests.keys.first; 857 String path = _unitElementSignatureRequests.keys.first;
846 String signature = _computeUnitElementSignature(path); 858 String signature = _computeUnitElementSignature(path);
847 _unitElementSignatureRequests.remove(path).forEach((completer) { 859 _unitElementSignatureRequests.remove(path).forEach((completer) {
848 completer.complete(signature); 860 completer.complete(signature);
849 }); 861 });
850 return; 862 return;
851 } 863 }
852 864
853 // Process a unit element request. 865 // Process a unit element request.
854 if (_unitElementRequestedFiles.isNotEmpty) { 866 if (_unitElementRequestedFiles.isNotEmpty) {
855 String path = _unitElementRequestedFiles.keys.first; 867 String path = _unitElementRequestedFiles.keys.first;
856 UnitElementResult result = _computeUnitElement(path); 868 UnitElementResult result = await _computeUnitElement(path);
857 _unitElementRequestedFiles.remove(path).forEach((completer) { 869 _unitElementRequestedFiles.remove(path).forEach((completer) {
858 completer.complete(result); 870 completer.complete(result);
859 }); 871 });
860 return; 872 return;
861 } 873 }
862 874
863 // Compute files defining a name. 875 // Compute files defining a name.
864 if (_definingClassMemberNameTasks.isNotEmpty) { 876 if (_definingClassMemberNameTasks.isNotEmpty) {
865 _FilesDefiningClassMemberNameTask task = 877 _FilesDefiningClassMemberNameTask task =
866 _definingClassMemberNameTasks.first; 878 _definingClassMemberNameTasks.first;
(...skipping 23 matching lines...) Expand all
890 } 902 }
891 return; 903 return;
892 } 904 }
893 905
894 // Analyze a priority file. 906 // Analyze a priority file.
895 if (_priorityFiles.isNotEmpty) { 907 if (_priorityFiles.isNotEmpty) {
896 for (String path in _priorityFiles) { 908 for (String path in _priorityFiles) {
897 if (_fileTracker.isFilePending(path)) { 909 if (_fileTracker.isFilePending(path)) {
898 try { 910 try {
899 AnalysisResult result = 911 AnalysisResult result =
900 _computeAnalysisResult(path, withUnit: true); 912 await _computeAnalysisResult(path, withUnit: true);
913 await _runTestAsyncWorkDuringAnalysis(path);
901 if (result == null) { 914 if (result == null) {
902 _partsToAnalyze.add(path); 915 _partsToAnalyze.add(path);
903 } else { 916 } else {
904 _resultController.add(result); 917 _resultController.add(result);
905 } 918 }
906 } catch (exception, stackTrace) { 919 } catch (exception, stackTrace) {
907 _reportException(path, exception, stackTrace); 920 _reportException(path, exception, stackTrace);
908 } finally { 921 } finally {
909 _fileTracker.fileWasAnalyzed(path); 922 _fileTracker.fileWasAnalyzed(path);
910 } 923 }
911 return; 924 return;
912 } 925 }
913 } 926 }
914 } 927 }
915 928
916 // Analyze a general file. 929 // Analyze a general file.
917 if (_fileTracker.hasPendingFiles) { 930 if (_fileTracker.hasPendingFiles) {
918 String path = _fileTracker.anyPendingFile; 931 String path = _fileTracker.anyPendingFile;
919 try { 932 try {
920 AnalysisResult result = _computeAnalysisResult(path, 933 AnalysisResult result = await _computeAnalysisResult(path,
921 withUnit: false, skipIfSameSignature: true); 934 withUnit: false, skipIfSameSignature: true);
935 await _runTestAsyncWorkDuringAnalysis(path);
922 if (result == null) { 936 if (result == null) {
923 _partsToAnalyze.add(path); 937 _partsToAnalyze.add(path);
924 } else if (result == AnalysisResult._UNCHANGED) { 938 } else if (result == AnalysisResult._UNCHANGED) {
925 // We found that the set of errors is the same as we produced the 939 // We found that the set of errors is the same as we produced the
926 // last time, so we don't need to produce it again now. 940 // last time, so we don't need to produce it again now.
927 } else { 941 } else {
928 _resultController.add(result); 942 _resultController.add(result);
929 _lastProducedSignatures[result.path] = result._signature; 943 _lastProducedSignatures[result.path] = result._signature;
930 } 944 }
931 } catch (exception, stackTrace) { 945 } catch (exception, stackTrace) {
932 _reportException(path, exception, stackTrace); 946 _reportException(path, exception, stackTrace);
933 } finally { 947 } finally {
934 _fileTracker.fileWasAnalyzed(path); 948 _fileTracker.fileWasAnalyzed(path);
935 } 949 }
936 return; 950 return;
937 } 951 }
938 952
939 // Analyze a requested part file. 953 // Analyze a requested part file.
940 if (_requestedParts.isNotEmpty) { 954 if (_requestedParts.isNotEmpty) {
941 String path = _requestedParts.keys.first; 955 String path = _requestedParts.keys.first;
942 try { 956 try {
943 AnalysisResult result = _computeAnalysisResult(path, 957 AnalysisResult result = await _computeAnalysisResult(path,
944 withUnit: true, asIsIfPartWithoutLibrary: true); 958 withUnit: true, asIsIfPartWithoutLibrary: true);
959 // Check for asynchronous changes during computing the result.
960 if (_fileTracker.hasChangedFiles) {
961 return;
962 }
945 // Notify the completers. 963 // Notify the completers.
946 _requestedParts.remove(path).forEach((completer) { 964 _requestedParts.remove(path).forEach((completer) {
947 completer.complete(result); 965 completer.complete(result);
948 }); 966 });
949 // Remove from to be analyzed and produce it now. 967 // Remove from to be analyzed and produce it now.
950 _partsToAnalyze.remove(path); 968 _partsToAnalyze.remove(path);
951 _resultController.add(result); 969 _resultController.add(result);
952 } catch (exception, stackTrace) { 970 } catch (exception, stackTrace) {
953 _partsToAnalyze.remove(path); 971 _partsToAnalyze.remove(path);
954 _requestedParts.remove(path).forEach((completer) { 972 _requestedParts.remove(path).forEach((completer) {
955 completer.completeError(exception, stackTrace); 973 completer.completeError(exception, stackTrace);
956 }); 974 });
957 } 975 }
958 return; 976 return;
959 } 977 }
960 978
961 // Analyze a general part. 979 // Analyze a general part.
962 if (_partsToAnalyze.isNotEmpty) { 980 if (_partsToAnalyze.isNotEmpty) {
963 String path = _partsToAnalyze.first; 981 String path = _partsToAnalyze.first;
964 _partsToAnalyze.remove(path); 982 _partsToAnalyze.remove(path);
965 try { 983 try {
966 AnalysisResult result = _computeAnalysisResult(path, 984 AnalysisResult result = await _computeAnalysisResult(path,
967 withUnit: _priorityFiles.contains(path), 985 withUnit: _priorityFiles.contains(path),
968 asIsIfPartWithoutLibrary: true); 986 asIsIfPartWithoutLibrary: true);
969 _resultController.add(result); 987 _resultController.add(result);
970 } catch (exception, stackTrace) { 988 } catch (exception, stackTrace) {
971 _reportException(path, exception, stackTrace); 989 _reportException(path, exception, stackTrace);
972 } 990 }
973 return; 991 return;
974 } 992 }
975 } 993 }
976 994
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 * compute only if [withUnit] is `true`. 1032 * compute only if [withUnit] is `true`.
1015 * 1033 *
1016 * Return `null` if the file is a part of an unknown library, so cannot be 1034 * Return `null` if the file is a part of an unknown library, so cannot be
1017 * analyzed yet. But [asIsIfPartWithoutLibrary] is `true`, then the file is 1035 * analyzed yet. But [asIsIfPartWithoutLibrary] is `true`, then the file is
1018 * analyzed anyway, even without a library. 1036 * analyzed anyway, even without a library.
1019 * 1037 *
1020 * Return [AnalysisResult._UNCHANGED] if [skipIfSameSignature] is `true` and 1038 * Return [AnalysisResult._UNCHANGED] if [skipIfSameSignature] is `true` and
1021 * the resolved signature of the file in its library is the same as the one 1039 * the resolved signature of the file in its library is the same as the one
1022 * that was the most recently produced to the client. 1040 * that was the most recently produced to the client.
1023 */ 1041 */
1024 AnalysisResult _computeAnalysisResult(String path, 1042 Future<AnalysisResult> _computeAnalysisResult(String path,
1025 {bool withUnit: false, 1043 {bool withUnit: false,
1026 bool asIsIfPartWithoutLibrary: false, 1044 bool asIsIfPartWithoutLibrary: false,
1027 bool skipIfSameSignature: false}) { 1045 bool skipIfSameSignature: false}) async {
1028 FileState file = _fsState.getFileForPath(path); 1046 FileState file = _fsState.getFileForPath(path);
1029 1047
1030 // Prepare the library - the file itself, or the known library. 1048 // Prepare the library - the file itself, or the known library.
1031 FileState library = file.isPart ? file.library : file; 1049 FileState library = file.isPart ? file.library : file;
1032 if (library == null) { 1050 if (library == null) {
1033 if (asIsIfPartWithoutLibrary) { 1051 if (asIsIfPartWithoutLibrary) {
1034 library = file; 1052 library = file;
1035 } else { 1053 } else {
1036 return null; 1054 return null;
1037 } 1055 }
(...skipping 15 matching lines...) Expand all
1053 if (!withUnit) { 1071 if (!withUnit) {
1054 List<int> bytes = DriverPerformance.cache.makeCurrentWhile(() { 1072 List<int> bytes = DriverPerformance.cache.makeCurrentWhile(() {
1055 return _byteStore.get(key); 1073 return _byteStore.get(key);
1056 }); 1074 });
1057 if (bytes != null) { 1075 if (bytes != null) {
1058 return _getAnalysisResultFromBytes(file, signature, bytes); 1076 return _getAnalysisResultFromBytes(file, signature, bytes);
1059 } 1077 }
1060 } 1078 }
1061 1079
1062 // We need the fully resolved unit, or the result is not cached. 1080 // We need the fully resolved unit, or the result is not cached.
1063 return _logger.run('Compute analysis result for $path', () { 1081 return _logger.runAsync('Compute analysis result for $path', () async {
1064 try { 1082 try {
1065 LibraryContext libraryContext = _createLibraryContext(library); 1083 LibraryContext libraryContext = await _createLibraryContext(library);
1066 try { 1084 try {
1067 _testView.numOfAnalyzedLibraries++; 1085 _testView.numOfAnalyzedLibraries++;
1068 LibraryAnalyzer analyzer = new LibraryAnalyzer( 1086 LibraryAnalyzer analyzer = new LibraryAnalyzer(
1069 analysisOptions, 1087 analysisOptions,
1070 declaredVariables, 1088 declaredVariables,
1071 sourceFactory, 1089 sourceFactory,
1072 _fsState, 1090 _fsState,
1073 libraryContext.store, 1091 libraryContext.store,
1074 library); 1092 library);
1075 Map<FileState, UnitAnalysisResult> results = analyzer.analyze(); 1093 Map<FileState, UnitAnalysisResult> results = analyzer.analyze();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 libraryContext.dispose(); 1127 libraryContext.dispose();
1110 } 1128 }
1111 } catch (exception, stackTrace) { 1129 } catch (exception, stackTrace) {
1112 String contextKey = 1130 String contextKey =
1113 _storeExceptionContext(path, library, exception, stackTrace); 1131 _storeExceptionContext(path, library, exception, stackTrace);
1114 throw new _ExceptionState(exception, stackTrace, contextKey); 1132 throw new _ExceptionState(exception, stackTrace, contextKey);
1115 } 1133 }
1116 }); 1134 });
1117 } 1135 }
1118 1136
1119 AnalysisDriverUnitIndex _computeIndex(String path) { 1137 Future<AnalysisDriverUnitIndex> _computeIndex(String path) async {
1120 AnalysisResult analysisResult = _computeAnalysisResult(path, 1138 AnalysisResult analysisResult = await _computeAnalysisResult(path,
1121 withUnit: false, asIsIfPartWithoutLibrary: true); 1139 withUnit: false, asIsIfPartWithoutLibrary: true);
1122 return analysisResult._index; 1140 return analysisResult._index;
1123 } 1141 }
1124 1142
1125 UnitElementResult _computeUnitElement(String path) { 1143 Future<UnitElementResult> _computeUnitElement(String path) async {
1126 FileState file = _fsState.getFileForPath(path); 1144 FileState file = _fsState.getFileForPath(path);
1127 FileState library = file.library ?? file; 1145 FileState library = file.library ?? file;
1128 1146
1129 // Create the AnalysisContext to resynthesize elements in. 1147 // Create the AnalysisContext to resynthesize elements in.
1130 LibraryContext libraryContext = _createLibraryContext(library); 1148 LibraryContext libraryContext = await _createLibraryContext(library);
1131 1149
1132 // Resynthesize the CompilationUnitElement in the context. 1150 // Resynthesize the CompilationUnitElement in the context.
1133 try { 1151 try {
1134 CompilationUnitElement element = 1152 CompilationUnitElement element =
1135 libraryContext.computeUnitElement(library.source, file.source); 1153 libraryContext.computeUnitElement(library.source, file.source);
1136 String signature = library.transitiveSignature; 1154 String signature = library.transitiveSignature;
1137 return new UnitElementResult( 1155 return new UnitElementResult(
1138 currentSession, path, file.uri, signature, element); 1156 currentSession, path, file.uri, signature, element);
1139 } finally { 1157 } finally {
1140 libraryContext.dispose(); 1158 libraryContext.dispose();
(...skipping 16 matching lines...) Expand all
1157 _fillSalt(); 1175 _fillSalt();
1158 _fsState = new FileSystemState(_logger, _byteStore, _contentOverlay, 1176 _fsState = new FileSystemState(_logger, _byteStore, _contentOverlay,
1159 _resourceProvider, sourceFactory, analysisOptions, _salt, 1177 _resourceProvider, sourceFactory, analysisOptions, _salt,
1160 externalSummaries: _externalSummaries); 1178 externalSummaries: _externalSummaries);
1161 _fileTracker = new FileTracker(_logger, _fsState, _changeHook); 1179 _fileTracker = new FileTracker(_logger, _fsState, _changeHook);
1162 } 1180 }
1163 1181
1164 /** 1182 /**
1165 * Return the context in which the [library] should be analyzed. 1183 * Return the context in which the [library] should be analyzed.
1166 */ 1184 */
1167 LibraryContext _createLibraryContext(FileState library) { 1185 Future<LibraryContext> _createLibraryContext(FileState library) async {
1168 _testView.numOfCreatedLibraryContexts++; 1186 _testView.numOfCreatedLibraryContexts++;
1169 return new LibraryContext.forSingleLibrary( 1187 return new LibraryContext.forSingleLibrary(
1170 library, 1188 library,
1171 _logger, 1189 _logger,
1172 _sdkBundle, 1190 _sdkBundle,
1173 _byteStore, 1191 _byteStore,
1174 _analysisOptions, 1192 _analysisOptions,
1175 declaredVariables, 1193 declaredVariables,
1176 _sourceFactory, 1194 _sourceFactory,
1177 _externalSummaries, 1195 _externalSummaries,
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 var state = exception as _ExceptionState; 1306 var state = exception as _ExceptionState;
1289 exception = state.exception; 1307 exception = state.exception;
1290 stackTrace = state.stackTrace; 1308 stackTrace = state.stackTrace;
1291 contextKey = state.contextKey; 1309 contextKey = state.contextKey;
1292 } 1310 }
1293 CaughtException caught = new CaughtException(exception, stackTrace); 1311 CaughtException caught = new CaughtException(exception, stackTrace);
1294 _exceptionController.add(new ExceptionResult(path, caught, contextKey)); 1312 _exceptionController.add(new ExceptionResult(path, caught, contextKey));
1295 } 1313 }
1296 1314
1297 /** 1315 /**
1316 * Tests need a reliable way to simulate file changes during analysis.
1317 *
1318 * When a change happens, the driver must make sure that [getResult] produces
1319 * results that include these changes. It is OK for the [results] stream
1320 * to produce stale results as long as it eventually produces results that
1321 * also include the changes.
Paul Berry 2017/08/25 20:01:55 This comment doesn't actually help me understand w
scheglov 2017/08/25 20:30:46 Done.
1322 */
1323 Future _runTestAsyncWorkDuringAnalysis(String path) {
1324 var work = _testView.workToWaitAfterComputingResult;
1325 _testView.workToWaitAfterComputingResult = null;
1326 return work != null ? work(path) : null;
1327 }
1328
1329 /**
1298 * Serialize the given [resolvedUnit] errors and index into bytes. 1330 * Serialize the given [resolvedUnit] errors and index into bytes.
1299 */ 1331 */
1300 List<int> _serializeResolvedUnit( 1332 List<int> _serializeResolvedUnit(
1301 CompilationUnit resolvedUnit, List<AnalysisError> errors) { 1333 CompilationUnit resolvedUnit, List<AnalysisError> errors) {
1302 AnalysisDriverUnitIndexBuilder index = indexUnit(resolvedUnit); 1334 AnalysisDriverUnitIndexBuilder index = indexUnit(resolvedUnit);
1303 return new AnalysisDriverResolvedUnitBuilder( 1335 return new AnalysisDriverResolvedUnitBuilder(
1304 errors: errors 1336 errors: errors
1305 .map((error) => new AnalysisDriverUnitErrorBuilder( 1337 .map((error) => new AnalysisDriverUnitErrorBuilder(
1306 offset: error.offset, 1338 offset: error.offset,
1307 length: error.length, 1339 length: error.length,
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 } 1668 }
1637 1669
1638 @visibleForTesting 1670 @visibleForTesting
1639 class AnalysisDriverTestView { 1671 class AnalysisDriverTestView {
1640 final AnalysisDriver driver; 1672 final AnalysisDriver driver;
1641 1673
1642 int numOfCreatedLibraryContexts = 0; 1674 int numOfCreatedLibraryContexts = 0;
1643 1675
1644 int numOfAnalyzedLibraries = 0; 1676 int numOfAnalyzedLibraries = 0;
1645 1677
1678 Future<Null> Function(String path) workToWaitAfterComputingResult;
1679
1646 AnalysisDriverTestView(this.driver); 1680 AnalysisDriverTestView(this.driver);
1647 1681
1648 FileTracker get fileTracker => driver._fileTracker; 1682 FileTracker get fileTracker => driver._fileTracker;
1649 1683
1650 Map<String, AnalysisResult> get priorityResults => driver._priorityResults; 1684 Map<String, AnalysisResult> get priorityResults => driver._priorityResults;
1651 1685
1652 SummaryDataStore getSummaryStore(String libraryPath) { 1686 Future<SummaryDataStore> getSummaryStore(String libraryPath) async {
1653 FileState library = driver.fsState.getFileForPath(libraryPath); 1687 FileState library = driver.fsState.getFileForPath(libraryPath);
1654 LibraryContext libraryContext = driver._createLibraryContext(library); 1688 LibraryContext libraryContext = await driver._createLibraryContext(library);
1655 try { 1689 try {
1656 return libraryContext.store; 1690 return libraryContext.store;
1657 } finally { 1691 } finally {
1658 libraryContext.dispose(); 1692 libraryContext.dispose();
1659 } 1693 }
1660 } 1694 }
1661 } 1695 }
1662 1696
1663 /** 1697 /**
1664 * The result of analyzing of a single file. 1698 * The result of analyzing of a single file.
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
2073 libraryDeclarations.add(new TopLevelDeclarationInSource( 2107 libraryDeclarations.add(new TopLevelDeclarationInSource(
2074 file.source, declaration, isExported)); 2108 file.source, declaration, isExported));
2075 } 2109 }
2076 } 2110 }
2077 } 2111 }
2078 2112
2079 // We're not done yet. 2113 // We're not done yet.
2080 return false; 2114 return false;
2081 } 2115 }
2082 } 2116 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/src/dart/analysis/driver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698