| 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 test.src.task.test_support; | 5 library test.src.task.test_support; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; | 7 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; |
| 8 import 'package:analyzer/src/generated/java_engine.dart'; |
| 8 import 'package:analyzer/task/model.dart'; | 9 import 'package:analyzer/task/model.dart'; |
| 9 | 10 |
| 11 /** |
| 12 * A configurable analysis task that can be used by tests. |
| 13 */ |
| 10 class TestAnalysisTask extends AnalysisTask { | 14 class TestAnalysisTask extends AnalysisTask { |
| 11 TestAnalysisTask(AnalysisContext context, AnalysisTarget target) | 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 = 1; |
| 34 |
| 35 TestAnalysisTask(AnalysisContext context, AnalysisTarget target, |
| 36 {this.descriptor, this.exception, this.results}) |
| 12 : super(context, target); | 37 : super(context, target); |
| 13 | 38 |
| 14 @override | 39 @override |
| 15 String get description => 'Test task'; | 40 String get description => 'Test task'; |
| 16 | 41 |
| 17 @override | 42 @override |
| 18 TaskDescriptor get descriptor => null; | |
| 19 | |
| 20 @override | |
| 21 internalPerform() { | 43 internalPerform() { |
| 44 if (exception != null) { |
| 45 caughtException = exception; |
| 46 } else if (results != null) { |
| 47 for (ResultDescriptor result in results) { |
| 48 outputs[result] = value++; |
| 49 } |
| 50 } else if (descriptor != null) { |
| 51 for (ResultDescriptor result in descriptor.results) { |
| 52 outputs[result] = value++; |
| 53 } |
| 54 } |
| 22 } | 55 } |
| 23 } | 56 } |
| OLD | NEW |