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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 analyzer.src.task.general;
6
7 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask;
8 import 'package:analyzer/src/generated/java_engine.dart';
9 import 'package:analyzer/src/generated/source.dart';
10 import 'package:analyzer/task/general.dart';
11 import 'package:analyzer/task/model.dart';
12
13 /**
14 * The description of the task used to get the content of a source.
15 */
16 final TaskDescriptor GET_CONTENT = new TaskDescriptor(
17 'GET_CONTENT',
18 GetContentTask.createTask,
19 GetContentTask.buildInputs,
20 <ResultDescriptor>[CONTENT, MODIFICATION_TIME]);
21
22 /**
23 * A task that gets the contents of the source associated with an analysis
24 * target.
25 */
26 class GetContentTask extends AnalysisTask {
27 /**
28 * Initialize a newly created task to access the content of the source
29 * associated with the given [target] in the given [context].
30 */
31 GetContentTask(InternalAnalysisContext context, AnalysisTarget target)
32 : super(context, target);
33
34 @override
35 String get description {
36 Source source = this.source;
37 if (source == null) {
38 return "get contents of <unknown source>";
39 }
40 return "get contents of ${source.fullName}";
41 }
42
43 @override
44 internalPerform() {
45 Source source = target.source;
46 if (source == null) {
47 throw new AnalysisException(
48 "Could not get contents: no source associated with the target");
49 }
50 TimestampedData<String> data = context.getContents(source);
51 outputs[CONTENT] = data.data;
52 outputs[MODIFICATION_TIME] = data.modificationTime;
53 }
54
55 /**
56 * Return a map from the names of the inputs of this kind of task to the task
57 * input descriptors describing those inputs for a task with the given [target ].
58 */
59 static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
60 return <String, TaskInput>{};
61 }
62
63 /**
64 * Create a [GetContentTask] based on the given [target] in the given
65 * [context].
66 */
67 static GetContentTask createTask(AnalysisContext context,
68 AnalysisTarget target) {
69 return new GetContentTask(context, target);
70 }
71 }
OLDNEW
« 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