| 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.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 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 bool changed = newContents != originalContents; | 973 bool changed = newContents != originalContents; |
| 974 if (newContents != null) { | 974 if (newContents != null) { |
| 975 if (newContents != originalContents) { | 975 if (newContents != originalContents) { |
| 976 _incrementalAnalysisCache = | 976 _incrementalAnalysisCache = |
| 977 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source); | 977 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source); |
| 978 if (!analysisOptions.incremental || | 978 if (!analysisOptions.incremental || |
| 979 !_tryPoorMansIncrementalResolution(source, newContents)) { | 979 !_tryPoorMansIncrementalResolution(source, newContents)) { |
| 980 _sourceChanged(source); | 980 _sourceChanged(source); |
| 981 } | 981 } |
| 982 entry.modificationTime = _contentCache.getModificationStamp(source); | 982 entry.modificationTime = _contentCache.getModificationStamp(source); |
| 983 entry.setValue( | 983 entry.setValue(CONTENT, newContents, cache.TargetedResult.EMPTY_LIST); |
| 984 CONTENT, newContents, cache.TargetedResult.EMPTY_LIST, null); | |
| 985 } else { | 984 } else { |
| 986 entry.modificationTime = _contentCache.getModificationStamp(source); | 985 entry.modificationTime = _contentCache.getModificationStamp(source); |
| 987 } | 986 } |
| 988 } else if (originalContents != null) { | 987 } else if (originalContents != null) { |
| 989 _incrementalAnalysisCache = | 988 _incrementalAnalysisCache = |
| 990 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source); | 989 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source); |
| 991 changed = newContents != originalContents; | 990 changed = newContents != originalContents; |
| 992 // We are removing the overlay for the file, check if the file's | 991 // We are removing the overlay for the file, check if the file's |
| 993 // contents is the same as it was in the overlay. | 992 // contents is the same as it was in the overlay. |
| 994 try { | 993 try { |
| 995 TimestampedData<String> fileContents = getContents(source); | 994 TimestampedData<String> fileContents = getContents(source); |
| 996 String fileContentsData = fileContents.data; | 995 String fileContentsData = fileContents.data; |
| 997 if (fileContentsData == originalContents) { | 996 if (fileContentsData == originalContents) { |
| 998 entry.setValue( | 997 entry.setValue( |
| 999 CONTENT, fileContentsData, cache.TargetedResult.EMPTY_LIST, null); | 998 CONTENT, fileContentsData, cache.TargetedResult.EMPTY_LIST); |
| 1000 entry.modificationTime = fileContents.modificationTime; | 999 entry.modificationTime = fileContents.modificationTime; |
| 1001 changed = false; | 1000 changed = false; |
| 1002 } | 1001 } |
| 1003 } catch (e) {} | 1002 } catch (e) {} |
| 1004 // If not the same content (e.g. the file is being closed without save), | 1003 // If not the same content (e.g. the file is being closed without save), |
| 1005 // then force analysis. | 1004 // then force analysis. |
| 1006 if (changed) { | 1005 if (changed) { |
| 1007 _sourceChanged(source); | 1006 _sourceChanged(source); |
| 1008 } | 1007 } |
| 1009 } | 1008 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1082 } | 1081 } |
| 1083 | 1082 |
| 1084 @override | 1083 @override |
| 1085 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { | 1084 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { |
| 1086 elementMap.forEach((Source librarySource, LibraryElement library) { | 1085 elementMap.forEach((Source librarySource, LibraryElement library) { |
| 1087 // | 1086 // |
| 1088 // Cache the element in the library's info. | 1087 // Cache the element in the library's info. |
| 1089 // | 1088 // |
| 1090 cache.CacheEntry entry = getCacheEntry(librarySource); | 1089 cache.CacheEntry entry = getCacheEntry(librarySource); |
| 1091 setValue(ResultDescriptor result, value) { | 1090 setValue(ResultDescriptor result, value) { |
| 1092 entry.setValue(result, value, cache.TargetedResult.EMPTY_LIST, null); | 1091 entry.setValue(result, value, cache.TargetedResult.EMPTY_LIST); |
| 1093 } | 1092 } |
| 1094 setValue(BUILD_DIRECTIVES_ERRORS, AnalysisError.NO_ERRORS); | 1093 setValue(BUILD_DIRECTIVES_ERRORS, AnalysisError.NO_ERRORS); |
| 1095 setValue(BUILD_FUNCTION_TYPE_ALIASES_ERRORS, AnalysisError.NO_ERRORS); | 1094 setValue(BUILD_FUNCTION_TYPE_ALIASES_ERRORS, AnalysisError.NO_ERRORS); |
| 1096 setValue(BUILD_LIBRARY_ERRORS, AnalysisError.NO_ERRORS); | 1095 setValue(BUILD_LIBRARY_ERRORS, AnalysisError.NO_ERRORS); |
| 1097 // CLASS_ELEMENTS | 1096 // CLASS_ELEMENTS |
| 1098 setValue(COMPILATION_UNIT_ELEMENT, library.definingCompilationUnit); | 1097 setValue(COMPILATION_UNIT_ELEMENT, library.definingCompilationUnit); |
| 1099 // CONSTRUCTORS | 1098 // CONSTRUCTORS |
| 1100 // CONSTRUCTORS_ERRORS | 1099 // CONSTRUCTORS_ERRORS |
| 1101 entry.setState(CONTENT, CacheState.FLUSHED); | 1100 entry.setState(CONTENT, CacheState.FLUSHED); |
| 1102 setValue(EXPORTED_LIBRARIES, Source.EMPTY_LIST); | 1101 setValue(EXPORTED_LIBRARIES, Source.EMPTY_LIST); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1133 entry.setState(RESOLVED_UNIT3, CacheState.FLUSHED); | 1132 entry.setState(RESOLVED_UNIT3, CacheState.FLUSHED); |
| 1134 entry.setState(RESOLVED_UNIT4, CacheState.FLUSHED); | 1133 entry.setState(RESOLVED_UNIT4, CacheState.FLUSHED); |
| 1135 entry.setState(RESOLVED_UNIT5, CacheState.FLUSHED); | 1134 entry.setState(RESOLVED_UNIT5, CacheState.FLUSHED); |
| 1136 // USED_IMPORTED_ELEMENTS | 1135 // USED_IMPORTED_ELEMENTS |
| 1137 // USED_LOCAL_ELEMENTS | 1136 // USED_LOCAL_ELEMENTS |
| 1138 setValue(VERIFY_ERRORS, AnalysisError.NO_ERRORS); | 1137 setValue(VERIFY_ERRORS, AnalysisError.NO_ERRORS); |
| 1139 }); | 1138 }); |
| 1140 | 1139 |
| 1141 cache.CacheEntry entry = getCacheEntry(AnalysisContextTarget.request); | 1140 cache.CacheEntry entry = getCacheEntry(AnalysisContextTarget.request); |
| 1142 entry.setValue( | 1141 entry.setValue( |
| 1143 TYPE_PROVIDER, typeProvider, cache.TargetedResult.EMPTY_LIST, null); | 1142 TYPE_PROVIDER, typeProvider, cache.TargetedResult.EMPTY_LIST); |
| 1144 } | 1143 } |
| 1145 | 1144 |
| 1146 @override | 1145 @override |
| 1147 void removeListener(AnalysisListener listener) { | 1146 void removeListener(AnalysisListener listener) { |
| 1148 _listeners.remove(listener); | 1147 _listeners.remove(listener); |
| 1149 } | 1148 } |
| 1150 | 1149 |
| 1151 @override | 1150 @override |
| 1152 CompilationUnit resolveCompilationUnit( | 1151 CompilationUnit resolveCompilationUnit( |
| 1153 Source unitSource, LibraryElement library) { | 1152 Source unitSource, LibraryElement library) { |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1369 // if (_options.incremental) { | 1368 // if (_options.incremental) { |
| 1370 // _incrementalAnalysisCache = IncrementalAnalysisCache.update( | 1369 // _incrementalAnalysisCache = IncrementalAnalysisCache.update( |
| 1371 // _incrementalAnalysisCache, source, originalContents, contents, | 1370 // _incrementalAnalysisCache, source, originalContents, contents, |
| 1372 // offset, oldLength, newLength, _cache.get(source)); | 1371 // offset, oldLength, newLength, _cache.get(source)); |
| 1373 // } | 1372 // } |
| 1374 _sourceChanged(source); | 1373 _sourceChanged(source); |
| 1375 changed = true; | 1374 changed = true; |
| 1376 cache.CacheEntry entry = _cache.get(source); | 1375 cache.CacheEntry entry = _cache.get(source); |
| 1377 if (entry != null) { | 1376 if (entry != null) { |
| 1378 entry.modificationTime = _contentCache.getModificationStamp(source); | 1377 entry.modificationTime = _contentCache.getModificationStamp(source); |
| 1379 entry.setValue( | 1378 entry.setValue(CONTENT, contents, cache.TargetedResult.EMPTY_LIST); |
| 1380 CONTENT, contents, cache.TargetedResult.EMPTY_LIST, null); | |
| 1381 } | 1379 } |
| 1382 } | 1380 } |
| 1383 } else if (originalContents != null) { | 1381 } else if (originalContents != null) { |
| 1384 _incrementalAnalysisCache = | 1382 _incrementalAnalysisCache = |
| 1385 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source); | 1383 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source); |
| 1386 _sourceChanged(source); | 1384 _sourceChanged(source); |
| 1387 changed = true; | 1385 changed = true; |
| 1388 } | 1386 } |
| 1389 return changed; | 1387 return changed; |
| 1390 } | 1388 } |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2116 PendingFuture pendingFuture = | 2114 PendingFuture pendingFuture = |
| 2117 new PendingFuture<T>(_context, target, computeValue); | 2115 new PendingFuture<T>(_context, target, computeValue); |
| 2118 if (!pendingFuture.evaluate(entry)) { | 2116 if (!pendingFuture.evaluate(entry)) { |
| 2119 _context._pendingFutureTargets | 2117 _context._pendingFutureTargets |
| 2120 .putIfAbsent(target, () => <PendingFuture>[]) | 2118 .putIfAbsent(target, () => <PendingFuture>[]) |
| 2121 .add(pendingFuture); | 2119 .add(pendingFuture); |
| 2122 } | 2120 } |
| 2123 return pendingFuture.future; | 2121 return pendingFuture.future; |
| 2124 } | 2122 } |
| 2125 } | 2123 } |
| OLD | NEW |