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

Side by Side Diff: pkg/analysis_server/lib/src/analysis_server.dart

Issue 875163002: Make AnalysisServer.onAnalysisComplete a Future and wait for it before refactoring. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/edit/edit_domain.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library analysis.server; 5 library analysis.server;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analysis_server/src/analysis_logger.dart'; 10 import 'package:analysis_server/src/analysis_logger.dart';
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 * The option possibly set from the server initialization which disables error notifications. 170 * The option possibly set from the server initialization which disables error notifications.
171 */ 171 */
172 bool _noErrorNotification; 172 bool _noErrorNotification;
173 173
174 /** 174 /**
175 * The controller that is notified when analysis is started. 175 * The controller that is notified when analysis is started.
176 */ 176 */
177 StreamController<AnalysisContext> _onAnalysisStartedController; 177 StreamController<AnalysisContext> _onAnalysisStartedController;
178 178
179 /** 179 /**
180 * The controller that is notified when analysis is complete.
181 */
182 StreamController _onAnalysisCompleteController;
183
184 /**
185 * The controller that is notified when a single file has been analyzed. 180 * The controller that is notified when a single file has been analyzed.
186 */ 181 */
187 StreamController<ChangeNotice> _onFileAnalyzedController; 182 StreamController<ChangeNotice> _onFileAnalyzedController;
188 183
189 /** 184 /**
190 * The controller used to notify others when priority sources change. 185 * The controller used to notify others when priority sources change.
191 */ 186 */
192 StreamController<PriorityChangeEvent> _onPriorityChangeController; 187 StreamController<PriorityChangeEvent> _onPriorityChangeController;
193 188
194 /** 189 /**
(...skipping 29 matching lines...) Expand all
224 contextDirectoryManager = 219 contextDirectoryManager =
225 new ServerContextManager(this, resourceProvider, packageMapProvider); 220 new ServerContextManager(this, resourceProvider, packageMapProvider);
226 contextDirectoryManager.defaultOptions.incremental = true; 221 contextDirectoryManager.defaultOptions.incremental = true;
227 contextDirectoryManager.defaultOptions.incrementalApi = 222 contextDirectoryManager.defaultOptions.incrementalApi =
228 analysisServerOptions.enableIncrementalResolutionApi; 223 analysisServerOptions.enableIncrementalResolutionApi;
229 contextDirectoryManager.defaultOptions.incrementalValidation = 224 contextDirectoryManager.defaultOptions.incrementalValidation =
230 analysisServerOptions.enableIncrementalResolutionValidation; 225 analysisServerOptions.enableIncrementalResolutionValidation;
231 _noErrorNotification = analysisServerOptions.noErrorNotification; 226 _noErrorNotification = analysisServerOptions.noErrorNotification;
232 AnalysisEngine.instance.logger = new AnalysisLogger(); 227 AnalysisEngine.instance.logger = new AnalysisLogger();
233 _onAnalysisStartedController = new StreamController.broadcast(); 228 _onAnalysisStartedController = new StreamController.broadcast();
234 _onAnalysisCompleteController = new StreamController.broadcast();
235 _onFileAnalyzedController = new StreamController.broadcast(); 229 _onFileAnalyzedController = new StreamController.broadcast();
236 _onPriorityChangeController = 230 _onPriorityChangeController =
237 new StreamController<PriorityChangeEvent>.broadcast(); 231 new StreamController<PriorityChangeEvent>.broadcast();
238 running = true; 232 running = true;
239 Notification notification = new ServerConnectedParams().toNotification(); 233 Notification notification = new ServerConnectedParams().toNotification();
240 channel.sendNotification(notification); 234 channel.sendNotification(notification);
241 channel.listen(handleRequest, onDone: done, onError: error); 235 channel.listen(handleRequest, onDone: done, onError: error);
242 } 236 }
243 237
244 /** 238 /**
245 * The stream that is notified when analysis is complete. 239 * The [Future] that completes when analysis is complete.
246 */ 240 */
247 Stream get onAnalysisComplete => _onAnalysisCompleteController.stream; 241 Future get onAnalysisComplete {
242 if (isAnalysisComplete()) {
243 return new Future.value();
244 }
245 return new Future(() => onAnalysisComplete);
Brian Wilkerson 2015/01/26 21:26:32 This concerns me. Given what I think I know about
scheglov 2015/01/26 22:05:53 Acknowledged.
246 }
248 247
249 /** 248 /**
250 * The stream that is notified when analysis of a context is started. 249 * The stream that is notified when analysis of a context is started.
251 */ 250 */
252 Stream<AnalysisContext> get onAnalysisStarted { 251 Stream<AnalysisContext> get onAnalysisStarted {
253 return _onAnalysisStartedController.stream; 252 return _onAnalysisStartedController.stream;
254 } 253 }
255 254
256 /** 255 /**
257 * The stream that is notified when contexts are added or removed. 256 * The stream that is notified when contexts are added or removed.
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 'Unexpected exception during analysis', 624 'Unexpected exception during analysis',
626 new CaughtException(exception, stackTrace)); 625 new CaughtException(exception, stackTrace));
627 } 626 }
628 sendServerErrorNotification(exception, stackTrace, fatal: true); 627 sendServerErrorNotification(exception, stackTrace, fatal: true);
629 shutdown(); 628 shutdown();
630 } finally { 629 } finally {
631 if (!operationQueue.isEmpty) { 630 if (!operationQueue.isEmpty) {
632 _schedulePerformOperation(); 631 _schedulePerformOperation();
633 } else { 632 } else {
634 sendStatusNotification(null); 633 sendStatusNotification(null);
635 _onAnalysisCompleteController.add(null);
636 } 634 }
637 } 635 }
638 } 636 }
639 637
640 /** 638 /**
641 * Trigger reanalysis of all files from disk. 639 * Trigger reanalysis of all files from disk.
642 */ 640 */
643 void reanalyze() { 641 void reanalyze() {
644 // Clear any operations that are pending. 642 // Clear any operations that are pending.
645 operationQueue.clear(); 643 operationQueue.clear();
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 * [packageUriResolver]. 1107 * [packageUriResolver].
1110 */ 1108 */
1111 SourceFactory _createSourceFactory(UriResolver packageUriResolver) { 1109 SourceFactory _createSourceFactory(UriResolver packageUriResolver) {
1112 List<UriResolver> resolvers = <UriResolver>[ 1110 List<UriResolver> resolvers = <UriResolver>[
1113 new DartUriResolver(analysisServer.defaultSdk), 1111 new DartUriResolver(analysisServer.defaultSdk),
1114 new ResourceUriResolver(resourceProvider), 1112 new ResourceUriResolver(resourceProvider),
1115 packageUriResolver]; 1113 packageUriResolver];
1116 return new SourceFactory(resolvers); 1114 return new SourceFactory(resolvers);
1117 } 1115 }
1118 } 1116 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/edit/edit_domain.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698