OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library test.src.task.test_support; |
| 6 |
| 7 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; |
| 8 import 'package:analyzer/src/generated/java_engine.dart'; |
| 9 import 'package:analyzer/task/model.dart'; |
| 10 |
| 11 /** |
| 12 * A configurable analysis task that can be used by tests. |
| 13 */ |
| 14 class TestAnalysisTask extends AnalysisTask { |
| 15 /** |
| 16 * The descriptor describing this task. |
| 17 */ |
| 18 TaskDescriptor descriptor; |
| 19 |
| 20 /** |
| 21 * The exception that is to be "thrown" by this task. |
| 22 */ |
| 23 CaughtException exception; |
| 24 |
| 25 /** |
| 26 * The results whose values are to be provided as outputs from this task. |
| 27 */ |
| 28 List<ResultDescriptor> results; |
| 29 |
| 30 /** |
| 31 * The next value that is to be used for a result. |
| 32 */ |
| 33 int value; |
| 34 |
| 35 @override |
| 36 final bool handlesDependencyCycles; |
| 37 |
| 38 TestAnalysisTask(AnalysisContext context, AnalysisTarget target, |
| 39 {this.descriptor, |
| 40 this.exception, |
| 41 this.handlesDependencyCycles: false, |
| 42 this.results, |
| 43 this.value: 1}) |
| 44 : super(context, target); |
| 45 |
| 46 @override |
| 47 String get description => 'Test task'; |
| 48 |
| 49 @override |
| 50 internalPerform() { |
| 51 if (exception != null) { |
| 52 caughtException = exception; |
| 53 } else if (results != null) { |
| 54 for (ResultDescriptor result in results) { |
| 55 outputs[result] = value++; |
| 56 } |
| 57 } else if (descriptor != null) { |
| 58 for (ResultDescriptor result in descriptor.results) { |
| 59 outputs[result] = value++; |
| 60 } |
| 61 } |
| 62 } |
| 63 } |
OLD | NEW |