| OLD | NEW |
| 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 import 'dart:core' hide Resource; | 9 import 'dart:core' hide Resource; |
| 10 import 'dart:math' show max; | 10 import 'dart:math' show max; |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 index2 = _index2, | 323 index2 = _index2, |
| 324 searchEngine = _index != null ? createSearchEngine(_index) : null { | 324 searchEngine = _index != null ? createSearchEngine(_index) : null { |
| 325 _performance = performanceDuringStartup; | 325 _performance = performanceDuringStartup; |
| 326 defaultContextOptions.incremental = true; | 326 defaultContextOptions.incremental = true; |
| 327 defaultContextOptions.incrementalApi = | 327 defaultContextOptions.incrementalApi = |
| 328 options.enableIncrementalResolutionApi; | 328 options.enableIncrementalResolutionApi; |
| 329 defaultContextOptions.incrementalValidation = | 329 defaultContextOptions.incrementalValidation = |
| 330 options.enableIncrementalResolutionValidation; | 330 options.enableIncrementalResolutionValidation; |
| 331 defaultContextOptions.generateImplicitErrors = false; | 331 defaultContextOptions.generateImplicitErrors = false; |
| 332 operationQueue = new ServerOperationQueue(); | 332 operationQueue = new ServerOperationQueue(); |
| 333 sdkManager = new DartSdkManager(defaultSdkCreator); |
| 333 contextManager = new ContextManagerImpl( | 334 contextManager = new ContextManagerImpl( |
| 334 resourceProvider, | 335 resourceProvider, |
| 336 sdkManager, |
| 335 packageResolverProvider, | 337 packageResolverProvider, |
| 336 embeddedResolverProvider, | 338 embeddedResolverProvider, |
| 337 packageMapProvider, | 339 packageMapProvider, |
| 338 analyzedFilesGlobs, | 340 analyzedFilesGlobs, |
| 339 instrumentationService, | 341 instrumentationService, |
| 340 defaultContextOptions); | 342 defaultContextOptions); |
| 341 ServerContextManagerCallbacks contextManagerCallbacks = | 343 ServerContextManagerCallbacks contextManagerCallbacks = |
| 342 new ServerContextManagerCallbacks(this, resourceProvider); | 344 new ServerContextManagerCallbacks(this, resourceProvider); |
| 343 contextManager.callbacks = contextManagerCallbacks; | 345 contextManager.callbacks = contextManagerCallbacks; |
| 344 _noErrorNotification = options.noErrorNotification; | 346 _noErrorNotification = options.noErrorNotification; |
| 345 AnalysisEngine.instance.logger = new AnalysisLogger(this); | 347 AnalysisEngine.instance.logger = new AnalysisLogger(this); |
| 346 _onAnalysisStartedController = new StreamController.broadcast(); | 348 _onAnalysisStartedController = new StreamController.broadcast(); |
| 347 _onFileAnalyzedController = new StreamController.broadcast(); | 349 _onFileAnalyzedController = new StreamController.broadcast(); |
| 348 _onPriorityChangeController = | 350 _onPriorityChangeController = |
| 349 new StreamController<PriorityChangeEvent>.broadcast(); | 351 new StreamController<PriorityChangeEvent>.broadcast(); |
| 350 running = true; | 352 running = true; |
| 351 onAnalysisStarted.first.then((_) { | 353 onAnalysisStarted.first.then((_) { |
| 352 onAnalysisComplete.then((_) { | 354 onAnalysisComplete.then((_) { |
| 353 performanceAfterStartup = new ServerPerformance(); | 355 performanceAfterStartup = new ServerPerformance(); |
| 354 _performance = performanceAfterStartup; | 356 _performance = performanceAfterStartup; |
| 355 }); | 357 }); |
| 356 }); | 358 }); |
| 357 Notification notification = | 359 Notification notification = |
| 358 new ServerConnectedParams(VERSION).toNotification(); | 360 new ServerConnectedParams(VERSION).toNotification(); |
| 359 channel.sendNotification(notification); | 361 channel.sendNotification(notification); |
| 360 channel.listen(handleRequest, onDone: done, onError: error); | 362 channel.listen(handleRequest, onDone: done, onError: error); |
| 361 handlers = serverPlugin.createDomains(this); | 363 handlers = serverPlugin.createDomains(this); |
| 362 sdkManager = new DartSdkManager(defaultSdkCreator); | |
| 363 } | 364 } |
| 364 | 365 |
| 365 /** | 366 /** |
| 366 * Return the [AnalysisContext]s that are being used to analyze the analysis | 367 * Return the [AnalysisContext]s that are being used to analyze the analysis |
| 367 * roots. | 368 * roots. |
| 368 */ | 369 */ |
| 369 Iterable<AnalysisContext> get analysisContexts => | 370 Iterable<AnalysisContext> get analysisContexts => |
| 370 contextManager.analysisContexts; | 371 contextManager.analysisContexts; |
| 371 | 372 |
| 372 /** | 373 /** |
| (...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1558 } | 1559 } |
| 1559 analysisServer.operationQueue.contextRemoved(context); | 1560 analysisServer.operationQueue.contextRemoved(context); |
| 1560 analysisServer._onContextsChangedController | 1561 analysisServer._onContextsChangedController |
| 1561 .add(new ContextsChangedEvent(removed: [context])); | 1562 .add(new ContextsChangedEvent(removed: [context])); |
| 1562 analysisServer.sendContextAnalysisDoneNotifications( | 1563 analysisServer.sendContextAnalysisDoneNotifications( |
| 1563 context, AnalysisDoneReason.CONTEXT_REMOVED); | 1564 context, AnalysisDoneReason.CONTEXT_REMOVED); |
| 1564 context.dispose(); | 1565 context.dispose(); |
| 1565 } | 1566 } |
| 1566 | 1567 |
| 1567 @override | 1568 @override |
| 1568 void updateContextPackageUriResolver( | 1569 void updateContextPackageUriResolver(AnalysisContext context) { |
| 1569 Folder contextFolder, FolderDisposition disposition) { | |
| 1570 AnalysisContext context = analysisServer.folderMap[contextFolder]; | |
| 1571 context.sourceFactory = _createSourceFactory( | |
| 1572 context, context.analysisOptions, disposition, contextFolder); | |
| 1573 analysisServer._onContextsChangedController | 1570 analysisServer._onContextsChangedController |
| 1574 .add(new ContextsChangedEvent(changed: [context])); | 1571 .add(new ContextsChangedEvent(changed: [context])); |
| 1575 analysisServer.schedulePerformAnalysisOperation(context); | 1572 analysisServer.schedulePerformAnalysisOperation(context); |
| 1576 } | 1573 } |
| 1577 | 1574 |
| 1578 /** | 1575 /** |
| 1579 * Set up a [SourceFactory] that resolves packages as appropriate for the | 1576 * Set up a [SourceFactory] that resolves packages as appropriate for the |
| 1580 * given [disposition]. | 1577 * given [disposition]. |
| 1581 */ | 1578 */ |
| 1582 SourceFactory _createSourceFactory(InternalAnalysisContext context, | 1579 SourceFactory _createSourceFactory(InternalAnalysisContext context, |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1724 /** | 1721 /** |
| 1725 * The [PerformanceTag] for time spent in server request handlers. | 1722 * The [PerformanceTag] for time spent in server request handlers. |
| 1726 */ | 1723 */ |
| 1727 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); | 1724 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); |
| 1728 | 1725 |
| 1729 /** | 1726 /** |
| 1730 * The [PerformanceTag] for time spent in split store microtasks. | 1727 * The [PerformanceTag] for time spent in split store microtasks. |
| 1731 */ | 1728 */ |
| 1732 static PerformanceTag splitStore = new PerformanceTag('splitStore'); | 1729 static PerformanceTag splitStore = new PerformanceTag('splitStore'); |
| 1733 } | 1730 } |
| OLD | NEW |