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

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

Issue 1023503002: Task: Resolve Type Names. (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 8d7ae9712386e6d4b13d161c8968e0395d43b3fb..49e025b86bd4dd25f2506c86b2aa77737e13e26c 100644
--- a/pkg/analyzer/lib/src/task/dart.dart
+++ b/pkg/analyzer/lib/src/task/dart.dart
@@ -115,6 +115,18 @@ final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT4 =
new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT4', null);
/**
+ * The errors produced while resolving type names.
+ *
+ * The list will be empty if there were no errors, but will not be `null`.
+ *
+ * The result is only available for targets representing a Dart library.
+ */
+final ResultDescriptor<List<AnalysisError>> RESOLVE_TYPE_NAMES_ERRORS =
+ new ResultDescriptor<List<AnalysisError>>(
+ 'RESOLVE_TYPE_NAMES_ERRORS', AnalysisError.NO_ERRORS,
+ contributesTo: DART_ERRORS);
+
+/**
* The partially resolved [CompilationUnit] associated with a unit.
*
* All declarations bound to the element defined by the declaration.
@@ -165,6 +177,16 @@ final ResultDescriptor<CompilationUnit> RESOLVED_UNIT5 =
new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT5', null);
/**
+ * The partially resolved [CompilationUnit] associated with a unit.
+ *
+ * [RESOLVED_UNIT5] with resolved type names.
+ *
+ * The result is only available for targets representing a unit.
+ */
+final ResultDescriptor<CompilationUnit> RESOLVED_UNIT6 =
+ new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT6', null);
+
+/**
* The [TypeProvider] of the context.
*/
final ResultDescriptor<TypeProvider> TYPE_PROVIDER =
@@ -701,7 +723,7 @@ class BuildExportSourceClosureTask extends SourceBasedAnalysisTask {
}
/**
- * A task that builds [RESOLVED_UNIT5] for a library.
+ * A task that builds [RESOLVED_UNIT5] for a unit.
*/
class BuildFunctionTypeAliasesTask extends SourceBasedAnalysisTask {
/**
@@ -1500,6 +1522,71 @@ class PublicNamespaceBuilder {
}
/**
+ * A task that builds [RESOLVED_UNIT6] for a unit.
+ */
+class ResolveTypeNamesTask extends SourceBasedAnalysisTask {
+ /**
+ * The name of the [RESOLVED_UNIT5] input.
+ */
+ static const String UNIT_INPUT = 'UNIT_INPUT';
+
+ /**
+ * The task descriptor describing this kind of task.
+ */
+ static final TaskDescriptor DESCRIPTOR = new TaskDescriptor(
+ 'ResolveTypeNamesTask', createTask, buildInputs, <ResultDescriptor>[
+ RESOLVE_TYPE_NAMES_ERRORS,
+ RESOLVED_UNIT6
+ ]);
+
+ ResolveTypeNamesTask(InternalAnalysisContext context, AnalysisTarget target)
+ : super(context, target);
+
+ @override
+ TaskDescriptor get descriptor => DESCRIPTOR;
+
+ @override
+ void internalPerform() {
+ RecordingErrorListener errorListener = new RecordingErrorListener();
+ //
+ // Prepare inputs.
+ //
+ CompilationUnit unit = getRequiredInput(UNIT_INPUT);
+ CompilationUnitElement unitElement = unit.element;
+ //
+ // Resolve TypeName nodes.
+ //
+ TypeResolverVisitor visitor = new TypeResolverVisitor.con2(
+ unitElement.library, unitElement.source, context.typeProvider,
+ errorListener);
+ unit.accept(visitor);
+ //
+ // Record outputs.
+ //
+ outputs[RESOLVE_TYPE_NAMES_ERRORS] = errorListener.errors;
+ outputs[RESOLVED_UNIT6] = 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>{UNIT_INPUT: RESOLVED_UNIT5.inputFor(target)};
+ }
+
+ /**
+ * Create a [ResolveTypeNamesTask] based on the given [target] in
+ * the given [context].
+ */
+ static ResolveTypeNamesTask createTask(
+ AnalysisContext context, AnalysisTarget target) {
+ return new ResolveTypeNamesTask(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