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

Unified Diff: pkg/analyzer/lib/src/dart/analysis/driver.dart

Issue 3003923002: Fixes for AnalysisDriver async CL comments. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/analysis/driver.dart
diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart
index fdb01cb6064e6b4f71caba5eb3cde3f22f10c069..06b6b89b4c08235566bafc442bfbf0e42f93d056 100644
--- a/pkg/analyzer/lib/src/dart/analysis/driver.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart
@@ -1313,17 +1313,18 @@ class AnalysisDriver implements AnalysisDriverGeneric {
}
/**
- * Tests need a reliable way to simulate file changes during analysis.
+ * Runs any asynchronous work that was injected as part of a test using
+ * [AnalysisDriverTestView.workToWaitAfterComputingResult].
*
- * When a change happens, the driver must make sure that [getResult] produces
- * results that include these changes. It is OK for the [results] stream
- * to produce stale results as long as it eventually produces results that
- * also include the changes.
+ * If the test view indicates that there is work to do, performs the work
+ * and returns a [Future] that will be signaled when the work completes.
+ *
+ * This gives tests a reliable way to simulate file changes during analysis.
*/
Future _runTestAsyncWorkDuringAnalysis(String path) {
var work = _testView.workToWaitAfterComputingResult;
_testView.workToWaitAfterComputingResult = null;
- return work != null ? work(path) : null;
+ return work != null ? work(path) : new Future.value();
}
/**
@@ -1675,6 +1676,12 @@ class AnalysisDriverTestView {
int numOfAnalyzedLibraries = 0;
+ /**
+ * If non-null, a function that should be executed asynchronously after
+ * the next result is computed.
+ *
+ * This can be used by a test to simulate file changes during analysis.
+ */
Future<Null> Function(String path) workToWaitAfterComputingResult;
AnalysisDriverTestView(this.driver);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698