| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * The status of analysis. | 8 * The status of analysis. |
| 9 */ | 9 */ |
| 10 class AnalysisStatus { | 10 class AnalysisStatus { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 * The controller for the [stream]. | 63 * The controller for the [stream]. |
| 64 */ | 64 */ |
| 65 final _statusController = new StreamController<AnalysisStatus>(); | 65 final _statusController = new StreamController<AnalysisStatus>(); |
| 66 | 66 |
| 67 /** | 67 /** |
| 68 * The last status sent to the [stream]. | 68 * The last status sent to the [stream]. |
| 69 */ | 69 */ |
| 70 AnalysisStatus _currentStatus = AnalysisStatus.IDLE; | 70 AnalysisStatus _currentStatus = AnalysisStatus.IDLE; |
| 71 | 71 |
| 72 /** | 72 /** |
| 73 * Return the last status sent to the [stream]. |
| 74 */ |
| 75 AnalysisStatus get currentStatus => _currentStatus; |
| 76 |
| 77 /** |
| 73 * Return the stream that produces [AnalysisStatus] events. | 78 * Return the stream that produces [AnalysisStatus] events. |
| 74 */ | 79 */ |
| 75 Stream<AnalysisStatus> get stream => _statusController.stream; | 80 Stream<AnalysisStatus> get stream => _statusController.stream; |
| 76 | 81 |
| 77 /** | 82 /** |
| 78 * Send a notifications to the [stream] that the driver started analyzing. | 83 * Send a notifications to the [stream] that the driver started analyzing. |
| 79 */ | 84 */ |
| 80 void transitionToAnalyzing() { | 85 void transitionToAnalyzing() { |
| 81 if (_currentStatus != AnalysisStatus.ANALYZING) { | 86 if (_currentStatus != AnalysisStatus.ANALYZING) { |
| 82 _currentStatus = AnalysisStatus.ANALYZING; | 87 _currentStatus = AnalysisStatus.ANALYZING; |
| 83 _statusController.add(AnalysisStatus.ANALYZING); | 88 _statusController.add(AnalysisStatus.ANALYZING); |
| 84 } | 89 } |
| 85 } | 90 } |
| 86 | 91 |
| 87 /** | 92 /** |
| 88 * Send a notifications to the [stream] stream that the driver is idle. | 93 * Send a notifications to the [stream] stream that the driver is idle. |
| 89 */ | 94 */ |
| 90 void transitionToIdle() { | 95 void transitionToIdle() { |
| 91 if (_currentStatus != AnalysisStatus.IDLE) { | 96 if (_currentStatus != AnalysisStatus.IDLE) { |
| 92 _currentStatus = AnalysisStatus.IDLE; | 97 _currentStatus = AnalysisStatus.IDLE; |
| 93 _statusController.add(AnalysisStatus.IDLE); | 98 _statusController.add(AnalysisStatus.IDLE); |
| 94 } | 99 } |
| 95 } | 100 } |
| 96 } | 101 } |
| OLD | NEW |