| 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/src/dart/element/element.dart' | 10 import 'package:analyzer/src/dart/element/element.dart' |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 */ | 308 */ |
| 309 int _flags = 0; | 309 int _flags = 0; |
| 310 | 310 |
| 311 /** | 311 /** |
| 312 * A table mapping result descriptors to the cached values of those results. | 312 * A table mapping result descriptors to the cached values of those results. |
| 313 */ | 313 */ |
| 314 Map<ResultDescriptor, ResultData> _resultMap = | 314 Map<ResultDescriptor, ResultData> _resultMap = |
| 315 new HashMap<ResultDescriptor, ResultData>(); | 315 new HashMap<ResultDescriptor, ResultData>(); |
| 316 | 316 |
| 317 CacheEntry(this.target) { | 317 CacheEntry(this.target) { |
| 318 if (target is ElementImpl) { | 318 _markAsCacheKey(target); |
| 319 (target as ElementImpl).setModifier(Modifier.CACHE_KEY, true); | |
| 320 } | |
| 321 } | 319 } |
| 322 | 320 |
| 323 /** | 321 /** |
| 324 * The exception that caused one or more values to have a state of | 322 * The exception that caused one or more values to have a state of |
| 325 * [CacheState.ERROR]. | 323 * [CacheState.ERROR]. |
| 326 */ | 324 */ |
| 327 CaughtException get exception => _exception; | 325 CaughtException get exception => _exception; |
| 328 | 326 |
| 329 /** | 327 /** |
| 330 * Return `true` if the source was explicitly added to the context or `false` | 328 * Return `true` if the source was explicitly added to the context or `false` |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 List<TargetedResult> dependentResults = thisData.dependentResults.toList(); | 623 List<TargetedResult> dependentResults = thisData.dependentResults.toList(); |
| 626 for (TargetedResult dependentResult in dependentResults) { | 624 for (TargetedResult dependentResult in dependentResults) { |
| 627 CacheEntry entry = _partition.get(dependentResult.target); | 625 CacheEntry entry = _partition.get(dependentResult.target); |
| 628 if (entry != null) { | 626 if (entry != null) { |
| 629 entry._invalidate(id, dependentResult.result, delta, level); | 627 entry._invalidate(id, dependentResult.result, delta, level); |
| 630 } | 628 } |
| 631 } | 629 } |
| 632 } | 630 } |
| 633 | 631 |
| 634 /** | 632 /** |
| 633 * If the given `target` is an element, mark it as being a cache key. |
| 634 */ |
| 635 void _markAsCacheKey(AnalysisTarget target) { |
| 636 if (target is ElementImpl) { |
| 637 target.setModifier(Modifier.CACHE_KEY, true); |
| 638 } |
| 639 } |
| 640 |
| 641 /** |
| 635 * Set the [dependedOn] on which this result depends. | 642 * Set the [dependedOn] on which this result depends. |
| 636 */ | 643 */ |
| 637 void _setDependedOnResults(ResultData thisData, TargetedResult thisResult, | 644 void _setDependedOnResults(ResultData thisData, TargetedResult thisResult, |
| 638 List<TargetedResult> dependedOn) { | 645 List<TargetedResult> dependedOn) { |
| 639 thisData.dependedOnResults.forEach((TargetedResult dependedOnResult) { | 646 thisData.dependedOnResults.forEach((TargetedResult dependedOnResult) { |
| 640 ResultData data = _partition._getDataFor(dependedOnResult); | 647 ResultData data = _partition._getDataFor(dependedOnResult); |
| 641 if (data != null) { | 648 if (data != null) { |
| 642 data.dependentResults.remove(thisResult); | 649 data.dependentResults.remove(thisResult); |
| 643 } | 650 } |
| 644 }); | 651 }); |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1271 void resultAccessed(TargetedResult result) {} | 1278 void resultAccessed(TargetedResult result) {} |
| 1272 | 1279 |
| 1273 @override | 1280 @override |
| 1274 List<TargetedResult> resultStored(TargetedResult newResult, newValue) { | 1281 List<TargetedResult> resultStored(TargetedResult newResult, newValue) { |
| 1275 return TargetedResult.EMPTY_LIST; | 1282 return TargetedResult.EMPTY_LIST; |
| 1276 } | 1283 } |
| 1277 | 1284 |
| 1278 @override | 1285 @override |
| 1279 void targetRemoved(AnalysisTarget target) {} | 1286 void targetRemoved(AnalysisTarget target) {} |
| 1280 } | 1287 } |
| OLD | NEW |