| 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'; | 9 import 'dart:core'; |
| 10 import 'dart:io' as io; | 10 import 'dart:io' as io; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 import 'package:analysis_server/src/context_manager.dart'; | 21 import 'package:analysis_server/src/context_manager.dart'; |
| 22 import 'package:analysis_server/src/domains/analysis/navigation.dart'; | 22 import 'package:analysis_server/src/domains/analysis/navigation.dart'; |
| 23 import 'package:analysis_server/src/domains/analysis/navigation_dart.dart'; | 23 import 'package:analysis_server/src/domains/analysis/navigation_dart.dart'; |
| 24 import 'package:analysis_server/src/domains/analysis/occurrences.dart'; | 24 import 'package:analysis_server/src/domains/analysis/occurrences.dart'; |
| 25 import 'package:analysis_server/src/domains/analysis/occurrences_dart.dart'; | 25 import 'package:analysis_server/src/domains/analysis/occurrences_dart.dart'; |
| 26 import 'package:analysis_server/src/ide_options.dart'; | 26 import 'package:analysis_server/src/ide_options.dart'; |
| 27 import 'package:analysis_server/src/operation/operation.dart'; | 27 import 'package:analysis_server/src/operation/operation.dart'; |
| 28 import 'package:analysis_server/src/operation/operation_analysis.dart'; | 28 import 'package:analysis_server/src/operation/operation_analysis.dart'; |
| 29 import 'package:analysis_server/src/operation/operation_queue.dart'; | 29 import 'package:analysis_server/src/operation/operation_queue.dart'; |
| 30 import 'package:analysis_server/src/plugin/notification_manager.dart'; | 30 import 'package:analysis_server/src/plugin/notification_manager.dart'; |
| 31 import 'package:analysis_server/src/plugin/plugin_manager.dart'; |
| 32 import 'package:analysis_server/src/plugin/plugin_watcher.dart'; |
| 31 import 'package:analysis_server/src/plugin/server_plugin.dart'; | 33 import 'package:analysis_server/src/plugin/server_plugin.dart'; |
| 32 import 'package:analysis_server/src/protocol_server.dart' as server; | 34 import 'package:analysis_server/src/protocol_server.dart' as server; |
| 33 import 'package:analysis_server/src/server/diagnostic_server.dart'; | 35 import 'package:analysis_server/src/server/diagnostic_server.dart'; |
| 34 import 'package:analysis_server/src/services/correction/namespace.dart'; | 36 import 'package:analysis_server/src/services/correction/namespace.dart'; |
| 35 import 'package:analysis_server/src/services/index/index.dart'; | 37 import 'package:analysis_server/src/services/index/index.dart'; |
| 36 import 'package:analysis_server/src/services/search/search_engine.dart'; | 38 import 'package:analysis_server/src/services/search/search_engine.dart'; |
| 37 import 'package:analysis_server/src/services/search/search_engine_internal.dart'
; | 39 import 'package:analysis_server/src/services/search/search_engine_internal.dart'
; |
| 38 import 'package:analysis_server/src/services/search/search_engine_internal2.dart
'; | 40 import 'package:analysis_server/src/services/search/search_engine_internal2.dart
'; |
| 39 import 'package:analysis_server/src/single_context_manager.dart'; | 41 import 'package:analysis_server/src/single_context_manager.dart'; |
| 40 import 'package:analysis_server/src/utilities/null_string_sink.dart'; | 42 import 'package:analysis_server/src/utilities/null_string_sink.dart'; |
| 43 import 'package:analyzer/context/context_root.dart'; |
| 41 import 'package:analyzer/dart/ast/ast.dart'; | 44 import 'package:analyzer/dart/ast/ast.dart'; |
| 42 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 45 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
| 43 import 'package:analyzer/dart/element/element.dart'; | 46 import 'package:analyzer/dart/element/element.dart'; |
| 44 import 'package:analyzer/exception/exception.dart'; | 47 import 'package:analyzer/exception/exception.dart'; |
| 45 import 'package:analyzer/file_system/file_system.dart'; | 48 import 'package:analyzer/file_system/file_system.dart'; |
| 46 import 'package:analyzer/file_system/physical_file_system.dart'; | 49 import 'package:analyzer/file_system/physical_file_system.dart'; |
| 47 import 'package:analyzer/instrumentation/instrumentation.dart'; | 50 import 'package:analyzer/instrumentation/instrumentation.dart'; |
| 48 import 'package:analyzer/plugin/resolver_provider.dart'; | 51 import 'package:analyzer/plugin/resolver_provider.dart'; |
| 49 import 'package:analyzer/source/pub_package_map_provider.dart'; | 52 import 'package:analyzer/source/pub_package_map_provider.dart'; |
| 50 import 'package:analyzer/src/context/builder.dart'; | 53 import 'package:analyzer/src/context/builder.dart'; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 final ServerCommunicationChannel channel; | 131 final ServerCommunicationChannel channel; |
| 129 | 132 |
| 130 /** | 133 /** |
| 131 * The object used to manage sending a subset of notifications to the client. | 134 * The object used to manage sending a subset of notifications to the client. |
| 132 * The subset of notifications are those to which plugins may contribute. | 135 * The subset of notifications are those to which plugins may contribute. |
| 133 * This field is `null` when the new plugin support is disabled. | 136 * This field is `null` when the new plugin support is disabled. |
| 134 */ | 137 */ |
| 135 final NotificationManager notificationManager; | 138 final NotificationManager notificationManager; |
| 136 | 139 |
| 137 /** | 140 /** |
| 141 * The object used to manage the execution of plugins. |
| 142 */ |
| 143 PluginManager pluginManager; |
| 144 |
| 145 /** |
| 138 * The [ResourceProvider] using which paths are converted into [Resource]s. | 146 * The [ResourceProvider] using which paths are converted into [Resource]s. |
| 139 */ | 147 */ |
| 140 final ResourceProvider resourceProvider; | 148 final ResourceProvider resourceProvider; |
| 141 | 149 |
| 142 /** | 150 /** |
| 143 * The [Index] for this server, may be `null` if indexing is disabled. | 151 * The [Index] for this server, may be `null` if indexing is disabled. |
| 144 */ | 152 */ |
| 145 final Index index; | 153 final Index index; |
| 146 | 154 |
| 147 /** | 155 /** |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 this.sdkManager, | 392 this.sdkManager, |
| 385 this.instrumentationService, | 393 this.instrumentationService, |
| 386 {this.diagnosticServer, | 394 {this.diagnosticServer, |
| 387 ResolverProvider fileResolverProvider: null, | 395 ResolverProvider fileResolverProvider: null, |
| 388 ResolverProvider packageResolverProvider: null, | 396 ResolverProvider packageResolverProvider: null, |
| 389 bool useSingleContextManager: false, | 397 bool useSingleContextManager: false, |
| 390 this.rethrowExceptions: true}) | 398 this.rethrowExceptions: true}) |
| 391 : notificationManager = | 399 : notificationManager = |
| 392 new NotificationManager(channel, resourceProvider) { | 400 new NotificationManager(channel, resourceProvider) { |
| 393 _performance = performanceDuringStartup; | 401 _performance = performanceDuringStartup; |
| 402 |
| 403 pluginManager = new PluginManager(resourceProvider, _getByteStorePath(), |
| 404 notificationManager, instrumentationService); |
| 405 PluginWatcher pluginWatcher = |
| 406 new PluginWatcher(resourceProvider, pluginManager); |
| 407 |
| 394 defaultContextOptions.incremental = true; | 408 defaultContextOptions.incremental = true; |
| 395 defaultContextOptions.incrementalApi = | 409 defaultContextOptions.incrementalApi = |
| 396 options.enableIncrementalResolutionApi; | 410 options.enableIncrementalResolutionApi; |
| 397 defaultContextOptions.incrementalValidation = | 411 defaultContextOptions.incrementalValidation = |
| 398 options.enableIncrementalResolutionValidation; | 412 options.enableIncrementalResolutionValidation; |
| 399 defaultContextOptions.finerGrainedInvalidation = | 413 defaultContextOptions.finerGrainedInvalidation = |
| 400 options.finerGrainedInvalidation; | 414 options.finerGrainedInvalidation; |
| 401 defaultContextOptions.generateImplicitErrors = false; | 415 defaultContextOptions.generateImplicitErrors = false; |
| 402 operationQueue = new ServerOperationQueue(); | 416 operationQueue = new ServerOperationQueue(); |
| 403 | 417 |
| 404 { | 418 { |
| 405 String name = options.newAnalysisDriverLog; | 419 String name = options.newAnalysisDriverLog; |
| 406 StringSink sink = new NullStringSink(); | 420 StringSink sink = new NullStringSink(); |
| 407 if (name != null) { | 421 if (name != null) { |
| 408 if (name == 'stdout') { | 422 if (name == 'stdout') { |
| 409 sink = io.stdout; | 423 sink = io.stdout; |
| 410 } else if (name.startsWith('file:')) { | 424 } else if (name.startsWith('file:')) { |
| 411 String path = name.substring('file:'.length); | 425 String path = name.substring('file:'.length); |
| 412 sink = new io.File(path).openWrite(mode: io.FileMode.APPEND); | 426 sink = new io.File(path).openWrite(mode: io.FileMode.APPEND); |
| 413 } | 427 } |
| 414 } | 428 } |
| 415 _analysisPerformanceLogger = new nd.PerformanceLog(sink); | 429 _analysisPerformanceLogger = new nd.PerformanceLog(sink); |
| 416 } | 430 } |
| 417 byteStore = _createByteStore(); | 431 byteStore = _createByteStore(); |
| 418 analysisDriverScheduler = | 432 analysisDriverScheduler = new nd.AnalysisDriverScheduler( |
| 419 new nd.AnalysisDriverScheduler(_analysisPerformanceLogger); | 433 _analysisPerformanceLogger, |
| 434 driverWatcher: pluginWatcher); |
| 420 analysisDriverScheduler.status.listen(sendStatusNotificationNew); | 435 analysisDriverScheduler.status.listen(sendStatusNotificationNew); |
| 421 analysisDriverScheduler.start(); | 436 analysisDriverScheduler.start(); |
| 422 | 437 |
| 423 if (useSingleContextManager) { | 438 if (useSingleContextManager) { |
| 424 contextManager = new SingleContextManager(resourceProvider, sdkManager, | 439 contextManager = new SingleContextManager(resourceProvider, sdkManager, |
| 425 packageResolverProvider, analyzedFilesGlobs, defaultContextOptions); | 440 packageResolverProvider, analyzedFilesGlobs, defaultContextOptions); |
| 426 } else { | 441 } else { |
| 427 contextManager = new ContextManagerImpl( | 442 contextManager = new ContextManagerImpl( |
| 428 resourceProvider, | 443 resourceProvider, |
| 429 sdkManager, | 444 sdkManager, |
| (...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1727 resourceProvider.getStateLocation('.analysis-driver'); | 1742 resourceProvider.getStateLocation('.analysis-driver'); |
| 1728 if (stateLocation != null) { | 1743 if (stateLocation != null) { |
| 1729 return new MemoryCachingByteStore( | 1744 return new MemoryCachingByteStore( |
| 1730 new EvictingFileByteStore(stateLocation.path, G), 64 * M); | 1745 new EvictingFileByteStore(stateLocation.path, G), 64 * M); |
| 1731 } | 1746 } |
| 1732 } | 1747 } |
| 1733 return new MemoryCachingByteStore(new NullByteStore(), 64 * M); | 1748 return new MemoryCachingByteStore(new NullByteStore(), 64 * M); |
| 1734 } | 1749 } |
| 1735 | 1750 |
| 1736 /** | 1751 /** |
| 1752 * Return the path to the location of the byte store on disk, or `null` if |
| 1753 * there is no on-disk byte store. |
| 1754 */ |
| 1755 String _getByteStorePath() { |
| 1756 if (resourceProvider is PhysicalResourceProvider) { |
| 1757 Folder stateLocation = |
| 1758 resourceProvider.getStateLocation('.analysis-driver'); |
| 1759 if (stateLocation != null) { |
| 1760 return stateLocation.path; |
| 1761 } |
| 1762 } |
| 1763 return null; |
| 1764 } |
| 1765 |
| 1766 /** |
| 1737 * Return a set of all contexts whose associated folder is contained within, | 1767 * Return a set of all contexts whose associated folder is contained within, |
| 1738 * or equal to, one of the resources in the given list of [resources]. | 1768 * or equal to, one of the resources in the given list of [resources]. |
| 1739 */ | 1769 */ |
| 1740 Set<AnalysisContext> _getContexts(List<Resource> resources) { | 1770 Set<AnalysisContext> _getContexts(List<Resource> resources) { |
| 1741 Set<AnalysisContext> contexts = new HashSet<AnalysisContext>(); | 1771 Set<AnalysisContext> contexts = new HashSet<AnalysisContext>(); |
| 1742 resources.forEach((Resource resource) { | 1772 resources.forEach((Resource resource) { |
| 1743 if (resource is Folder) { | 1773 if (resource is Folder) { |
| 1744 contexts.addAll(contextManager.contextsInAnalysisRoot(resource)); | 1774 contexts.addAll(contextManager.contextsInAnalysisRoot(resource)); |
| 1745 } | 1775 } |
| 1746 }); | 1776 }); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1895 final AnalysisServer analysisServer; | 1925 final AnalysisServer analysisServer; |
| 1896 | 1926 |
| 1897 /** | 1927 /** |
| 1898 * The [ResourceProvider] by which paths are converted into [Resource]s. | 1928 * The [ResourceProvider] by which paths are converted into [Resource]s. |
| 1899 */ | 1929 */ |
| 1900 final ResourceProvider resourceProvider; | 1930 final ResourceProvider resourceProvider; |
| 1901 | 1931 |
| 1902 ServerContextManagerCallbacks(this.analysisServer, this.resourceProvider); | 1932 ServerContextManagerCallbacks(this.analysisServer, this.resourceProvider); |
| 1903 | 1933 |
| 1904 @override | 1934 @override |
| 1905 nd.AnalysisDriver addAnalysisDriver(Folder folder, AnalysisOptions options) { | 1935 nd.AnalysisDriver addAnalysisDriver( |
| 1936 Folder folder, ContextRoot contextRoot, AnalysisOptions options) { |
| 1906 ContextBuilder builder = createContextBuilder(folder, options); | 1937 ContextBuilder builder = createContextBuilder(folder, options); |
| 1907 nd.AnalysisDriver analysisDriver = builder.buildDriver(folder.path); | 1938 nd.AnalysisDriver analysisDriver = builder.buildDriver(contextRoot); |
| 1908 analysisDriver.results.listen((result) { | 1939 analysisDriver.results.listen((result) { |
| 1909 NotificationManager notificationManager = | 1940 NotificationManager notificationManager = |
| 1910 analysisServer.notificationManager; | 1941 analysisServer.notificationManager; |
| 1911 String path = result.path; | 1942 String path = result.path; |
| 1912 if (analysisServer.shouldSendErrorsNotificationFor(path)) { | 1943 if (analysisServer.shouldSendErrorsNotificationFor(path)) { |
| 1913 if (notificationManager != null) { | 1944 if (notificationManager != null) { |
| 1914 notificationManager.recordAnalysisErrors( | 1945 notificationManager.recordAnalysisErrors( |
| 1915 NotificationManager.serverId, | 1946 NotificationManager.serverId, |
| 1916 path, | 1947 path, |
| 1917 server.doAnalysisError_listFromEngine( | 1948 server.doAnalysisError_listFromEngine( |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2308 /** | 2339 /** |
| 2309 * The [PerformanceTag] for time spent in server request handlers. | 2340 * The [PerformanceTag] for time spent in server request handlers. |
| 2310 */ | 2341 */ |
| 2311 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); | 2342 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); |
| 2312 | 2343 |
| 2313 /** | 2344 /** |
| 2314 * The [PerformanceTag] for time spent in split store microtasks. | 2345 * The [PerformanceTag] for time spent in split store microtasks. |
| 2315 */ | 2346 */ |
| 2316 static PerformanceTag splitStore = new PerformanceTag('splitStore'); | 2347 static PerformanceTag splitStore = new PerformanceTag('splitStore'); |
| 2317 } | 2348 } |
| OLD | NEW |