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

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

Issue 1009693002: Task: Build Enum Member Elements. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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/test/src/task/dart_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/task/dart.dart
diff --git a/pkg/analyzer/lib/src/task/dart.dart b/pkg/analyzer/lib/src/task/dart.dart
index b96b0edc53ff9af13aa40f92ce7e7f8448844f22..849d141a39fc2e6f0a876de766da294ff9da7dd3 100644
--- a/pkg/analyzer/lib/src/task/dart.dart
+++ b/pkg/analyzer/lib/src/task/dart.dart
@@ -89,6 +89,16 @@ final ResultDescriptor<CompilationUnit> RESOLVED_UNIT3 =
new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT3', null);
/**
+ * The partially resolved [CompilationUnit] associated with a unit.
+ *
+ * All the enum member elements are built.
+ *
+ * The result is only available for targets representing a unit.
+ */
+final ResultDescriptor<CompilationUnit> RESOLVED_UNIT4 =
+ new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT4', null);
+
+/**
* The [TypeProvider] of the context.
*/
final ResultDescriptor<TypeProvider> TYPE_PROVIDER =
@@ -413,6 +423,72 @@ class BuildDirectiveElementsTask extends SourceBasedAnalysisTask {
}
/**
+ * A task that builds [RESOLVED_UNIT4].
Brian Wilkerson 2015/03/14 14:45:14 How about: A task that builds the elements repres
+ */
+class BuildEnumMemberElementsTask extends SourceBasedAnalysisTask {
+ /**
+ * The name of the [TYPE_PROVIDER] input.
+ */
+ static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT';
+
+ /**
+ * The name of the [RESOLVED_UNIT3] input.
+ */
+ static const String UNIT_INPUT = 'UNIT_INPUT';
+
+ /**
+ * The task descriptor describing this kind of task.
+ */
+ static final TaskDescriptor DESCRIPTOR = new TaskDescriptor(
+ 'BuildEnumMemberElementsTask', createTask, buildInputs,
+ <ResultDescriptor>[RESOLVED_UNIT4]);
+
+ BuildEnumMemberElementsTask(
+ InternalAnalysisContext context, AnalysisTarget target)
+ : super(context, target);
+
+ @override
+ TaskDescriptor get descriptor => DESCRIPTOR;
+
+ @override
+ void internalPerform() {
+ //
+ // Prepare inputs.
+ //
+ TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT);
+ CompilationUnit unit = getRequiredInput(UNIT_INPUT);
+ //
+ // Record outputs.
+ //
+ EnumMemberBuilder builder = new EnumMemberBuilder(typeProvider);
+ unit.accept(builder);
+ outputs[RESOLVED_UNIT4] = unit;
+ }
+
+ /**
+ * 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>{
+ TYPE_PROVIDER_INPUT:
+ TYPE_PROVIDER.inputFor(AnalysisContextTarget.request),
+ UNIT_INPUT: RESOLVED_UNIT3.inputFor(target)
+ };
+ }
+
+ /**
+ * Create a [BuildEnumMemberElementsTask] based on the given [target] in
+ * the given [context].
+ */
+ static BuildEnumMemberElementsTask createTask(
+ AnalysisContext context, AnalysisTarget target) {
+ return new BuildEnumMemberElementsTask(context, target);
+ }
+}
+
+/**
* A task that builds a library element for a Dart library.
*/
class BuildLibraryElementTask extends SourceBasedAnalysisTask {
« no previous file with comments | « no previous file | pkg/analyzer/test/src/task/dart_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698