| 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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 * referenced by another source. | 279 * referenced by another source. |
| 280 */ | 280 */ |
| 281 static int _EXPLICITLY_ADDED_FLAG = 0; | 281 static int _EXPLICITLY_ADDED_FLAG = 0; |
| 282 | 282 |
| 283 /** | 283 /** |
| 284 * The next invalidation process identifier. | 284 * The next invalidation process identifier. |
| 285 */ | 285 */ |
| 286 static int nextInvalidateId = 0; | 286 static int nextInvalidateId = 0; |
| 287 | 287 |
| 288 /** | 288 /** |
| 289 * A table containing the number of times the value of a result descriptor was |
| 290 * recomputed after having been flushed. |
| 291 */ |
| 292 static final Map<ResultDescriptor, int> recomputedCounts = |
| 293 new HashMap<ResultDescriptor, int>(); |
| 294 |
| 295 /** |
| 289 * The target this entry is about. | 296 * The target this entry is about. |
| 290 */ | 297 */ |
| 291 final AnalysisTarget target; | 298 final AnalysisTarget target; |
| 292 | 299 |
| 293 /** | 300 /** |
| 294 * The partition that is responsible for this entry. | 301 * The partition that is responsible for this entry. |
| 295 */ | 302 */ |
| 296 CachePartition _partition; | 303 CachePartition _partition; |
| 297 | 304 |
| 298 /** | 305 /** |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 // print( | 530 // print( |
| 524 // 'setValue $descriptor for $target value=$valueStr $dependedOn=$depen
dedOn'); | 531 // 'setValue $descriptor for $target value=$valueStr $dependedOn=$depen
dedOn'); |
| 525 // } | 532 // } |
| 526 _validateStateChange(descriptor, CacheState.VALID); | 533 _validateStateChange(descriptor, CacheState.VALID); |
| 527 TargetedResult thisResult = new TargetedResult(target, descriptor); | 534 TargetedResult thisResult = new TargetedResult(target, descriptor); |
| 528 if (_partition != null) { | 535 if (_partition != null) { |
| 529 _partition.resultStored(thisResult, value); | 536 _partition.resultStored(thisResult, value); |
| 530 } | 537 } |
| 531 ResultData data = getResultData(descriptor); | 538 ResultData data = getResultData(descriptor); |
| 532 _setDependedOnResults(data, thisResult, dependedOn); | 539 _setDependedOnResults(data, thisResult, dependedOn); |
| 540 if (data.state == CacheState.FLUSHED) { |
| 541 int count = recomputedCounts[descriptor] ?? 0; |
| 542 recomputedCounts[descriptor] = count + 1; |
| 543 } |
| 533 data.state = CacheState.VALID; | 544 data.state = CacheState.VALID; |
| 534 data.value = value ?? descriptor.defaultValue; | 545 data.value = value ?? descriptor.defaultValue; |
| 535 } | 546 } |
| 536 | 547 |
| 537 /** | 548 /** |
| 538 * If the result represented by the given [descriptor] is valid, set | 549 * If the result represented by the given [descriptor] is valid, set |
| 539 * it to the given [value], keep its dependency, and if [invalidateDependent] | 550 * it to the given [value], keep its dependency, and if [invalidateDependent] |
| 540 * invalidate all the dependent result. | 551 * invalidate all the dependent result. |
| 541 */ | 552 */ |
| 542 void setValueIncremental( | 553 void setValueIncremental( |
| (...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1349 void resultAccessed(TargetedResult result) {} | 1360 void resultAccessed(TargetedResult result) {} |
| 1350 | 1361 |
| 1351 @override | 1362 @override |
| 1352 List<TargetedResult> resultStored(TargetedResult newResult, newValue) { | 1363 List<TargetedResult> resultStored(TargetedResult newResult, newValue) { |
| 1353 return TargetedResult.EMPTY_LIST; | 1364 return TargetedResult.EMPTY_LIST; |
| 1354 } | 1365 } |
| 1355 | 1366 |
| 1356 @override | 1367 @override |
| 1357 void targetRemoved(AnalysisTarget target) {} | 1368 void targetRemoved(AnalysisTarget target) {} |
| 1358 } | 1369 } |
| OLD | NEW |