| 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 import 'dart:developer'; | 8 import 'dart:developer'; |
| 9 | 9 |
| 10 import 'package:analyzer/error/error.dart' show AnalysisError; | 10 import 'package:analyzer/error/error.dart' show AnalysisError; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 if (inputs == null || !inputs.containsKey(name)) { | 169 if (inputs == null || !inputs.containsKey(name)) { |
| 170 return null; | 170 return null; |
| 171 } | 171 } |
| 172 return inputs[name]; | 172 return inputs[name]; |
| 173 } | 173 } |
| 174 | 174 |
| 175 /** | 175 /** |
| 176 * Return the value of the input with the given [name]. Throw an exception if | 176 * Return the value of the input with the given [name]. Throw an exception if |
| 177 * the input value is not defined. | 177 * the input value is not defined. |
| 178 */ | 178 */ |
| 179 Object/*=E*/ getRequiredInput/*<E>*/(String name) { | 179 E getRequiredInput<E>(String name) { |
| 180 if (inputs == null || !inputs.containsKey(name)) { | 180 if (inputs == null || !inputs.containsKey(name)) { |
| 181 throw new AnalysisException("Could not $description: missing $name"); | 181 throw new AnalysisException("Could not $description: missing $name"); |
| 182 } | 182 } |
| 183 return inputs[name] as Object/*=E*/; | 183 return inputs[name] as E; |
| 184 } | 184 } |
| 185 | 185 |
| 186 /** | 186 /** |
| 187 * Return the source associated with the target. Throw an exception if | 187 * Return the source associated with the target. Throw an exception if |
| 188 * the target is not associated with a source. | 188 * the target is not associated with a source. |
| 189 */ | 189 */ |
| 190 Source getRequiredSource() { | 190 Source getRequiredSource() { |
| 191 Source source = target.source; | 191 Source source = target.source; |
| 192 if (source == null) { | 192 if (source == null) { |
| 193 throw new AnalysisException("Could not $description: missing source"); | 193 throw new AnalysisException("Could not $description: missing source"); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 * A description of an input to an [AnalysisTask] that can be used to compute | 361 * A description of an input to an [AnalysisTask] that can be used to compute |
| 362 * that input. | 362 * that input. |
| 363 * | 363 * |
| 364 * Clients may not extend, implement or mix-in this class. | 364 * Clients may not extend, implement or mix-in this class. |
| 365 */ | 365 */ |
| 366 abstract class ListTaskInput<E> implements TaskInput<List<E>> { | 366 abstract class ListTaskInput<E> implements TaskInput<List<E>> { |
| 367 /** | 367 /** |
| 368 * Return a task input that can be used to compute a flatten list whose | 368 * Return a task input that can be used to compute a flatten list whose |
| 369 * elements are combined [subListResult]'s associated with those elements. | 369 * elements are combined [subListResult]'s associated with those elements. |
| 370 */ | 370 */ |
| 371 ListTaskInput/*<V>*/ toFlattenListOf/*<V>*/( | 371 ListTaskInput<V> toFlattenListOf<V>(ListResultDescriptor<V> subListResult); |
| 372 ListResultDescriptor/*<V>*/ subListResult); | |
| 373 | 372 |
| 374 /** | 373 /** |
| 375 * Return a task input that can be used to compute a list whose elements are | 374 * Return a task input that can be used to compute a list whose elements are |
| 376 * the result of passing the elements of this input to the [mapper] function. | 375 * the result of passing the elements of this input to the [mapper] function. |
| 377 */ | 376 */ |
| 378 ListTaskInput/*<V>*/ toList/*<V>*/(UnaryFunction<E, dynamic/*=V*/ > mapper); | 377 ListTaskInput<V> toList<V>(UnaryFunction<E, V> mapper); |
| 379 | 378 |
| 380 /** | 379 /** |
| 381 * Return a task input that can be used to compute a list whose elements are | 380 * Return a task input that can be used to compute a list whose elements are |
| 382 * [valueResult]'s associated with those elements. | 381 * [valueResult]'s associated with those elements. |
| 383 */ | 382 */ |
| 384 ListTaskInput/*<V>*/ toListOf/*<V>*/(ResultDescriptor/*<V>*/ valueResult); | 383 ListTaskInput<V> toListOf<V>(ResultDescriptor<V> valueResult); |
| 385 | 384 |
| 386 /** | 385 /** |
| 387 * Return a task input that can be used to compute a map whose keys are the | 386 * Return a task input that can be used to compute a map whose keys are the |
| 388 * elements of this input and whose values are the result of passing the | 387 * elements of this input and whose values are the result of passing the |
| 389 * corresponding key to the [mapper] function. | 388 * corresponding key to the [mapper] function. |
| 390 */ | 389 */ |
| 391 MapTaskInput<E, dynamic/*=V*/ > toMap/*<V>*/( | 390 MapTaskInput<E, V> toMap<V>(UnaryFunction<E, V> mapper); |
| 392 UnaryFunction<E, dynamic/*=V*/ > mapper); | |
| 393 | 391 |
| 394 /** | 392 /** |
| 395 * Return a task input that can be used to compute a map whose keys are the | 393 * Return a task input that can be used to compute a map whose keys are the |
| 396 * elements of this input and whose values are the [valueResult]'s associated | 394 * elements of this input and whose values are the [valueResult]'s associated |
| 397 * with those elements. | 395 * with those elements. |
| 398 */ | 396 */ |
| 399 MapTaskInput<AnalysisTarget, dynamic/*=V*/ > toMapOf/*<V>*/( | 397 MapTaskInput<AnalysisTarget, V> toMapOf<V>(ResultDescriptor<V> valueResult); |
| 400 ResultDescriptor/*<V>*/ valueResult); | |
| 401 } | 398 } |
| 402 | 399 |
| 403 /** | 400 /** |
| 404 * A description of an input with a [Map] based values. | 401 * A description of an input with a [Map] based values. |
| 405 * | 402 * |
| 406 * Clients may not extend, implement or mix-in this class. | 403 * Clients may not extend, implement or mix-in this class. |
| 407 */ | 404 */ |
| 408 abstract class MapTaskInput<K, V> implements TaskInput<Map<K, V>> { | 405 abstract class MapTaskInput<K, V> implements TaskInput<Map<K, V>> { |
| 409 /** | 406 /** |
| 410 * [V] must be a [List]. | 407 * [V] must be a [List]. |
| 411 * Return a task input that can be used to compute a list whose elements are | 408 * Return a task input that can be used to compute a list whose elements are |
| 412 * the result of passing keys [K] and the corresponding elements of [V] to | 409 * the result of passing keys [K] and the corresponding elements of [V] to |
| 413 * the [mapper] function. | 410 * the [mapper] function. |
| 414 */ | 411 */ |
| 415 TaskInput<List/*<E>*/ > toFlattenList/*<E>*/( | 412 TaskInput<List<E>> toFlattenList<E>( |
| 416 BinaryFunction<K, dynamic /*element of V*/, dynamic/*=E*/ > mapper); | 413 BinaryFunction<K, dynamic /*element of V*/, E> mapper); |
| 417 } | 414 } |
| 418 | 415 |
| 419 /** | 416 /** |
| 420 * Instances of this class are thrown when a task detects that the modification | 417 * Instances of this class are thrown when a task detects that the modification |
| 421 * time of a cache entry is not the same as the actual modification time. This | 418 * time of a cache entry is not the same as the actual modification time. This |
| 422 * means that any analysis results based on the content of the target cannot be | 419 * means that any analysis results based on the content of the target cannot be |
| 423 * used anymore and must be invalidated. | 420 * used anymore and must be invalidated. |
| 424 */ | 421 */ |
| 425 class ModificationTimeMismatchError { | 422 class ModificationTimeMismatchError { |
| 426 final Source source; | 423 final Source source; |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 abstract class TaskInput<V> { | 597 abstract class TaskInput<V> { |
| 601 /** | 598 /** |
| 602 * Create and return a builder that can be used to build this task input. | 599 * Create and return a builder that can be used to build this task input. |
| 603 */ | 600 */ |
| 604 TaskInputBuilder<V> createBuilder(); | 601 TaskInputBuilder<V> createBuilder(); |
| 605 | 602 |
| 606 /** | 603 /** |
| 607 * Return a task input that can be used to compute a list whose elements are | 604 * Return a task input that can be used to compute a list whose elements are |
| 608 * the result of passing the result of this input to the [mapper] function. | 605 * the result of passing the result of this input to the [mapper] function. |
| 609 */ | 606 */ |
| 610 ListTaskInput/*<E>*/ mappedToList/*<E>*/(List/*<E>*/ mapper(V value)); | 607 ListTaskInput<E> mappedToList<E>(List<E> mapper(V value)); |
| 611 } | 608 } |
| 612 | 609 |
| 613 /** | 610 /** |
| 614 * An object used to build the value associated with a single [TaskInput]. | 611 * An object used to build the value associated with a single [TaskInput]. |
| 615 * | 612 * |
| 616 * All builders work by requesting one or more results (each result being | 613 * All builders work by requesting one or more results (each result being |
| 617 * associated with a target). The interaction pattern is modeled after the class | 614 * associated with a target). The interaction pattern is modeled after the class |
| 618 * [Iterator], in which the method [moveNext] is invoked to move from one result | 615 * [Iterator], in which the method [moveNext] is invoked to move from one result |
| 619 * request to the next. The getters [currentResult] and [currentTarget] are used | 616 * request to the next. The getters [currentResult] and [currentTarget] are used |
| 620 * to get the result and target of the current request. The value of the result | 617 * to get the result and target of the current request. The value of the result |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 /** | 774 /** |
| 778 * A work should be done, but without any special urgency. | 775 * A work should be done, but without any special urgency. |
| 779 */ | 776 */ |
| 780 NORMAL, | 777 NORMAL, |
| 781 | 778 |
| 782 /** | 779 /** |
| 783 * Nothing to do. | 780 * Nothing to do. |
| 784 */ | 781 */ |
| 785 NONE | 782 NONE |
| 786 } | 783 } |
| OLD | NEW |