| 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/instrumentation/instrumentation.dart'; | 10 import 'package:analyzer/instrumentation/instrumentation.dart'; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 new HashMap<AnalysisTarget, List<PendingFuture>>(); | 150 new HashMap<AnalysisTarget, List<PendingFuture>>(); |
| 151 | 151 |
| 152 /** | 152 /** |
| 153 * A table mapping sources to the change notices that are waiting to be | 153 * A table mapping sources to the change notices that are waiting to be |
| 154 * returned related to that source. | 154 * returned related to that source. |
| 155 */ | 155 */ |
| 156 HashMap<Source, ChangeNoticeImpl> _pendingNotices = | 156 HashMap<Source, ChangeNoticeImpl> _pendingNotices = |
| 157 new HashMap<Source, ChangeNoticeImpl>(); | 157 new HashMap<Source, ChangeNoticeImpl>(); |
| 158 | 158 |
| 159 /** | 159 /** |
| 160 * Cached information used in incremental analysis or `null` if none. | |
| 161 */ | |
| 162 IncrementalAnalysisCache _incrementalAnalysisCache; | |
| 163 | |
| 164 /** | |
| 165 * The [TypeProvider] for this context, `null` if not yet created. | 160 * The [TypeProvider] for this context, `null` if not yet created. |
| 166 */ | 161 */ |
| 167 TypeProvider _typeProvider; | 162 TypeProvider _typeProvider; |
| 168 | 163 |
| 169 /** | 164 /** |
| 170 * The controller for sending [SourcesChangedEvent]s. | 165 * The controller for sending [SourcesChangedEvent]s. |
| 171 */ | 166 */ |
| 172 StreamController<SourcesChangedEvent> _onSourcesChangedController; | 167 StreamController<SourcesChangedEvent> _onSourcesChangedController; |
| 173 | 168 |
| 174 /** | 169 /** |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 @override | 412 @override |
| 418 AnalysisContextStatistics get statistics { | 413 AnalysisContextStatistics get statistics { |
| 419 AnalysisContextStatisticsImpl statistics = | 414 AnalysisContextStatisticsImpl statistics = |
| 420 new AnalysisContextStatisticsImpl(); | 415 new AnalysisContextStatisticsImpl(); |
| 421 // TODO(brianwilkerson) Implement this. | 416 // TODO(brianwilkerson) Implement this. |
| 422 // visitCacheItems(statistics._internalPutCacheItem); | 417 // visitCacheItems(statistics._internalPutCacheItem); |
| 423 // statistics.partitionData = _cache.partitionData; | 418 // statistics.partitionData = _cache.partitionData; |
| 424 return statistics; | 419 return statistics; |
| 425 } | 420 } |
| 426 | 421 |
| 427 IncrementalAnalysisCache get test_incrementalAnalysisCache { | |
| 428 return _incrementalAnalysisCache; | |
| 429 } | |
| 430 | |
| 431 set test_incrementalAnalysisCache(IncrementalAnalysisCache value) { | |
| 432 _incrementalAnalysisCache = value; | |
| 433 } | |
| 434 | |
| 435 List<Source> get test_priorityOrder => _priorityOrder; | 422 List<Source> get test_priorityOrder => _priorityOrder; |
| 436 | 423 |
| 437 @override | 424 @override |
| 438 TypeProvider get typeProvider { | 425 TypeProvider get typeProvider { |
| 439 // Make sure a task didn't accidentally try to call back into the context | 426 // Make sure a task didn't accidentally try to call back into the context |
| 440 // to retrieve the type provider. | 427 // to retrieve the type provider. |
| 441 assert(!driver.isTaskRunning); | 428 assert(!driver.isTaskRunning); |
| 442 | 429 |
| 443 if (_typeProvider != null) { | 430 if (_typeProvider != null) { |
| 444 return _typeProvider; | 431 return _typeProvider; |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 @override | 933 @override |
| 947 bool handleContentsChanged( | 934 bool handleContentsChanged( |
| 948 Source source, String originalContents, String newContents, bool notify) { | 935 Source source, String originalContents, String newContents, bool notify) { |
| 949 CacheEntry entry = _cache.get(source); | 936 CacheEntry entry = _cache.get(source); |
| 950 if (entry == null) { | 937 if (entry == null) { |
| 951 return false; | 938 return false; |
| 952 } | 939 } |
| 953 bool changed = newContents != originalContents; | 940 bool changed = newContents != originalContents; |
| 954 if (newContents != null) { | 941 if (newContents != null) { |
| 955 if (newContents != originalContents) { | 942 if (newContents != originalContents) { |
| 956 _incrementalAnalysisCache = | |
| 957 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source); | |
| 958 if (!analysisOptions.incremental || | 943 if (!analysisOptions.incremental || |
| 959 !_tryPoorMansIncrementalResolution(source, newContents)) { | 944 !_tryPoorMansIncrementalResolution(source, newContents)) { |
| 960 _sourceChanged(source); | 945 _sourceChanged(source); |
| 961 } | 946 } |
| 962 entry.modificationTime = _contentCache.getModificationStamp(source); | 947 entry.modificationTime = _contentCache.getModificationStamp(source); |
| 963 entry.setValue(CONTENT, newContents, TargetedResult.EMPTY_LIST); | 948 entry.setValue(CONTENT, newContents, TargetedResult.EMPTY_LIST); |
| 964 } else { | 949 } else { |
| 965 entry.modificationTime = _contentCache.getModificationStamp(source); | 950 entry.modificationTime = _contentCache.getModificationStamp(source); |
| 966 } | 951 } |
| 967 } else if (originalContents != null) { | 952 } else if (originalContents != null) { |
| 968 _incrementalAnalysisCache = | |
| 969 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source); | |
| 970 changed = newContents != originalContents; | 953 changed = newContents != originalContents; |
| 971 // We are removing the overlay for the file, check if the file's | 954 // We are removing the overlay for the file, check if the file's |
| 972 // contents is the same as it was in the overlay. | 955 // contents is the same as it was in the overlay. |
| 973 try { | 956 try { |
| 974 TimestampedData<String> fileContents = getContents(source); | 957 TimestampedData<String> fileContents = getContents(source); |
| 975 String fileContentsData = fileContents.data; | 958 String fileContentsData = fileContents.data; |
| 976 if (fileContentsData == originalContents) { | 959 if (fileContentsData == originalContents) { |
| 977 entry.setValue(CONTENT, fileContentsData, TargetedResult.EMPTY_LIST); | 960 entry.setValue(CONTENT, fileContentsData, TargetedResult.EMPTY_LIST); |
| 978 entry.modificationTime = fileContents.modificationTime; | 961 entry.modificationTime = fileContents.modificationTime; |
| 979 changed = false; | 962 changed = false; |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1417 // } | 1400 // } |
| 1418 _sourceChanged(source); | 1401 _sourceChanged(source); |
| 1419 changed = true; | 1402 changed = true; |
| 1420 CacheEntry entry = _cache.get(source); | 1403 CacheEntry entry = _cache.get(source); |
| 1421 if (entry != null) { | 1404 if (entry != null) { |
| 1422 entry.modificationTime = _contentCache.getModificationStamp(source); | 1405 entry.modificationTime = _contentCache.getModificationStamp(source); |
| 1423 entry.setValue(CONTENT, contents, TargetedResult.EMPTY_LIST); | 1406 entry.setValue(CONTENT, contents, TargetedResult.EMPTY_LIST); |
| 1424 } | 1407 } |
| 1425 } | 1408 } |
| 1426 } else if (originalContents != null) { | 1409 } else if (originalContents != null) { |
| 1427 _incrementalAnalysisCache = | |
| 1428 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source); | |
| 1429 _sourceChanged(source); | 1410 _sourceChanged(source); |
| 1430 changed = true; | 1411 changed = true; |
| 1431 } | 1412 } |
| 1432 return changed; | 1413 return changed; |
| 1433 } | 1414 } |
| 1434 | 1415 |
| 1435 /** | 1416 /** |
| 1436 * Set the contents of the given [source] to the given [contents] and mark the | 1417 * Set the contents of the given [source] to the given [contents] and mark the |
| 1437 * source as having changed. This has the effect of overriding the default | 1418 * source as having changed. This has the effect of overriding the default |
| 1438 * contents of the source. If the contents are `null` the override is removed | 1419 * contents of the source. If the contents are `null` the override is removed |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2043 new PendingFuture<T>(_context, target, computeValue); | 2024 new PendingFuture<T>(_context, target, computeValue); |
| 2044 if (!pendingFuture.evaluate(entry)) { | 2025 if (!pendingFuture.evaluate(entry)) { |
| 2045 _context._pendingFutureTargets | 2026 _context._pendingFutureTargets |
| 2046 .putIfAbsent(target, () => <PendingFuture>[]) | 2027 .putIfAbsent(target, () => <PendingFuture>[]) |
| 2047 .add(pendingFuture); | 2028 .add(pendingFuture); |
| 2048 scheduleComputation(); | 2029 scheduleComputation(); |
| 2049 } | 2030 } |
| 2050 return pendingFuture.future; | 2031 return pendingFuture.future; |
| 2051 } | 2032 } |
| 2052 } | 2033 } |
| OLD | NEW |