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

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

Issue 1220743004: Split BuildSourceClosuresTask into two tasks; remove unnecessary computation. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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/plugin/engine_plugin.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 7a83a39366a9f94e5e99f592bd2fab64de02d44b..849ae3376307adaaacd20190d08695c6348d37cd 100644
--- a/pkg/analyzer/lib/src/task/dart.dart
+++ b/pkg/analyzer/lib/src/task/dart.dart
@@ -172,15 +172,6 @@ final ListResultDescriptor<Source> IMPORT_EXPORT_SOURCE_CLOSURE =
new ListResultDescriptor<Source>('IMPORT_EXPORT_SOURCE_CLOSURE', null);
/**
- * The sources representing the import closure of a library.
- * The [Source]s include only library sources, not their units.
- *
- * The result is only available for [Source]s representing a library.
- */
-final ListResultDescriptor<Source> IMPORT_SOURCE_CLOSURE =
- new ListResultDescriptor<Source>('IMPORT_SOURCE_CLOSURE', null);
-
-/**
* The partial [LibraryElement] associated with a library.
*
* The [LibraryElement] and its [CompilationUnitElement]s are attached to each
@@ -1515,21 +1506,65 @@ class BuildPublicNamespaceTask extends SourceBasedAnalysisTask {
}
/**
- * A task that builds [IMPORT_SOURCE_CLOSURE] and [EXPORT_SOURCE_CLOSURE] of
- * a library.
+ * A task that builds [EXPORT_SOURCE_CLOSURE] of a library.
*/
-class BuildSourceClosuresTask extends SourceBasedAnalysisTask {
+class BuildSourceExportClosureTask extends SourceBasedAnalysisTask {
/**
- * The name of the import closure.
+ * The name of the export closure.
*/
- static const String IMPORT_INPUT = 'IMPORT_INPUT';
+ static const String EXPORT_INPUT = 'EXPORT_INPUT';
/**
- * The name of the export closure.
+ * The task descriptor describing this kind of task.
*/
- static const String EXPORT_INPUT = 'EXPORT_INPUT';
+ static final TaskDescriptor DESCRIPTOR = new TaskDescriptor(
+ 'BuildSourceExportClosureTask', createTask, buildInputs,
+ <ResultDescriptor>[EXPORT_SOURCE_CLOSURE]);
+
+ BuildSourceExportClosureTask(
+ InternalAnalysisContext context, AnalysisTarget target)
+ : super(context, target);
+
+ @override
+ TaskDescriptor get descriptor => DESCRIPTOR;
+
+ @override
+ void internalPerform() {
+ List<Source> exportClosure = getRequiredInput(EXPORT_INPUT);
+ //
+ // Record output.
+ //
+ outputs[EXPORT_SOURCE_CLOSURE] = exportClosure;
+ }
/**
+ * 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 library [libSource].
+ */
+ static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
+ Source source = target;
+ return <String, TaskInput>{
+ EXPORT_INPUT: new _ExportSourceClosureTaskInput(source, LIBRARY_ELEMENT2)
+ };
+ }
+
+ /**
+ * Create a [BuildSourceExportClosureTask] based on the given [target] in
+ * the given [context].
+ */
+ static BuildSourceExportClosureTask createTask(
+ AnalysisContext context, AnalysisTarget target) {
+ return new BuildSourceExportClosureTask(context, target);
+ }
+}
+
+/**
+ * A task that builds [IMPORT_EXPORT_SOURCE_CLOSURE] of a library, and also
+ * sets [IS_CLIENT].
+ */
+class BuildSourceImportExportClosureTask extends SourceBasedAnalysisTask {
+ /**
* The name of the import/export closure.
*/
static const String IMPORT_EXPORT_INPUT = 'IMPORT_EXPORT_INPUT';
@@ -1538,14 +1573,10 @@ class BuildSourceClosuresTask extends SourceBasedAnalysisTask {
* The task descriptor describing this kind of task.
*/
static final TaskDescriptor DESCRIPTOR = new TaskDescriptor(
- 'BuildSourceClosuresTask', createTask, buildInputs, <ResultDescriptor>[
- IMPORT_SOURCE_CLOSURE,
- EXPORT_SOURCE_CLOSURE,
- IMPORT_EXPORT_SOURCE_CLOSURE,
- IS_CLIENT
- ]);
+ 'BuildSourceImportExportClosureTask', createTask, buildInputs,
+ <ResultDescriptor>[IMPORT_EXPORT_SOURCE_CLOSURE, IS_CLIENT]);
- BuildSourceClosuresTask(
+ BuildSourceImportExportClosureTask(
InternalAnalysisContext context, AnalysisTarget target)
: super(context, target);
@@ -1554,15 +1585,11 @@ class BuildSourceClosuresTask extends SourceBasedAnalysisTask {
@override
void internalPerform() {
- List<Source> importClosure = getRequiredInput(IMPORT_INPUT);
- List<Source> exportClosure = getRequiredInput(EXPORT_INPUT);
List<Source> importExportClosure = getRequiredInput(IMPORT_EXPORT_INPUT);
Source htmlSource = context.sourceFactory.forUri(DartSdk.DART_HTML);
//
// Record outputs.
//
- outputs[IMPORT_SOURCE_CLOSURE] = importClosure;
- outputs[EXPORT_SOURCE_CLOSURE] = exportClosure;
outputs[IMPORT_EXPORT_SOURCE_CLOSURE] = importExportClosure;
outputs[IS_CLIENT] = importExportClosure.contains(htmlSource);
}
@@ -1575,20 +1602,18 @@ class BuildSourceClosuresTask extends SourceBasedAnalysisTask {
static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
Source source = target;
return <String, TaskInput>{
- IMPORT_INPUT: new _ImportSourceClosureTaskInput(source, LIBRARY_ELEMENT2),
- EXPORT_INPUT: new _ExportSourceClosureTaskInput(source, LIBRARY_ELEMENT2),
IMPORT_EXPORT_INPUT:
new _ImportExportSourceClosureTaskInput(source, LIBRARY_ELEMENT2)
};
}
/**
- * Create a [BuildSourceClosuresTask] based on the given [target] in
- * the given [context].
+ * Create a [BuildSourceImportExportClosureTask] based on the given [target]
+ * in the given [context].
*/
- static BuildSourceClosuresTask createTask(
+ static BuildSourceImportExportClosureTask createTask(
AnalysisContext context, AnalysisTarget target) {
- return new BuildSourceClosuresTask(context, target);
+ return new BuildSourceImportExportClosureTask(context, target);
}
}
« no previous file with comments | « pkg/analyzer/lib/src/plugin/engine_plugin.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