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.task.model; | 5 library analyzer.task.model; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; | 9 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; |
10 import 'package:analyzer/src/generated/java_engine.dart'; | 10 import 'package:analyzer/src/generated/java_engine.dart'; |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 * [AnalysisTask]. | 272 * [AnalysisTask]. |
273 * | 273 * |
274 * Clients are not expected to subtype this class. | 274 * Clients are not expected to subtype this class. |
275 */ | 275 */ |
276 abstract class ListResultDescriptor<E> implements ResultDescriptor<List<E>> { | 276 abstract class ListResultDescriptor<E> implements ResultDescriptor<List<E>> { |
277 /** | 277 /** |
278 * Initialize a newly created analysis result to have the given [name]. If a | 278 * Initialize a newly created analysis result to have the given [name]. If a |
279 * composite result is specified, then this result will contribute to it. | 279 * composite result is specified, then this result will contribute to it. |
280 */ | 280 */ |
281 factory ListResultDescriptor(String name, List<E> defaultValue, | 281 factory ListResultDescriptor(String name, List<E> defaultValue, |
282 {CompositeResultDescriptor<List<E>> contributesTo}) = ListResultDescriptor
Impl<E>; | 282 {CompositeResultDescriptor<List<E>> contributesTo, |
| 283 ResultCachingPolicy<List<E>> cachingPolicy}) = ListResultDescriptorImpl<E>
; |
283 | 284 |
284 @override | 285 @override |
285 ListTaskInput<E> of(AnalysisTarget target); | 286 ListTaskInput<E> of(AnalysisTarget target); |
286 } | 287 } |
287 | 288 |
288 /** | 289 /** |
289 * A description of an input to an [AnalysisTask] that can be used to compute | 290 * A description of an input to an [AnalysisTask] that can be used to compute |
290 * that input. | 291 * that input. |
291 * | 292 * |
292 * Clients are not expected to subtype this class. | 293 * Clients are not expected to subtype this class. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 * [V] must be a [List]. | 332 * [V] must be a [List]. |
332 * Return a task input that can be used to compute a list whose elements are | 333 * Return a task input that can be used to compute a list whose elements are |
333 * the result of passing keys [K] and the corresponding elements of [V] to | 334 * the result of passing keys [K] and the corresponding elements of [V] to |
334 * the [mapper] function. | 335 * the [mapper] function. |
335 */ | 336 */ |
336 TaskInput<List /*<E>*/ > toFlattenList( | 337 TaskInput<List /*<E>*/ > toFlattenList( |
337 BinaryFunction<K, dynamic /*element of V*/, dynamic /*<E>*/ > mapper); | 338 BinaryFunction<K, dynamic /*element of V*/, dynamic /*<E>*/ > mapper); |
338 } | 339 } |
339 | 340 |
340 /** | 341 /** |
| 342 * A policy object that can compute sizes of results and provide the maximum |
| 343 * active and idle sizes that can be kept in the cache. |
| 344 * |
| 345 * All the [ResultDescriptor]s with the same [ResultCachingPolicy] instance |
| 346 * share the same total size in a cache. |
| 347 */ |
| 348 abstract class ResultCachingPolicy<T> { |
| 349 /** |
| 350 * Return the maximum total size of results that can be kept in the cache |
| 351 * while analysis is in progress. |
| 352 */ |
| 353 int get maxActiveSize; |
| 354 |
| 355 /** |
| 356 * Return the maximum total size of results that can be kept in the cache |
| 357 * while analysis is idle. |
| 358 */ |
| 359 int get maxIdleSize; |
| 360 |
| 361 /** |
| 362 * Return the size of the given [object]. |
| 363 */ |
| 364 int measure(T object); |
| 365 } |
| 366 |
| 367 /** |
341 * A description of an analysis result that can be computed by an [AnalysisTask]
. | 368 * A description of an analysis result that can be computed by an [AnalysisTask]
. |
342 * | 369 * |
343 * Clients are not expected to subtype this class. | 370 * Clients are not expected to subtype this class. |
344 */ | 371 */ |
345 abstract class ResultDescriptor<V> { | 372 abstract class ResultDescriptor<V> { |
346 /** | 373 /** |
347 * Initialize a newly created analysis result to have the given [name]. If a | 374 * Initialize a newly created analysis result to have the given [name]. If a |
348 * composite result is specified, then this result will contribute to it. | 375 * composite result is specified, then this result will contribute to it. |
| 376 * |
| 377 * The given [cachingPolicy] is used to limit the total size of results |
| 378 * described by this descriptor. If no policy is specified, the results are |
| 379 * never evicted from the cache, and removed only when they are invalidated. |
349 */ | 380 */ |
350 factory ResultDescriptor(String name, V defaultValue, | 381 factory ResultDescriptor(String name, V defaultValue, |
351 {CompositeResultDescriptor<V> contributesTo}) = ResultDescriptorImpl; | 382 {CompositeResultDescriptor<V> contributesTo, |
| 383 ResultCachingPolicy<V> cachingPolicy}) = ResultDescriptorImpl; |
| 384 |
| 385 /** |
| 386 * Return the caching policy for results described by this descriptor. |
| 387 */ |
| 388 ResultCachingPolicy<V> get cachingPolicy; |
352 | 389 |
353 /** | 390 /** |
354 * Return the default value for results described by this descriptor. | 391 * Return the default value for results described by this descriptor. |
355 */ | 392 */ |
356 V get defaultValue; | 393 V get defaultValue; |
357 | 394 |
358 /** | 395 /** |
359 * Return the name of this descriptor. | 396 * Return the name of this descriptor. |
360 */ | 397 */ |
361 String get name; | 398 String get name; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 * be computed, or `false` if the inputs have been computed. | 505 * be computed, or `false` if the inputs have been computed. |
469 * | 506 * |
470 * It is safe to invoke [moveNext] after it has returned `false`. In this case | 507 * It is safe to invoke [moveNext] after it has returned `false`. In this case |
471 * [moveNext] has no effect and will again return `false`. | 508 * [moveNext] has no effect and will again return `false`. |
472 * | 509 * |
473 * Throws a [StateError] if the value of the current result has not been | 510 * Throws a [StateError] if the value of the current result has not been |
474 * provided using [currentValue]. | 511 * provided using [currentValue]. |
475 */ | 512 */ |
476 bool moveNext(); | 513 bool moveNext(); |
477 } | 514 } |
OLD | NEW |