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

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

Issue 2665263002: Streamline AnalysisDriver status tracking. (Closed)
Patch Set: Created 3 years, 11 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/dart/analysis/driver.dart ('k') | pkg/analyzer/test/src/dart/analysis/base.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/analysis/status.dart
diff --git a/pkg/analyzer/lib/src/dart/analysis/status.dart b/pkg/analyzer/lib/src/dart/analysis/status.dart
index e70de686623aa72f3eafdff29498bc62f44a741c..b108eafcb8c81fd57bd6d78d84a24eb682290fa0 100644
--- a/pkg/analyzer/lib/src/dart/analysis/status.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/status.dart
@@ -89,10 +89,22 @@ class StatusSupport {
Stream<AnalysisStatus> get stream => _statusController.stream;
/**
+ * Prepare for the driver to start analyzing, but do not notify the [stream]
+ * yet.
+ *
+ * A call to [preTransitionToAnalyzing] has the same effect on [waitForIdle]
+ * as a call to [transitionToAnalyzing], but it has no effect on the [stream].
+ */
+ void preTransitionToAnalyzing() {
+ _idleCompleter ??= new Completer<Null>();
+ }
+
+ /**
* Send a notifications to the [stream] that the driver started analyzing.
scheglov 2017/02/01 00:35:58 Now probably that "a driver" started analyzing. Or
Paul Berry 2017/02/01 17:17:34 Done.
*/
void transitionToAnalyzing() {
if (_currentStatus != AnalysisStatus.ANALYZING) {
+ preTransitionToAnalyzing();
_currentStatus = AnalysisStatus.ANALYZING;
_statusController.add(AnalysisStatus.ANALYZING);
}
@@ -105,9 +117,9 @@ class StatusSupport {
if (_currentStatus != AnalysisStatus.IDLE) {
_currentStatus = AnalysisStatus.IDLE;
_statusController.add(AnalysisStatus.IDLE);
- _idleCompleter?.complete();
- _idleCompleter = null;
}
+ _idleCompleter?.complete();
+ _idleCompleter = null;
}
/**
@@ -117,11 +129,6 @@ class StatusSupport {
* immediately.
*/
Future<Null> waitForIdle() {
- if (_currentStatus == AnalysisStatus.IDLE) {
- return new Future.value();
- } else {
- _idleCompleter ??= new Completer<Null>();
- return _idleCompleter.future;
- }
+ return _idleCompleter?.future ?? new Future.value();
}
}
« no previous file with comments | « pkg/analyzer/lib/src/dart/analysis/driver.dart ('k') | pkg/analyzer/test/src/dart/analysis/base.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698