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

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

Issue 887433002: Add simple Dart tasks (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add base class and general implementation of description 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 | « pkg/analyzer/lib/src/task/dart.dart ('k') | pkg/analyzer/lib/task/model.dart » ('j') | no next file with comments »
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
index 25feb6f6d320ce397fd92636cbb085fd2d089647..5cb31ed699b0a0a3bfb9af9389ad44d9ad5d51bf 100644
--- a/pkg/analyzer/lib/src/task/general.dart
+++ b/pkg/analyzer/lib/src/task/general.dart
@@ -13,7 +13,7 @@ import 'package:analyzer/task/model.dart';
* A task that gets the contents of the source associated with an analysis
* target.
*/
-class GetContentTask extends AnalysisTask {
+class GetContentTask extends SourceBasedAnalysisTask {
/**
* The task descriptor describing this kind of task.
*/
@@ -31,15 +31,6 @@ class GetContentTask extends AnalysisTask {
: super(context, target);
@override
- String get description {
- Source source = target.source;
- if (source == null) {
- return "get contents of <unknown source>";
- }
- return "get contents of ${source.fullName}";
- }
-
- @override
TaskDescriptor get descriptor => DESCRIPTOR;
@override
@@ -68,3 +59,23 @@ class GetContentTask extends AnalysisTask {
return new GetContentTask(context, target);
}
}
+
+/**
+ * A base class for analysis tasks whose target is expected to be a source.
+ */
+abstract class SourceBasedAnalysisTask extends AnalysisTask {
+ /**
+ * Initialize a newly created task to perform analysis within the given
+ * [context] in order to produce results for the given [target].
+ */
+ SourceBasedAnalysisTask(AnalysisContext context, AnalysisTarget target)
+ : super(context, target);
+
+ @override
+ String get description {
+ Source source = target.source;
+ String sourceName =
+ target.source == null ? '<unknown source>' : source.fullName;
+ return '${descriptor.name} for source $sourceName';
+ }
+}
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | pkg/analyzer/lib/task/model.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698