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

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

Issue 867563004: Improvements to task model (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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
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 analyzer.src.task.general; 5 library analyzer.src.task.general;
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';
9 import 'package:analyzer/src/generated/source.dart'; 8 import 'package:analyzer/src/generated/source.dart';
10 import 'package:analyzer/task/general.dart'; 9 import 'package:analyzer/task/general.dart';
11 import 'package:analyzer/task/model.dart'; 10 import 'package:analyzer/task/model.dart';
12 11
13 /** 12 /**
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 13 * A task that gets the contents of the source associated with an analysis
24 * target. 14 * target.
25 */ 15 */
26 class GetContentTask extends AnalysisTask { 16 class GetContentTask extends AnalysisTask {
27 /** 17 /**
18 * The task descriptor describing this kind of task.
19 */
20 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor(
21 'GET_CONTENT',
22 GetContentTask.createTask,
scheglov 2015/01/26 16:10:33 FYI, we don't need GetContentTask qualifier now. J
Brian Wilkerson 2015/01/26 16:14:12 It wasn't. Thanks! I've removed them.
23 GetContentTask.buildInputs,
24 <ResultDescriptor>[CONTENT, MODIFICATION_TIME]);
25
26 /**
28 * Initialize a newly created task to access the content of the source 27 * Initialize a newly created task to access the content of the source
29 * associated with the given [target] in the given [context]. 28 * associated with the given [target] in the given [context].
30 */ 29 */
31 GetContentTask(InternalAnalysisContext context, AnalysisTarget target) 30 GetContentTask(InternalAnalysisContext context, AnalysisTarget target)
32 : super(context, target); 31 : super(context, target);
33 32
34 @override 33 @override
35 String get description { 34 String get description {
36 Source source = target.source; 35 Source source = target.source;
37 if (source == null) { 36 if (source == null) {
38 return "get contents of <unknown source>"; 37 return "get contents of <unknown source>";
39 } 38 }
40 return "get contents of ${source.fullName}"; 39 return "get contents of ${source.fullName}";
41 } 40 }
42 41
43 @override 42 @override
43 TaskDescriptor get descriptor => DESCRIPTOR;
44
45 @override
44 internalPerform() { 46 internalPerform() {
45 Source source = target.source; 47 Source source = getRequiredSource();
46 if (source == null) { 48
47 throw new AnalysisException(
48 "Could not get contents: no source associated with the target");
49 }
50 TimestampedData<String> data = context.getContents(source); 49 TimestampedData<String> data = context.getContents(source);
51 outputs[CONTENT] = data.data; 50 outputs[CONTENT] = data.data;
52 outputs[MODIFICATION_TIME] = data.modificationTime; 51 outputs[MODIFICATION_TIME] = data.modificationTime;
53 } 52 }
54 53
55 /** 54 /**
56 * Return a map from the names of the inputs of this kind of task to the task 55 * 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 ]. 56 * input descriptors describing those inputs for a task with the given [target ].
58 */ 57 */
59 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { 58 static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
60 return <String, TaskInput>{}; 59 return <String, TaskInput>{};
61 } 60 }
62 61
63 /** 62 /**
64 * Create a [GetContentTask] based on the given [target] in the given 63 * Create a [GetContentTask] based on the given [target] in the given
65 * [context]. 64 * [context].
66 */ 65 */
67 static GetContentTask createTask(AnalysisContext context, 66 static GetContentTask createTask(AnalysisContext context,
68 AnalysisTarget target) { 67 AnalysisTarget target) {
69 return new GetContentTask(context, target); 68 return new GetContentTask(context, target);
70 } 69 }
71 } 70 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/task/model.dart » ('j') | pkg/analyzer/lib/src/task/model.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698