| 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' |
| 11 show ElementImpl, Modifier; | 11 show ElementImpl, Modifier; |
| 12 import 'package:analyzer/src/generated/engine.dart'; | 12 import 'package:analyzer/src/generated/engine.dart'; |
| 13 import 'package:analyzer/src/generated/java_engine.dart'; | 13 import 'package:analyzer/src/generated/java_engine.dart'; |
| 14 import 'package:analyzer/src/generated/source.dart'; | 14 import 'package:analyzer/src/generated/source.dart'; |
| 15 import 'package:analyzer/src/generated/utilities_collection.dart'; | 15 import 'package:analyzer/src/generated/utilities_collection.dart'; |
| 16 import 'package:analyzer/src/task/model.dart'; | 16 import 'package:analyzer/src/task/model.dart'; |
| 17 import 'package:analyzer/task/dart.dart'; |
| 17 import 'package:analyzer/task/model.dart'; | 18 import 'package:analyzer/task/model.dart'; |
| 18 | 19 |
| 19 /** | 20 /** |
| 20 * Return `true` if the [result] of the [target] should be flushed. | 21 * Return `true` if the [result] of the [target] should be flushed. |
| 21 */ | 22 */ |
| 22 typedef bool FlushResultFilter<V>( | 23 typedef bool FlushResultFilter<V>( |
| 23 AnalysisTarget target, ResultDescriptor<V> result); | 24 AnalysisTarget target, ResultDescriptor<V> result); |
| 24 | 25 |
| 25 /** | 26 /** |
| 26 * Return `true` if the given [target] is a priority one. | 27 * Return `true` if the given [target] is a priority one. |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 */ | 307 */ |
| 307 static final Map<ResultDescriptor, int> recomputedCounts = | 308 static final Map<ResultDescriptor, int> recomputedCounts = |
| 308 new HashMap<ResultDescriptor, int>(); | 309 new HashMap<ResultDescriptor, int>(); |
| 309 | 310 |
| 310 /** | 311 /** |
| 311 * The target this entry is about. | 312 * The target this entry is about. |
| 312 */ | 313 */ |
| 313 final AnalysisTarget target; | 314 final AnalysisTarget target; |
| 314 | 315 |
| 315 /** | 316 /** |
| 317 * A library specific unit associated with the target if the target is a |
| 318 * [Source], or `null` if the target is not a [Source] or if a library |
| 319 * specific unit for the source has not yet been computed. |
| 320 */ |
| 321 LibrarySpecificUnit librarySpecificUnit; |
| 322 |
| 323 /** |
| 316 * The partition that is responsible for this entry. | 324 * The partition that is responsible for this entry. |
| 317 */ | 325 */ |
| 318 CachePartition _partition; | 326 CachePartition _partition; |
| 319 | 327 |
| 320 /** | 328 /** |
| 321 * The most recent time at which the state of the target matched the state | 329 * The most recent time at which the state of the target matched the state |
| 322 * represented by this entry, `-1` if the target does not exist. | 330 * represented by this entry, `-1` if the target does not exist. |
| 323 */ | 331 */ |
| 324 int modificationTime = -1; | 332 int modificationTime = -1; |
| 325 | 333 |
| (...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 _removeIfSource(target); | 1102 _removeIfSource(target); |
| 1095 return entry; | 1103 return entry; |
| 1096 } | 1104 } |
| 1097 | 1105 |
| 1098 /** | 1106 /** |
| 1099 * Records that a value of the result described by the given [descriptor] | 1107 * Records that a value of the result described by the given [descriptor] |
| 1100 * for the given [target] was just read from the cache. | 1108 * for the given [target] was just read from the cache. |
| 1101 */ | 1109 */ |
| 1102 void resultAccessed(AnalysisTarget target, ResultDescriptor descriptor) { | 1110 void resultAccessed(AnalysisTarget target, ResultDescriptor descriptor) { |
| 1103 CacheFlushManager flushManager = _getFlushManager(descriptor); | 1111 CacheFlushManager flushManager = _getFlushManager(descriptor); |
| 1104 TargetedResult result = new TargetedResult(target, descriptor); | 1112 TargetedResult result = |
| 1113 new TargetedResult(context.canonicalizeTarget(target), descriptor); |
| 1105 flushManager.resultAccessed(result); | 1114 flushManager.resultAccessed(result); |
| 1106 } | 1115 } |
| 1107 | 1116 |
| 1108 /** | 1117 /** |
| 1109 * Records that the given [result] was just stored into the cache. | 1118 * Records that the given [result] was just stored into the cache. |
| 1110 */ | 1119 */ |
| 1111 void resultStored(TargetedResult result, Object value) { | 1120 void resultStored(TargetedResult result, Object value) { |
| 1112 CacheFlushManager flushManager = _getFlushManager(result.result); | 1121 CacheFlushManager flushManager = _getFlushManager(result.result); |
| 1113 List<TargetedResult> resultsToFlush = | 1122 List<TargetedResult> resultsToFlush = |
| 1114 flushManager.resultStored(result, value); | 1123 flushManager.resultStored(result, value); |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1400 void resultAccessed(TargetedResult result) {} | 1409 void resultAccessed(TargetedResult result) {} |
| 1401 | 1410 |
| 1402 @override | 1411 @override |
| 1403 List<TargetedResult> resultStored(TargetedResult newResult, newValue) { | 1412 List<TargetedResult> resultStored(TargetedResult newResult, newValue) { |
| 1404 return TargetedResult.EMPTY_LIST; | 1413 return TargetedResult.EMPTY_LIST; |
| 1405 } | 1414 } |
| 1406 | 1415 |
| 1407 @override | 1416 @override |
| 1408 void targetRemoved(AnalysisTarget target) {} | 1417 void targetRemoved(AnalysisTarget target) {} |
| 1409 } | 1418 } |
| OLD | NEW |