Chromium Code Reviews| 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:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/generated/engine.dart' | 9 import 'package:analyzer/src/generated/engine.dart' |
| 10 show AnalysisEngine, CacheState, InternalAnalysisContext, RetentionPriority; | 10 show AnalysisEngine, CacheState, InternalAnalysisContext, RetentionPriority; |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 418 } | 418 } |
| 419 } | 419 } |
| 420 } | 420 } |
| 421 | 421 |
| 422 /** | 422 /** |
| 423 * Set the value of the result represented by the given [descriptor] to the | 423 * Set the value of the result represented by the given [descriptor] to the |
| 424 * given [value]. | 424 * given [value]. |
| 425 */ | 425 */ |
| 426 /*<V>*/ void setValue(ResultDescriptor /*<V>*/ descriptor, dynamic /*V*/ | 426 /*<V>*/ void setValue(ResultDescriptor /*<V>*/ descriptor, dynamic /*V*/ |
| 427 value, List<TargetedResult> dependedOn) { | 427 value, List<TargetedResult> dependedOn) { |
| 428 // { | |
|
Brian Wilkerson
2015/06/05 18:24:48
Did you intend to include this debugging code?
scheglov
2015/06/05 18:28:24
Yes, I did.
I find it often useful for debugging.
| |
| 429 // String valueStr = '$value'; | |
| 430 // if (valueStr.length > 20) { | |
| 431 // valueStr = valueStr.substring(0, 20) + '...'; | |
| 432 // } | |
| 433 // valueStr = valueStr.replaceAll('\n', '\\n'); | |
| 434 // print( | |
| 435 // 'setValue $descriptor for $target value=$valueStr deps=$dependedOn') ; | |
| 436 // } | |
| 428 _validateStateChange(descriptor, CacheState.VALID); | 437 _validateStateChange(descriptor, CacheState.VALID); |
| 429 TargetedResult thisResult = new TargetedResult(target, descriptor); | 438 TargetedResult thisResult = new TargetedResult(target, descriptor); |
| 430 if (_partition != null) { | 439 if (_partition != null) { |
| 431 _partition.resultStored(thisResult, value); | 440 _partition.resultStored(thisResult, value); |
| 432 } | 441 } |
| 433 ResultData data = getResultData(descriptor); | 442 ResultData data = getResultData(descriptor); |
| 434 _setDependedOnResults(data, thisResult, dependedOn); | 443 _setDependedOnResults(data, thisResult, dependedOn); |
| 435 data.state = CacheState.VALID; | 444 data.state = CacheState.VALID; |
| 436 data.value = value == null ? descriptor.defaultValue : value; | 445 data.value = value == null ? descriptor.defaultValue : value; |
| 437 } | 446 } |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 457 /** | 466 /** |
| 458 * Return the value of the flag with the given [index]. | 467 * Return the value of the flag with the given [index]. |
| 459 */ | 468 */ |
| 460 bool _getFlag(int index) => BooleanArray.get(_flags, index); | 469 bool _getFlag(int index) => BooleanArray.get(_flags, index); |
| 461 | 470 |
| 462 /** | 471 /** |
| 463 * Invalidate the result represented by the given [descriptor] and propagate | 472 * Invalidate the result represented by the given [descriptor] and propagate |
| 464 * invalidation to other results that depend on it. | 473 * invalidation to other results that depend on it. |
| 465 */ | 474 */ |
| 466 void _invalidate(ResultDescriptor descriptor) { | 475 void _invalidate(ResultDescriptor descriptor) { |
| 476 // print('invalidate $descriptor for $target'); | |
| 467 ResultData thisData = _resultMap.remove(descriptor); | 477 ResultData thisData = _resultMap.remove(descriptor); |
| 468 if (thisData == null) { | 478 if (thisData == null) { |
| 469 return; | 479 return; |
| 470 } | 480 } |
| 471 // Stop depending on other results. | 481 // Stop depending on other results. |
| 472 TargetedResult thisResult = new TargetedResult(target, descriptor); | 482 TargetedResult thisResult = new TargetedResult(target, descriptor); |
| 473 thisData.dependedOnResults.forEach((TargetedResult dependedOnResult) { | 483 thisData.dependedOnResults.forEach((TargetedResult dependedOnResult) { |
| 474 ResultData data = _partition._getDataFor(dependedOnResult, orNull: true); | 484 ResultData data = _partition._getDataFor(dependedOnResult, orNull: true); |
| 475 if (data != null) { | 485 if (data != null) { |
| 476 data.dependentResults.remove(thisResult); | 486 data.dependentResults.remove(thisResult); |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1051 void resultAccessed(TargetedResult result) {} | 1061 void resultAccessed(TargetedResult result) {} |
| 1052 | 1062 |
| 1053 @override | 1063 @override |
| 1054 List<TargetedResult> resultStored(TargetedResult newResult, newValue) { | 1064 List<TargetedResult> resultStored(TargetedResult newResult, newValue) { |
| 1055 return TargetedResult.EMPTY_LIST; | 1065 return TargetedResult.EMPTY_LIST; |
| 1056 } | 1066 } |
| 1057 | 1067 |
| 1058 @override | 1068 @override |
| 1059 void targetRemoved(AnalysisTarget target) {} | 1069 void targetRemoved(AnalysisTarget target) {} |
| 1060 } | 1070 } |
| OLD | NEW |