| 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/generated/engine.dart'; | 10 import 'package:analyzer/src/generated/engine.dart'; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 * An array containing the partitions of which this cache is comprised. | 33 * An array containing the partitions of which this cache is comprised. |
| 34 */ | 34 */ |
| 35 final List<CachePartition> _partitions; | 35 final List<CachePartition> _partitions; |
| 36 | 36 |
| 37 /** | 37 /** |
| 38 * The [StreamController] reporting [InvalidatedResult]s. | 38 * The [StreamController] reporting [InvalidatedResult]s. |
| 39 */ | 39 */ |
| 40 final ReentrantSynchronousStream<InvalidatedResult> onResultInvalidated = | 40 final ReentrantSynchronousStream<InvalidatedResult> onResultInvalidated = |
| 41 new ReentrantSynchronousStream<InvalidatedResult>(); | 41 new ReentrantSynchronousStream<InvalidatedResult>(); |
| 42 | 42 |
| 43 final List< | 43 final List<ReentrantSynchronousStreamSubscription> |
| 44 ReentrantSynchronousStreamSubscription> onResultInvalidatedPartitionSubscr
iptions = < | 44 onResultInvalidatedPartitionSubscriptions = |
| 45 ReentrantSynchronousStreamSubscription>[]; | 45 <ReentrantSynchronousStreamSubscription>[]; |
| 46 | 46 |
| 47 /** | 47 /** |
| 48 * Initialize a newly created cache to have the given [_partitions]. The | 48 * Initialize a newly created cache to have the given [_partitions]. The |
| 49 * partitions will be searched in the order in which they appear in the array, | 49 * partitions will be searched in the order in which they appear in the array, |
| 50 * so the most specific partition (usually an [SdkCachePartition]) should be | 50 * so the most specific partition (usually an [SdkCachePartition]) should be |
| 51 * first and the most general (usually a [UniversalCachePartition]) last. | 51 * first and the most general (usually a [UniversalCachePartition]) last. |
| 52 */ | 52 */ |
| 53 AnalysisCache(this._partitions) { | 53 AnalysisCache(this._partitions) { |
| 54 for (CachePartition partition in _partitions) { | 54 for (CachePartition partition in _partitions) { |
| 55 ReentrantSynchronousStreamSubscription<InvalidatedResult> subscription = | 55 ReentrantSynchronousStreamSubscription<InvalidatedResult> subscription = |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 if (data == null) { | 377 if (data == null) { |
| 378 return CacheState.INVALID; | 378 return CacheState.INVALID; |
| 379 } | 379 } |
| 380 return data.state; | 380 return data.state; |
| 381 } | 381 } |
| 382 | 382 |
| 383 /** | 383 /** |
| 384 * Return the value of the result represented by the given [descriptor], or | 384 * Return the value of the result represented by the given [descriptor], or |
| 385 * the default value for the result if this entry does not have a valid value. | 385 * the default value for the result if this entry does not have a valid value. |
| 386 */ | 386 */ |
| 387 /*<V>*/ dynamic /*V*/ getValue(ResultDescriptor /*<V>*/ descriptor) { | 387 dynamic /*=V*/ getValue /*<V>*/ (ResultDescriptor /*<V>*/ descriptor) { |
| 388 ResultData data = _resultMap[descriptor]; | 388 ResultData data = _resultMap[descriptor]; |
| 389 if (data == null) { | 389 if (data == null) { |
| 390 return descriptor.defaultValue; | 390 return descriptor.defaultValue; |
| 391 } | 391 } |
| 392 if (_partition != null) { | 392 if (_partition != null) { |
| 393 _partition.resultAccessed(target, descriptor); | 393 _partition.resultAccessed(target, descriptor); |
| 394 } | 394 } |
| 395 return data.value; | 395 return data.value; |
| 396 } | 396 } |
| 397 | 397 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 // | 475 // |
| 476 data.value = descriptor.defaultValue; | 476 data.value = descriptor.defaultValue; |
| 477 } | 477 } |
| 478 } | 478 } |
| 479 } | 479 } |
| 480 | 480 |
| 481 /** | 481 /** |
| 482 * Set the value of the result represented by the given [descriptor] to the | 482 * Set the value of the result represented by the given [descriptor] to the |
| 483 * given [value]. | 483 * given [value]. |
| 484 */ | 484 */ |
| 485 /*<V>*/ void setValue( | 485 void setValue /*<V>*/ (ResultDescriptor /*<V>*/ descriptor, |
| 486 ResultDescriptor /*<V>*/ descriptor, | 486 dynamic /*=V*/ value, List<TargetedResult> dependedOn) { |
| 487 dynamic /*V*/ | |
| 488 value, | |
| 489 List<TargetedResult> dependedOn) { | |
| 490 // { | 487 // { |
| 491 // String valueStr = '$value'; | 488 // String valueStr = '$value'; |
| 492 // if (valueStr.length > 20) { | 489 // if (valueStr.length > 20) { |
| 493 // valueStr = valueStr.substring(0, 20) + '...'; | 490 // valueStr = valueStr.substring(0, 20) + '...'; |
| 494 // } | 491 // } |
| 495 // valueStr = valueStr.replaceAll('\n', '\\n'); | 492 // valueStr = valueStr.replaceAll('\n', '\\n'); |
| 496 // print( | 493 // print( |
| 497 // 'setValue $descriptor for $target value=$valueStr $dependedOn=$depen
dedOn'); | 494 // 'setValue $descriptor for $target value=$valueStr $dependedOn=$depen
dedOn'); |
| 498 // } | 495 // } |
| 499 _validateStateChange(descriptor, CacheState.VALID); | 496 _validateStateChange(descriptor, CacheState.VALID); |
| (...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1255 void resultAccessed(TargetedResult result) {} | 1252 void resultAccessed(TargetedResult result) {} |
| 1256 | 1253 |
| 1257 @override | 1254 @override |
| 1258 List<TargetedResult> resultStored(TargetedResult newResult, newValue) { | 1255 List<TargetedResult> resultStored(TargetedResult newResult, newValue) { |
| 1259 return TargetedResult.EMPTY_LIST; | 1256 return TargetedResult.EMPTY_LIST; |
| 1260 } | 1257 } |
| 1261 | 1258 |
| 1262 @override | 1259 @override |
| 1263 void targetRemoved(AnalysisTarget target) {} | 1260 void targetRemoved(AnalysisTarget target) {} |
| 1264 } | 1261 } |
| OLD | NEW |