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

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

Issue 1031303002: Task: Resolve Variables. (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 59b9efe9a86b06eeaad3266a1badcc94a2b396ba..609ef92f900a5ccbf5fe5263e46721a685f3622b 100644
--- a/pkg/analyzer/lib/src/task/dart.dart
+++ b/pkg/analyzer/lib/src/task/dart.dart
@@ -210,6 +210,16 @@ final ResultDescriptor<CompilationUnit> RESOLVED_UNIT4 =
new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT4', null);
/**
+ * The partially resolved [CompilationUnit] associated with a unit.
+ *
+ * [RESOLVED_UNIT4] plus resolved local variables and formal parameters.
+ *
+ * The result is only available for targets representing a unit.
+ */
+final ResultDescriptor<CompilationUnit> RESOLVED_UNIT5 =
+ new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT5', null);
+
+/**
* The [TypeProvider] of the context.
*/
final ResultDescriptor<TypeProvider> TYPE_PROVIDER =
@@ -1938,6 +1948,79 @@ class ResolveUnitTypeNamesTask extends SourceBasedAnalysisTask {
}
/**
+ * A task that builds [RESOLVED_UNIT5] for a unit.
+ */
+class ResolveVariableReferencesTask extends SourceBasedAnalysisTask {
+ /**
+ * The name of the [LIBRARY_ELEMENT6] input.
+ */
+ static const String LIBRARY_INPUT = 'LIBRARY_INPUT';
+
+ /**
+ * The name of the [RESOLVED_UNIT4] input.
+ */
+ static const String UNIT_INPUT = 'UNIT_INPUT';
+
+ /**
+ * The task descriptor describing this kind of task.
+ */
+ static final TaskDescriptor DESCRIPTOR = new TaskDescriptor(
+ 'ResolveVariableReferencesTask', createTask, buildInputs,
+ <ResultDescriptor>[RESOLVED_UNIT5]);
+
+ ResolveVariableReferencesTask(
+ InternalAnalysisContext context, AnalysisTarget target)
+ : super(context, target);
+
+ @override
+ TaskDescriptor get descriptor => DESCRIPTOR;
+
+ @override
+ void internalPerform() {
+ RecordingErrorListener errorListener = new RecordingErrorListener();
+ //
+ // Prepare inputs.
+ //
+ LibraryElement libraryElement = getRequiredInput(LIBRARY_INPUT);
+ CompilationUnit unit = getRequiredInput(UNIT_INPUT);
+ CompilationUnitElement unitElement = unit.element;
+ //
+ // Resolve local variables.
+ //
+ TypeProvider typeProvider = unitElement.context.typeProvider;
+ Scope nameScope = new LibraryScope(libraryElement, errorListener);
+ AstVisitor visitor = new VariableResolverVisitor.con2(libraryElement,
+ unitElement.source, typeProvider, nameScope, errorListener);
+ unit.accept(visitor);
+ //
+ // Record outputs.
+ //
+ outputs[RESOLVED_UNIT5] = 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(LibraryUnitTarget target) {
+ return <String, TaskInput>{
+ LIBRARY_INPUT: LIBRARY_ELEMENT6.of(target.library),
+ UNIT_INPUT: RESOLVED_UNIT4.of(target)
+ };
+ }
+
+ /**
+ * Create a [ResolveVariableReferencesTask] based on the given [target] in
+ * the given [context].
+ */
+ static ResolveVariableReferencesTask createTask(
+ AnalysisContext context, AnalysisTarget target) {
+ return new ResolveVariableReferencesTask(context, target);
+ }
+}
+
+/**
* A task that scans the content of a file, producing a set of Dart tokens.
*/
class ScanDartTask 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