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

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

Issue 596893002: Rework launch data (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated Java side Created 6 years, 2 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
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:analyzer/file_system/file_system.dart'; 10 import 'package:analyzer/file_system/file_system.dart';
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 * The controller that is notified when analysis is started. 211 * The controller that is notified when analysis is started.
212 */ 212 */
213 StreamController<AnalysisContext> _onAnalysisStartedController; 213 StreamController<AnalysisContext> _onAnalysisStartedController;
214 214
215 /** 215 /**
216 * The controller that is notified when analysis is complete. 216 * The controller that is notified when analysis is complete.
217 */ 217 */
218 StreamController _onAnalysisCompleteController; 218 StreamController _onAnalysisCompleteController;
219 219
220 /** 220 /**
221 * The controller that is notified when a single file has been analyzed.
222 */
223 StreamController<ChangeNotice> _onFileAnalyzedController;
224
225 /**
221 * True if any exceptions thrown by analysis should be propagated up the call 226 * True if any exceptions thrown by analysis should be propagated up the call
222 * stack. 227 * stack.
223 */ 228 */
224 bool rethrowExceptions; 229 bool rethrowExceptions;
225 230
226 /** 231 /**
227 * Initialize a newly created server to receive requests from and send 232 * Initialize a newly created server to receive requests from and send
228 * responses to the given [channel]. 233 * responses to the given [channel].
229 * 234 *
230 * If [rethrowExceptions] is true, then any exceptions thrown by analysis are 235 * If [rethrowExceptions] is true, then any exceptions thrown by analysis are
231 * propagated up the call stack. The default is true to allow analysis 236 * propagated up the call stack. The default is true to allow analysis
232 * exceptions to show up in unit tests, but it should be set to false when 237 * exceptions to show up in unit tests, but it should be set to false when
233 * running a full analysis server. 238 * running a full analysis server.
234 */ 239 */
235 AnalysisServer(this.channel, this.resourceProvider, 240 AnalysisServer(this.channel, this.resourceProvider,
236 PackageMapProvider packageMapProvider, this.index, this.defaultSdk, 241 PackageMapProvider packageMapProvider, this.index, this.defaultSdk,
237 {this.rethrowExceptions: true}) { 242 {this.rethrowExceptions: true}) {
238 searchEngine = createSearchEngine(index); 243 searchEngine = createSearchEngine(index);
239 operationQueue = new ServerOperationQueue(this); 244 operationQueue = new ServerOperationQueue(this);
240 contextDirectoryManager = 245 contextDirectoryManager =
241 new ServerContextManager(this, resourceProvider, packageMapProvider); 246 new ServerContextManager(this, resourceProvider, packageMapProvider);
242 AnalysisEngine.instance.logger = new AnalysisLogger(); 247 AnalysisEngine.instance.logger = new AnalysisLogger();
243 _onAnalysisStartedController = new StreamController.broadcast(); 248 _onAnalysisStartedController = new StreamController.broadcast();
244 _onAnalysisCompleteController = new StreamController.broadcast(); 249 _onAnalysisCompleteController = new StreamController.broadcast();
250 _onFileAnalyzedController = new StreamController.broadcast();
245 running = true; 251 running = true;
246 Notification notification = new ServerConnectedParams().toNotification(); 252 Notification notification = new ServerConnectedParams().toNotification();
247 channel.sendNotification(notification); 253 channel.sendNotification(notification);
248 channel.listen(handleRequest, onDone: done, onError: error); 254 channel.listen(handleRequest, onDone: done, onError: error);
249 } 255 }
250 256
251 /** 257 /**
258 * If the given notice applies to a file contained within an analysis root,
259 * notify interested parties that the file has been (at least partially)
260 * analyzed.
261 */
262 void fileAnalyzed(ChangeNotice notice) {
263 if (contextDirectoryManager.isInAnalysisRoot(notice.source.fullName)) {
264 _onFileAnalyzedController.add(notice);
265 }
266 }
267
268 /**
252 * Schedules execution of the given [ServerOperation]. 269 * Schedules execution of the given [ServerOperation].
253 */ 270 */
254 void scheduleOperation(ServerOperation operation) { 271 void scheduleOperation(ServerOperation operation) {
255 bool wasEmpty = operationQueue.isEmpty; 272 bool wasEmpty = operationQueue.isEmpty;
256 addOperation(operation); 273 addOperation(operation);
257 if (wasEmpty) { 274 if (wasEmpty) {
258 _schedulePerformOperation(); 275 _schedulePerformOperation();
259 } 276 }
260 } 277 }
261 278
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 Stream<AnalysisContext> get onAnalysisStarted { 364 Stream<AnalysisContext> get onAnalysisStarted {
348 return _onAnalysisStartedController.stream; 365 return _onAnalysisStartedController.stream;
349 } 366 }
350 367
351 /** 368 /**
352 * The stream that is notified when analysis is complete. 369 * The stream that is notified when analysis is complete.
353 */ 370 */
354 Stream get onAnalysisComplete => _onAnalysisCompleteController.stream; 371 Stream get onAnalysisComplete => _onAnalysisCompleteController.stream;
355 372
356 /** 373 /**
374 * The stream that is notified when a single file has been analyzed.
375 */
376 Stream get onFileAnalyzed => _onFileAnalyzedController.stream;
377
378 /**
357 * Adds the given [ServerOperation] to the queue, but does not schedule 379 * Adds the given [ServerOperation] to the queue, but does not schedule
358 * operations execution. 380 * operations execution.
359 */ 381 */
360 void addOperation(ServerOperation operation) { 382 void addOperation(ServerOperation operation) {
361 operationQueue.add(operation); 383 operationQueue.add(operation);
362 } 384 }
363 385
364 /** 386 /**
365 * The socket from which requests are being read has been closed. 387 * The socket from which requests are being read has been closed.
366 */ 388 */
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 // send the notification 954 // send the notification
933 channel.sendNotification( 955 channel.sendNotification(
934 new ServerErrorParams( 956 new ServerErrorParams(
935 true, 957 true,
936 exceptionString, 958 exceptionString,
937 stackTraceString).toNotification()); 959 stackTraceString).toNotification());
938 } 960 }
939 } 961 }
940 962
941 typedef void OptionUpdater(AnalysisOptionsImpl options); 963 typedef void OptionUpdater(AnalysisOptionsImpl options);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698