| 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.cache; | 5 library analyzer.src.context.cache; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'package:analyzer/file_system/file_system.dart'; | 10 import 'package:analyzer/file_system/file_system.dart'; |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 * A bit-encoding of boolean flags associated with this entry's target. | 339 * A bit-encoding of boolean flags associated with this entry's target. |
| 340 */ | 340 */ |
| 341 int _flags = 0; | 341 int _flags = 0; |
| 342 | 342 |
| 343 /** | 343 /** |
| 344 * A table mapping result descriptors to the cached values of those results. | 344 * A table mapping result descriptors to the cached values of those results. |
| 345 */ | 345 */ |
| 346 Map<ResultDescriptor, ResultData> _resultMap = | 346 Map<ResultDescriptor, ResultData> _resultMap = |
| 347 new HashMap<ResultDescriptor, ResultData>(); | 347 new HashMap<ResultDescriptor, ResultData>(); |
| 348 | 348 |
| 349 CacheEntry(this.target) { | 349 CacheEntry(this.target); |
| 350 _markAsCacheKey(target); | |
| 351 } | |
| 352 | 350 |
| 353 /** | 351 /** |
| 354 * The exception that caused one or more values to have a state of | 352 * The exception that caused one or more values to have a state of |
| 355 * [CacheState.ERROR]. | 353 * [CacheState.ERROR]. |
| 356 */ | 354 */ |
| 357 CaughtException get exception => _exception; | 355 CaughtException get exception => _exception; |
| 358 | 356 |
| 359 /** | 357 /** |
| 360 * Return `true` if the source was explicitly added to the context or `false` | 358 * Return `true` if the source was explicitly added to the context or `false` |
| 361 * if the source was implicitly added because it was referenced by another | 359 * if the source was implicitly added because it was referenced by another |
| (...skipping 28 matching lines...) Expand all Loading... |
| 390 ResultData data = | 388 ResultData data = |
| 391 entry.getResultDataOrNull(dependedOnResult.result); | 389 entry.getResultDataOrNull(dependedOnResult.result); |
| 392 if (data != null) { | 390 if (data != null) { |
| 393 data.dependentResults.remove(result); | 391 data.dependentResults.remove(result); |
| 394 } | 392 } |
| 395 } | 393 } |
| 396 } | 394 } |
| 397 } | 395 } |
| 398 }); | 396 }); |
| 399 _resultMap.clear(); | 397 _resultMap.clear(); |
| 400 AnalysisTarget oldTarget = target; | |
| 401 if (oldTarget is ElementImpl) { | |
| 402 oldTarget.setModifier(Modifier.CACHE_KEY, false); | |
| 403 } | |
| 404 } | 398 } |
| 405 | 399 |
| 406 /** | 400 /** |
| 407 * Fix the state of the [exception] to match the current state of the entry. | 401 * Fix the state of the [exception] to match the current state of the entry. |
| 408 */ | 402 */ |
| 409 void fixExceptionState() { | 403 void fixExceptionState() { |
| 410 if (!hasErrorState()) { | 404 if (!hasErrorState()) { |
| 411 _exception = null; | 405 _exception = null; |
| 412 } | 406 } |
| 413 } | 407 } |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 AnalysisCache cache = caches[j]; | 742 AnalysisCache cache = caches[j]; |
| 749 CacheEntry entry = cache.get(dependentResult.target); | 743 CacheEntry entry = cache.get(dependentResult.target); |
| 750 if (entry != null) { | 744 if (entry != null) { |
| 751 entry._invalidate(id, dependentResult.result, delta, level); | 745 entry._invalidate(id, dependentResult.result, delta, level); |
| 752 } | 746 } |
| 753 } | 747 } |
| 754 } | 748 } |
| 755 } | 749 } |
| 756 | 750 |
| 757 /** | 751 /** |
| 758 * If the given `target` is an element, mark it as being a cache key. | |
| 759 */ | |
| 760 void _markAsCacheKey(AnalysisTarget target) { | |
| 761 if (target is ElementImpl) { | |
| 762 target.setModifier(Modifier.CACHE_KEY, true); | |
| 763 } | |
| 764 } | |
| 765 | |
| 766 /** | |
| 767 * Set the [dependedOn] on which this result depends. | 752 * Set the [dependedOn] on which this result depends. |
| 768 */ | 753 */ |
| 769 void _setDependedOnResults(ResultData thisData, TargetedResult thisResult, | 754 void _setDependedOnResults(ResultData thisData, TargetedResult thisResult, |
| 770 List<TargetedResult> dependedOn) { | 755 List<TargetedResult> dependedOn) { |
| 771 List<AnalysisCache> caches = _partition.containingCaches; | 756 List<AnalysisCache> caches = _partition.containingCaches; |
| 772 int cacheLength = caches.length; | 757 int cacheLength = caches.length; |
| 773 | 758 |
| 774 List<TargetedResult> oldResults = thisData.dependedOnResults; | 759 List<TargetedResult> oldResults = thisData.dependedOnResults; |
| 775 int oldLength = oldResults.length; | 760 int oldLength = oldResults.length; |
| 776 for (int i = 0; i < oldLength; i++) { | 761 for (int i = 0; i < oldLength; i++) { |
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1507 void resultAccessed(TargetedResult result) {} | 1492 void resultAccessed(TargetedResult result) {} |
| 1508 | 1493 |
| 1509 @override | 1494 @override |
| 1510 List<TargetedResult> resultStored(TargetedResult newResult, newValue) { | 1495 List<TargetedResult> resultStored(TargetedResult newResult, newValue) { |
| 1511 return TargetedResult.EMPTY_LIST; | 1496 return TargetedResult.EMPTY_LIST; |
| 1512 } | 1497 } |
| 1513 | 1498 |
| 1514 @override | 1499 @override |
| 1515 void targetRemoved(AnalysisTarget target) {} | 1500 void targetRemoved(AnalysisTarget target) {} |
| 1516 } | 1501 } |
| OLD | NEW |