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

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

Issue 1018443003: Start analyzing LibraryUnitTarget(s) from BuildLibraryElementTask. (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 | « pkg/analyzer/lib/src/generated/ast.dart ('k') | 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 44ae3c8ab15cbc06527638019c17a1ce128f2be6..472897bbf764eda38e1a038facf6df3432343a54 100644
--- a/pkg/analyzer/lib/src/task/dart.dart
+++ b/pkg/analyzer/lib/src/task/dart.dart
@@ -16,6 +16,7 @@ import 'package:analyzer/src/generated/resolver.dart';
import 'package:analyzer/src/generated/scanner.dart';
import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/generated/source.dart';
+import 'package:analyzer/src/generated/utilities_general.dart';
import 'package:analyzer/src/task/driver.dart';
import 'package:analyzer/src/task/general.dart';
import 'package:analyzer/src/task/inputs.dart';
@@ -139,23 +140,32 @@ class BuildCompilationUnitElementTask extends SourceBasedAnalysisTask {
@override
void internalPerform() {
+ //
+ // Prepare inputs.
+ //
Source source = getRequiredSource();
CompilationUnit unit = getRequiredInput(PARSED_UNIT_INPUT_NAME);
-
+ //
+ // Process inputs.
+ //
+ unit = AstCloner.clone(unit);
CompilationUnitBuilder builder = new CompilationUnitBuilder();
CompilationUnitElement element = builder.buildCompilationUnit(source, unit);
-
+ //
+ // Record outputs.
+ //
outputs[COMPILATION_UNIT_ELEMENT] = element;
outputs[RESOLVED_UNIT1] = 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].
+ * input descriptors describing those inputs for a task with the given
+ * [target].
*/
- static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
+ static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) {
return <String, TaskInput>{
- PARSED_UNIT_INPUT_NAME: PARSED_UNIT.inputFor(target)
+ PARSED_UNIT_INPUT_NAME: PARSED_UNIT.inputFor(target.unit)
};
}
@@ -358,26 +368,26 @@ class BuildDirectiveElementsTask extends SourceBasedAnalysisTask {
/**
* 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].
+ * given library [source].
*/
- static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
+ static Map<String, TaskInput> buildInputs(Source source) {
return <String, TaskInput>{
- RESOLVED_UNIT2_INPUT_NAME: RESOLVED_UNIT2.inputFor(target),
+ RESOLVED_UNIT2_INPUT_NAME: RESOLVED_UNIT2.inputFor(source),
IMPORTS_LIBRARY_ELEMENT1_INPUT_NAME:
new ListToMapTaskInput<Source, LibraryElement>(
- IMPORTED_LIBRARIES.inputFor(target),
+ IMPORTED_LIBRARIES.inputFor(source),
(Source source) => LIBRARY_ELEMENT1.inputFor(source)),
EXPORTS_LIBRARY_ELEMENT1_INPUT_NAME:
new ListToMapTaskInput<Source, LibraryElement>(
- EXPORTED_LIBRARIES.inputFor(target),
+ EXPORTED_LIBRARIES.inputFor(source),
(Source source) => LIBRARY_ELEMENT1.inputFor(source)),
IMPORTS_SOURCE_KIND_INPUT_NAME:
new ListToMapTaskInput<Source, SourceKind>(
- IMPORTED_LIBRARIES.inputFor(target),
+ IMPORTED_LIBRARIES.inputFor(source),
(Source source) => SOURCE_KIND.inputFor(source)),
EXPORTS_SOURCE_KIND_INPUT_NAME:
new ListToMapTaskInput<Source, SourceKind>(
- EXPORTED_LIBRARIES.inputFor(target),
+ EXPORTED_LIBRARIES.inputFor(source),
(Source source) => SOURCE_KIND.inputFor(source))
};
}
@@ -736,16 +746,17 @@ class BuildLibraryElementTask extends SourceBasedAnalysisTask {
/**
* 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].
+ * [librarySource].
*/
- static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
+ static Map<String, TaskInput> buildInputs(Source librarySource) {
return <String, TaskInput>{
- DEFINING_RESOLVER_UNIT1_INPUT_NAME:
- new SimpleTaskInput(target, RESOLVED_UNIT1),
+ DEFINING_RESOLVER_UNIT1_INPUT_NAME: RESOLVED_UNIT1
+ .inputFor(new LibraryUnitTarget(librarySource, librarySource)),
PARTS_RESOLVED_UNIT1_INPUT_NAME:
new ListToListTaskInput<Source, CompilationUnit>(
- INCLUDED_PARTS.inputFor(target),
- (Source source) => RESOLVED_UNIT1.inputFor(source))
+ INCLUDED_PARTS.inputFor(librarySource),
+ (Source source) => RESOLVED_UNIT1
+ .inputFor(new LibraryUnitTarget(librarySource, source)))
};
}
@@ -796,11 +807,11 @@ class BuildPublicNamespaceTask extends SourceBasedAnalysisTask {
/**
* 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].
+ * given library [source].
*/
- static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
+ static Map<String, TaskInput> buildInputs(Source source) {
return <String, TaskInput>{
- BUILT_LIBRARY_ELEMENT_INPUT_NAME: LIBRARY_ELEMENT1.inputFor(target)
+ BUILT_LIBRARY_ELEMENT_INPUT_NAME: LIBRARY_ELEMENT1.inputFor(source)
};
}
@@ -876,6 +887,30 @@ class BuildTypeProviderTask extends SourceBasedAnalysisTask {
}
/**
+ * A pair of a library [Source] and a unit [Source] in this library.
+ */
+class LibraryUnitTarget implements AnalysisTarget {
+ final Source library;
+ final Source unit;
+ LibraryUnitTarget(this.library, this.unit);
+
+ @override
+ int get hashCode {
+ return JenkinsSmiHash.combine(library.hashCode, unit.hashCode);
+ }
+
+ @override
+ Source get source => unit;
+
+ @override
+ bool operator ==(other) {
+ return other is LibraryUnitTarget &&
+ other.library == library &&
+ other.unit == unit;
+ }
+}
+
+/**
* A task that parses the content of a Dart file, producing an AST structure.
*/
class ParseDartTask extends SourceBasedAnalysisTask {
@@ -981,12 +1016,13 @@ class ParseDartTask extends SourceBasedAnalysisTask {
/**
* 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].
+ * input descriptors describing those inputs for a task with the given
+ * [source].
*/
- static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
+ static Map<String, TaskInput> buildInputs(Source source) {
return <String, TaskInput>{
- LINE_INFO_INPUT_NAME: LINE_INFO.inputFor(target),
- TOKEN_STREAM_INPUT_NAME: TOKEN_STREAM.inputFor(target)
+ LINE_INFO_INPUT_NAME: LINE_INFO.inputFor(source),
+ TOKEN_STREAM_INPUT_NAME: TOKEN_STREAM.inputFor(source)
};
}
@@ -1086,10 +1122,11 @@ class ScanDartTask extends SourceBasedAnalysisTask {
/**
* 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].
+ * input descriptors describing those inputs for a task with the given
+ * [source].
*/
- static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
- return <String, TaskInput>{CONTENT_INPUT_NAME: CONTENT.inputFor(target)};
+ static Map<String, TaskInput> buildInputs(Source source) {
+ return <String, TaskInput>{CONTENT_INPUT_NAME: CONTENT.inputFor(source)};
}
/**
« no previous file with comments | « pkg/analyzer/lib/src/generated/ast.dart ('k') | pkg/analyzer/test/src/task/dart_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698