Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Unified Diff: pkg/analyzer/lib/src/task/general.dart

Issue 812733004: Initial task support (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/task/inputs.dart » ('j') | pkg/analyzer/lib/src/task/inputs.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/task/general.dart
diff --git a/pkg/analyzer/lib/src/task/general.dart b/pkg/analyzer/lib/src/task/general.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ac61a3ccd9a4749b705edb94e476ff8b77a941d9
--- /dev/null
+++ b/pkg/analyzer/lib/src/task/general.dart
@@ -0,0 +1,71 @@
+// 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 analyzer.src.task.general;
+
+import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask;
+import 'package:analyzer/src/generated/java_engine.dart';
+import 'package:analyzer/src/generated/source.dart';
+import 'package:analyzer/task/general.dart';
+import 'package:analyzer/task/model.dart';
+
+/**
+ * The description of the task used to get the content of a source.
+ */
+final TaskDescriptor GET_CONTENT = new TaskDescriptor(
+ 'GET_CONTENT',
+ GetContentTask.createTask,
+ GetContentTask.buildInputs,
+ <ResultDescriptor>[CONTENT, MODIFICATION_TIME]);
+
+/**
+ * A task that gets the contents of the source associated with an analysis
+ * target.
+ */
+class GetContentTask extends AnalysisTask {
+ /**
+ * Initialize a newly created task to access the content of the source
+ * associated with the given [target] in the given [context].
+ */
+ GetContentTask(InternalAnalysisContext context, AnalysisTarget target)
+ : super(context, target);
+
+ @override
+ String get description {
+ Source source = this.source;
+ if (source == null) {
+ return "get contents of <unknown source>";
+ }
+ return "get contents of ${source.fullName}";
+ }
+
+ @override
+ internalPerform() {
+ Source source = target.source;
+ if (source == null) {
+ throw new AnalysisException(
+ "Could not get contents: no source associated with the target");
+ }
+ TimestampedData<String> data = context.getContents(source);
+ outputs[CONTENT] = data.data;
+ outputs[MODIFICATION_TIME] = data.modificationTime;
+ }
+
+ /**
+ * Return a map from the names of the inputs of this kind of task to the task
+ * input descriptors describing those inputs for a task with the given [target].
+ */
+ static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
+ return <String, TaskInput>{};
+ }
+
+ /**
+ * Create a [GetContentTask] based on the given [target] in the given
+ * [context].
+ */
+ static GetContentTask createTask(AnalysisContext context,
+ AnalysisTarget target) {
+ return new GetContentTask(context, target);
+ }
+}
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/task/inputs.dart » ('j') | pkg/analyzer/lib/src/task/inputs.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698