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

Side by Side Diff: pkg/analyzer/lib/src/context/context.dart

Issue 1121963002: Record dependencies and invalidate results. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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 | Annotate | Revision Log
OLDNEW
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.context.context; 5 library analyzer.src.context.context;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analyzer/src/cancelable_future.dart'; 10 import 'package:analyzer/src/cancelable_future.dart';
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 TaskManager _taskManager; 83 TaskManager _taskManager;
84 84
85 /** 85 /**
86 * The analysis driver used to perform analysis. 86 * The analysis driver used to perform analysis.
87 */ 87 */
88 AnalysisDriver _driver; 88 AnalysisDriver _driver;
89 89
90 /** 90 /**
91 * A list containing sources for which data should not be flushed. 91 * A list containing sources for which data should not be flushed.
92 */ 92 */
93 List<Source> _priorityOrder = Source.EMPTY_ARRAY; 93 List<Source> _priorityOrder = <Source>[];
94 94
95 /** 95 /**
96 * A map from all sources for which there are futures pending to a list of 96 * A map from all sources for which there are futures pending to a list of
97 * the corresponding PendingFuture objects. These sources will be analyzed 97 * the corresponding PendingFuture objects. These sources will be analyzed
98 * in the same way as priority sources, except with higher priority. 98 * in the same way as priority sources, except with higher priority.
99 */ 99 */
100 HashMap<Source, List<PendingFuture>> _pendingFutureSources = 100 HashMap<Source, List<PendingFuture>> _pendingFutureSources =
101 new HashMap<Source, List<PendingFuture>>(); 101 new HashMap<Source, List<PendingFuture>>();
102 102
103 /** 103 /**
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 bool changed = newContents != originalContents; 931 bool changed = newContents != originalContents;
932 if (newContents != null) { 932 if (newContents != null) {
933 if (newContents != originalContents) { 933 if (newContents != originalContents) {
934 _incrementalAnalysisCache = 934 _incrementalAnalysisCache =
935 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source); 935 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source);
936 if (!analysisOptions.incremental || 936 if (!analysisOptions.incremental ||
937 !_tryPoorMansIncrementalResolution(source, newContents)) { 937 !_tryPoorMansIncrementalResolution(source, newContents)) {
938 _sourceChanged(source); 938 _sourceChanged(source);
939 } 939 }
940 entry.modificationTime = _contentCache.getModificationStamp(source); 940 entry.modificationTime = _contentCache.getModificationStamp(source);
941 entry.setValue(CONTENT, newContents); 941 entry.setValue(CONTENT, newContents, cache.TargetedResult.EMPTY_LIST);
942 } else { 942 } else {
943 entry.modificationTime = _contentCache.getModificationStamp(source); 943 entry.modificationTime = _contentCache.getModificationStamp(source);
944 } 944 }
945 } else if (originalContents != null) { 945 } else if (originalContents != null) {
946 _incrementalAnalysisCache = 946 _incrementalAnalysisCache =
947 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source); 947 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source);
948 changed = newContents != originalContents; 948 changed = newContents != originalContents;
949 // We are removing the overlay for the file, check if the file's 949 // We are removing the overlay for the file, check if the file's
950 // contents is the same as it was in the overlay. 950 // contents is the same as it was in the overlay.
951 try { 951 try {
952 TimestampedData<String> fileContents = getContents(source); 952 TimestampedData<String> fileContents = getContents(source);
953 String fileContentsData = fileContents.data; 953 String fileContentsData = fileContents.data;
954 if (fileContentsData == originalContents) { 954 if (fileContentsData == originalContents) {
955 entry.setValue(CONTENT, fileContentsData); 955 entry.setValue(
956 CONTENT, fileContentsData, cache.TargetedResult.EMPTY_LIST);
956 entry.modificationTime = fileContents.modificationTime; 957 entry.modificationTime = fileContents.modificationTime;
957 changed = false; 958 changed = false;
958 } 959 }
959 } catch (e) {} 960 } catch (e) {}
960 // If not the same content (e.g. the file is being closed without save), 961 // If not the same content (e.g. the file is being closed without save),
961 // then force analysis. 962 // then force analysis.
962 if (changed) { 963 if (changed) {
963 _sourceChanged(source); 964 _sourceChanged(source);
964 } 965 }
965 } 966 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 }); 1038 });
1038 } 1039 }
1039 1040
1040 @override 1041 @override
1041 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { 1042 void recordLibraryElements(Map<Source, LibraryElement> elementMap) {
1042 elementMap.forEach((Source librarySource, LibraryElement library) { 1043 elementMap.forEach((Source librarySource, LibraryElement library) {
1043 // 1044 //
1044 // Cache the element in the library's info. 1045 // Cache the element in the library's info.
1045 // 1046 //
1046 cache.CacheEntry entry = getCacheEntry(librarySource); 1047 cache.CacheEntry entry = getCacheEntry(librarySource);
1047 entry.setValue(BUILD_DIRECTIVES_ERRORS, AnalysisError.NO_ERRORS); 1048 setValue(ResultDescriptor result, value) {
1048 entry.setValue( 1049 entry.setValue(result, value, cache.TargetedResult.EMPTY_LIST);
1049 BUILD_FUNCTION_TYPE_ALIASES_ERRORS, AnalysisError.NO_ERRORS); 1050 }
1050 entry.setValue(BUILD_LIBRARY_ERRORS, AnalysisError.NO_ERRORS); 1051 setValue(BUILD_DIRECTIVES_ERRORS, AnalysisError.NO_ERRORS);
1052 setValue(BUILD_FUNCTION_TYPE_ALIASES_ERRORS, AnalysisError.NO_ERRORS);
1053 setValue(BUILD_LIBRARY_ERRORS, AnalysisError.NO_ERRORS);
1051 // CLASS_ELEMENTS 1054 // CLASS_ELEMENTS
1052 entry.setValue(COMPILATION_UNIT_ELEMENT, library.definingCompilationUnit); 1055 setValue(COMPILATION_UNIT_ELEMENT, library.definingCompilationUnit);
1053 // CONSTRUCTORS 1056 // CONSTRUCTORS
1054 // CONSTRUCTORS_ERRORS 1057 // CONSTRUCTORS_ERRORS
1055 entry.setState(CONTENT, CacheState.FLUSHED); 1058 entry.setState(CONTENT, CacheState.FLUSHED);
1056 entry.setValue(EXPORTED_LIBRARIES, Source.EMPTY_ARRAY); 1059 setValue(EXPORTED_LIBRARIES, Source.EMPTY_ARRAY);
1057 // EXPORT_SOURCE_CLOSURE 1060 // EXPORT_SOURCE_CLOSURE
1058 entry.setValue(IMPORTED_LIBRARIES, Source.EMPTY_ARRAY); 1061 setValue(IMPORTED_LIBRARIES, Source.EMPTY_ARRAY);
1059 // IMPORT_SOURCE_CLOSURE 1062 // IMPORT_SOURCE_CLOSURE
1060 entry.setValue(INCLUDED_PARTS, Source.EMPTY_ARRAY); 1063 setValue(INCLUDED_PARTS, Source.EMPTY_ARRAY);
1061 entry.setValue(IS_CLIENT, true); 1064 setValue(IS_CLIENT, true);
1062 entry.setValue(IS_LAUNCHABLE, false); 1065 setValue(IS_LAUNCHABLE, false);
1063 entry.setValue(LIBRARY_ELEMENT, library); 1066 setValue(LIBRARY_ELEMENT, library);
1064 entry.setValue(LIBRARY_ELEMENT1, library); 1067 setValue(LIBRARY_ELEMENT1, library);
1065 entry.setValue(LIBRARY_ELEMENT2, library); 1068 setValue(LIBRARY_ELEMENT2, library);
1066 entry.setValue(LIBRARY_ELEMENT3, library); 1069 setValue(LIBRARY_ELEMENT3, library);
1067 entry.setValue(LIBRARY_ELEMENT4, library); 1070 setValue(LIBRARY_ELEMENT4, library);
1068 entry.setValue(LIBRARY_ELEMENT5, library); 1071 setValue(LIBRARY_ELEMENT5, library);
1069 entry.setValue(LINE_INFO, new LineInfo(<int>[0])); 1072 setValue(LINE_INFO, new LineInfo(<int>[0]));
1070 entry.setValue(PARSE_ERRORS, AnalysisError.NO_ERRORS); 1073 setValue(PARSE_ERRORS, AnalysisError.NO_ERRORS);
1071 entry.setState(PARSED_UNIT, CacheState.FLUSHED); 1074 entry.setState(PARSED_UNIT, CacheState.FLUSHED);
1072 entry.setState(RESOLVE_TYPE_NAMES_ERRORS, CacheState.FLUSHED); 1075 entry.setState(RESOLVE_TYPE_NAMES_ERRORS, CacheState.FLUSHED);
1073 entry.setValue(SCAN_ERRORS, AnalysisError.NO_ERRORS); 1076 setValue(SCAN_ERRORS, AnalysisError.NO_ERRORS);
1074 entry.setValue(SOURCE_KIND, SourceKind.LIBRARY); 1077 setValue(SOURCE_KIND, SourceKind.LIBRARY);
1075 entry.setState(TOKEN_STREAM, CacheState.FLUSHED); 1078 entry.setState(TOKEN_STREAM, CacheState.FLUSHED);
1076 entry.setValue(UNITS, <Source>[librarySource]); 1079 setValue(UNITS, <Source>[librarySource]);
1077 1080
1078 LibrarySpecificUnit unit = 1081 LibrarySpecificUnit unit =
1079 new LibrarySpecificUnit(librarySource, librarySource); 1082 new LibrarySpecificUnit(librarySource, librarySource);
1080 entry = getCacheEntry(unit); 1083 entry = getCacheEntry(unit);
1081 entry.setValue(HINTS, AnalysisError.NO_ERRORS); 1084 setValue(HINTS, AnalysisError.NO_ERRORS);
1082 // dartEntry.setValue(LINTS, AnalysisError.NO_ERRORS); 1085 // dartEntry.setValue(LINTS, AnalysisError.NO_ERRORS);
1083 entry.setState(RESOLVE_REFERENCES_ERRORS, CacheState.FLUSHED); 1086 entry.setState(RESOLVE_REFERENCES_ERRORS, CacheState.FLUSHED);
1084 entry.setState(RESOLVED_UNIT, CacheState.FLUSHED); 1087 entry.setState(RESOLVED_UNIT, CacheState.FLUSHED);
1085 entry.setState(RESOLVED_UNIT1, CacheState.FLUSHED); 1088 entry.setState(RESOLVED_UNIT1, CacheState.FLUSHED);
1086 entry.setState(RESOLVED_UNIT2, CacheState.FLUSHED); 1089 entry.setState(RESOLVED_UNIT2, CacheState.FLUSHED);
1087 entry.setState(RESOLVED_UNIT3, CacheState.FLUSHED); 1090 entry.setState(RESOLVED_UNIT3, CacheState.FLUSHED);
1088 entry.setState(RESOLVED_UNIT4, CacheState.FLUSHED); 1091 entry.setState(RESOLVED_UNIT4, CacheState.FLUSHED);
1089 entry.setState(RESOLVED_UNIT5, CacheState.FLUSHED); 1092 entry.setState(RESOLVED_UNIT5, CacheState.FLUSHED);
1090 // USED_IMPORTED_ELEMENTS 1093 // USED_IMPORTED_ELEMENTS
1091 // USED_LOCAL_ELEMENTS 1094 // USED_LOCAL_ELEMENTS
1092 entry.setValue(VERIFY_ERRORS, AnalysisError.NO_ERRORS); 1095 setValue(VERIFY_ERRORS, AnalysisError.NO_ERRORS);
1093 }); 1096 });
1094 1097
1095 cache.CacheEntry entry = getCacheEntry(AnalysisContextTarget.request); 1098 cache.CacheEntry entry = getCacheEntry(AnalysisContextTarget.request);
1096 entry.setValue(TYPE_PROVIDER, typeProvider); 1099 entry.setValue(
1100 TYPE_PROVIDER, typeProvider, cache.TargetedResult.EMPTY_LIST);
1097 } 1101 }
1098 1102
1099 @override 1103 @override
1100 void removeListener(AnalysisListener listener) { 1104 void removeListener(AnalysisListener listener) {
1101 _listeners.remove(listener); 1105 _listeners.remove(listener);
1102 } 1106 }
1103 1107
1104 @override 1108 @override
1105 CompilationUnit resolveCompilationUnit( 1109 CompilationUnit resolveCompilationUnit(
1106 Source unitSource, LibraryElement library) { 1110 Source unitSource, LibraryElement library) {
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 // if (_options.incremental) { 1311 // if (_options.incremental) {
1308 // _incrementalAnalysisCache = IncrementalAnalysisCache.update( 1312 // _incrementalAnalysisCache = IncrementalAnalysisCache.update(
1309 // _incrementalAnalysisCache, source, originalContents, contents, 1313 // _incrementalAnalysisCache, source, originalContents, contents,
1310 // offset, oldLength, newLength, _cache.get(source)); 1314 // offset, oldLength, newLength, _cache.get(source));
1311 // } 1315 // }
1312 _sourceChanged(source); 1316 _sourceChanged(source);
1313 changed = true; 1317 changed = true;
1314 cache.CacheEntry entry = _cache.get(source); 1318 cache.CacheEntry entry = _cache.get(source);
1315 if (entry != null) { 1319 if (entry != null) {
1316 entry.modificationTime = _contentCache.getModificationStamp(source); 1320 entry.modificationTime = _contentCache.getModificationStamp(source);
1317 entry.setValue(CONTENT, contents); 1321 entry.setValue(CONTENT, contents, cache.TargetedResult.EMPTY_LIST);
1318 } 1322 }
1319 } 1323 }
1320 } else if (originalContents != null) { 1324 } else if (originalContents != null) {
1321 _incrementalAnalysisCache = 1325 _incrementalAnalysisCache =
1322 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source); 1326 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source);
1323 _sourceChanged(source); 1327 _sourceChanged(source);
1324 changed = true; 1328 changed = true;
1325 } 1329 }
1326 return changed; 1330 return changed;
1327 } 1331 }
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
1952 // Check cache for an existing partition. 1956 // Check cache for an existing partition.
1953 cache.SdkCachePartition partition = _sdkPartitions[sdk]; 1957 cache.SdkCachePartition partition = _sdkPartitions[sdk];
1954 if (partition == null) { 1958 if (partition == null) {
1955 partition = 1959 partition =
1956 new cache.SdkCachePartition(sdkContext, _DEFAULT_SDK_CACHE_SIZE); 1960 new cache.SdkCachePartition(sdkContext, _DEFAULT_SDK_CACHE_SIZE);
1957 _sdkPartitions[sdk] = partition; 1961 _sdkPartitions[sdk] = partition;
1958 } 1962 }
1959 return partition; 1963 return partition;
1960 } 1964 }
1961 } 1965 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698