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

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

Issue 1322983002: Implement task to infer instance members (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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
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 2a0815c95129c49f673bd02319741249d6c2a5ee..a4f8b406ecefaba27701312d88b88d891139f394 100644
--- a/pkg/analyzer/lib/src/task/dart.dart
+++ b/pkg/analyzer/lib/src/task/dart.dart
@@ -2410,6 +2410,86 @@ class GenerateHintsTask extends SourceBasedAnalysisTask {
}
/**
+ * A task that ensures that all of the inferrable instance members in a
+ * compilation unit have had their type inferred.
+ */
+class InferInstanceMembersInUnitTask extends SourceBasedAnalysisTask {
+ /**
+ * The name of the [TYPE_PROVIDER] input.
+ */
+ static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT';
+
+ /**
+ * The name of the input whose value is the [RESOLVED_UNIT6] for the
+ * compilation unit.
+ */
+ static const String UNIT_INPUT = 'UNIT_INPUT';
+
+ /**
+ * The task descriptor describing this kind of task.
+ */
+ static final TaskDescriptor DESCRIPTOR = new TaskDescriptor(
+ 'InferInstanceMembersInUnitTask',
+ createTask,
+ buildInputs,
+ <ResultDescriptor>[RESOLVED_UNIT7]);
+
+ /**
+ * Initialize a newly created task to build a library element for the given
+ * [unit] in the given [context].
+ */
+ InferInstanceMembersInUnitTask(
+ InternalAnalysisContext context, LibrarySpecificUnit unit)
+ : super(context, unit);
+
+ @override
+ TaskDescriptor get descriptor => DESCRIPTOR;
+
+ @override
+ void internalPerform() {
+ //
+ // Prepare inputs.
+ //
+ CompilationUnit unit = getRequiredInput(UNIT_INPUT);
+ TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT);
+ //
+ // Infer instance members.
+ //
+ if (context.analysisOptions.strongMode) {
+ InstanceMemberInferrer inferrer =
+ new InstanceMemberInferrer(typeProvider);
+ inferrer.inferCompilationUnit(unit.element);
+ }
+ //
+ // Record outputs.
+ //
+ outputs[RESOLVED_UNIT7] = 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
+ * [libSource].
+ */
+ static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
+ LibrarySpecificUnit unit = target;
+ return <String, TaskInput>{
+ UNIT_INPUT: RESOLVED_UNIT6.of(unit),
+ TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request)
+ };
+ }
+
+ /**
+ * Create a [InferInstanceMembersInUnitTask] based on the given [target] in
+ * the given [context].
+ */
+ static InferInstanceMembersInUnitTask createTask(
+ AnalysisContext context, AnalysisTarget target) {
+ return new InferInstanceMembersInUnitTask(context, target);
+ }
+}
+
+/**
* An abstract class that defines utility methods that are useful for tasks
* operating on static variables.
*/
@@ -2503,8 +2583,8 @@ class InferStaticVariableTypesInUnitTask extends SourceBasedAnalysisTask {
}
/**
- * Create a [InferStaticVariableTypesInUnitTask] based on the given [target] in the
- * given [context].
+ * Create a [InferStaticVariableTypesInUnitTask] based on the given [target]
+ * in the given [context].
*/
static InferStaticVariableTypesInUnitTask createTask(
AnalysisContext context, AnalysisTarget target) {

Powered by Google App Engine
This is Rietveld 408576698