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

Side by Side Diff: analyzer/lib/src/task/general.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « analyzer/lib/src/task/driver.dart ('k') | analyzer/lib/src/task/html.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/source.dart';
9 import 'package:analyzer/task/general.dart';
10 import 'package:analyzer/task/model.dart';
11
12 /**
13 * A task that gets the contents of the source associated with an analysis
14 * target.
15 */
16 class GetContentTask extends SourceBasedAnalysisTask {
17 /**
18 * The task descriptor describing this kind of task.
19 */
20 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor('GetContentTask',
21 createTask, buildInputs, <ResultDescriptor>[CONTENT, MODIFICATION_TIME]);
22
23 /**
24 * Initialize a newly created task to access the content of the source
25 * associated with the given [target] in the given [context].
26 */
27 GetContentTask(AnalysisContext context, AnalysisTarget target)
28 : super(context, target);
29
30 @override
31 TaskDescriptor get descriptor => DESCRIPTOR;
32
33 @override
34 internalPerform() {
35 Source source = getRequiredSource();
36 try {
37 TimestampedData<String> data = context.getContents(source);
38 outputs[CONTENT] = data.data;
39 outputs[MODIFICATION_TIME] = data.modificationTime;
40 } catch (exception) {
41 outputs[CONTENT] = '';
42 outputs[MODIFICATION_TIME] = -1;
43 }
44 }
45
46 /**
47 * Return a map from the names of the inputs of this kind of task to the task
48 * input descriptors describing those inputs for a task with the given [target ].
49 */
50 static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
51 return <String, TaskInput>{};
52 }
53
54 /**
55 * Create a [GetContentTask] based on the given [target] in the given
56 * [context].
57 */
58 static GetContentTask createTask(
59 AnalysisContext context, AnalysisTarget target) {
60 return new GetContentTask(context, target);
61 }
62 }
63
64 /**
65 * A base class for analysis tasks whose target is expected to be a source.
66 */
67 abstract class SourceBasedAnalysisTask extends AnalysisTask {
68 /**
69 * Initialize a newly created task to perform analysis within the given
70 * [context] in order to produce results for the given [target].
71 */
72 SourceBasedAnalysisTask(AnalysisContext context, AnalysisTarget target)
73 : super(context, target);
74
75 @override
76 String get description {
77 Source source = target.source;
78 String sourceName = source == null ? '<unknown source>' : source.fullName;
79 return '${descriptor.name} for source $sourceName';
80 }
81 }
OLDNEW
« no previous file with comments | « analyzer/lib/src/task/driver.dart ('k') | analyzer/lib/src/task/html.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698