Index: packages/analyzer/test/src/task/test_support.dart |
diff --git a/packages/analyzer/test/src/task/test_support.dart b/packages/analyzer/test/src/task/test_support.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e68952b9e13fb6520b45cbd765ffd23847a4ea33 |
--- /dev/null |
+++ b/packages/analyzer/test/src/task/test_support.dart |
@@ -0,0 +1,63 @@ |
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+ |
+library test.src.task.test_support; |
+ |
+import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; |
+import 'package:analyzer/src/generated/java_engine.dart'; |
+import 'package:analyzer/task/model.dart'; |
+ |
+/** |
+ * A configurable analysis task that can be used by tests. |
+ */ |
+class TestAnalysisTask extends AnalysisTask { |
+ /** |
+ * The descriptor describing this task. |
+ */ |
+ TaskDescriptor descriptor; |
+ |
+ /** |
+ * The exception that is to be "thrown" by this task. |
+ */ |
+ CaughtException exception; |
+ |
+ /** |
+ * The results whose values are to be provided as outputs from this task. |
+ */ |
+ List<ResultDescriptor> results; |
+ |
+ /** |
+ * The next value that is to be used for a result. |
+ */ |
+ int value; |
+ |
+ @override |
+ final bool handlesDependencyCycles; |
+ |
+ TestAnalysisTask(AnalysisContext context, AnalysisTarget target, |
+ {this.descriptor, |
+ this.exception, |
+ this.handlesDependencyCycles: false, |
+ this.results, |
+ this.value: 1}) |
+ : super(context, target); |
+ |
+ @override |
+ String get description => 'Test task'; |
+ |
+ @override |
+ internalPerform() { |
+ if (exception != null) { |
+ caughtException = exception; |
+ } else if (results != null) { |
+ for (ResultDescriptor result in results) { |
+ outputs[result] = value++; |
+ } |
+ } else if (descriptor != null) { |
+ for (ResultDescriptor result in descriptor.results) { |
+ outputs[result] = value++; |
+ } |
+ } |
+ } |
+} |