| 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 socket.server; | 5 library socket.server; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/analysis_server.dart'; | 7 import 'package:analysis_server/src/analysis_server.dart'; |
| 8 import 'package:analysis_server/src/channel/channel.dart'; | 8 import 'package:analysis_server/src/channel/channel.dart'; |
| 9 import 'package:analysis_server/src/context_manager.dart'; | |
| 10 import 'package:analysis_server/src/plugin/server_plugin.dart'; | 9 import 'package:analysis_server/src/plugin/server_plugin.dart'; |
| 11 import 'package:analysis_server/src/protocol.dart'; | 10 import 'package:analysis_server/src/protocol.dart'; |
| 12 import 'package:analysis_server/src/services/index/index.dart'; | 11 import 'package:analysis_server/src/services/index/index.dart'; |
| 13 import 'package:analysis_server/src/services/index/local_file_index.dart'; | 12 import 'package:analysis_server/src/services/index/local_file_index.dart'; |
| 14 import 'package:analysis_server/uri/resolver_provider.dart'; | 13 import 'package:analysis_server/uri/resolver_provider.dart'; |
| 15 import 'package:analyzer/file_system/physical_file_system.dart'; | 14 import 'package:analyzer/file_system/physical_file_system.dart'; |
| 16 import 'package:analyzer/instrumentation/instrumentation.dart'; | 15 import 'package:analyzer/instrumentation/instrumentation.dart'; |
| 17 import 'package:analyzer/source/pub_package_map_provider.dart'; | 16 import 'package:analyzer/source/pub_package_map_provider.dart'; |
| 18 import 'package:analyzer/src/generated/sdk_io.dart'; | 17 import 'package:analyzer/src/generated/sdk_io.dart'; |
| 19 import 'package:plugin/plugin.dart'; | 18 import 'package:plugin/plugin.dart'; |
| 20 | 19 |
| 21 /** | 20 /** |
| 22 * Instances of the class [SocketServer] implement the common parts of | 21 * Instances of the class [SocketServer] implement the common parts of |
| 23 * http-based and stdio-based analysis servers. The primary responsibility of | 22 * http-based and stdio-based analysis servers. The primary responsibility of |
| 24 * the SocketServer is to manage the lifetime of the AnalysisServer and to | 23 * the SocketServer is to manage the lifetime of the AnalysisServer and to |
| 25 * encode and decode the JSON messages exchanged with the client. | 24 * encode and decode the JSON messages exchanged with the client. |
| 26 */ | 25 */ |
| 27 class SocketServer { | 26 class SocketServer { |
| 28 final AnalysisServerOptions analysisServerOptions; | 27 final AnalysisServerOptions analysisServerOptions; |
| 29 final DirectoryBasedDartSdk defaultSdk; | 28 final DirectoryBasedDartSdk defaultSdk; |
| 30 final InstrumentationService instrumentationService; | 29 final InstrumentationService instrumentationService; |
| 31 final ServerPlugin serverPlugin; | 30 final ServerPlugin serverPlugin; |
| 32 final ContextManager contextManager; | |
| 33 final ResolverProvider packageResolverProvider; | 31 final ResolverProvider packageResolverProvider; |
| 34 | 32 |
| 35 /** | 33 /** |
| 36 * The analysis server that was created when a client established a | 34 * The analysis server that was created when a client established a |
| 37 * connection, or `null` if no such connection has yet been established. | 35 * connection, or `null` if no such connection has yet been established. |
| 38 */ | 36 */ |
| 39 AnalysisServer analysisServer; | 37 AnalysisServer analysisServer; |
| 40 | 38 |
| 41 /** | 39 /** |
| 42 * The plugins that are defined outside the analysis_server package. | 40 * The plugins that are defined outside the analysis_server package. |
| 43 */ | 41 */ |
| 44 List<Plugin> userDefinedPlugins; | 42 List<Plugin> userDefinedPlugins; |
| 45 | 43 |
| 46 SocketServer( | 44 SocketServer( |
| 47 this.analysisServerOptions, | 45 this.analysisServerOptions, |
| 48 this.defaultSdk, | 46 this.defaultSdk, |
| 49 this.instrumentationService, | 47 this.instrumentationService, |
| 50 this.serverPlugin, | 48 this.serverPlugin, |
| 51 this.contextManager, | |
| 52 this.packageResolverProvider); | 49 this.packageResolverProvider); |
| 53 | 50 |
| 54 /** | 51 /** |
| 55 * Create an analysis server which will communicate with the client using the | 52 * Create an analysis server which will communicate with the client using the |
| 56 * given serverChannel. | 53 * given serverChannel. |
| 57 */ | 54 */ |
| 58 void createAnalysisServer(ServerCommunicationChannel serverChannel) { | 55 void createAnalysisServer(ServerCommunicationChannel serverChannel) { |
| 59 if (analysisServer != null) { | 56 if (analysisServer != null) { |
| 60 RequestError error = new RequestError( | 57 RequestError error = new RequestError( |
| 61 RequestErrorCode.SERVER_ALREADY_STARTED, "Server already started"); | 58 RequestErrorCode.SERVER_ALREADY_STARTED, "Server already started"); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 86 | 83 |
| 87 analysisServer = new AnalysisServer( | 84 analysisServer = new AnalysisServer( |
| 88 serverChannel, | 85 serverChannel, |
| 89 resourceProvider, | 86 resourceProvider, |
| 90 new PubPackageMapProvider(resourceProvider, defaultSdk), | 87 new PubPackageMapProvider(resourceProvider, defaultSdk), |
| 91 index, | 88 index, |
| 92 serverPlugin, | 89 serverPlugin, |
| 93 analysisServerOptions, | 90 analysisServerOptions, |
| 94 defaultSdk, | 91 defaultSdk, |
| 95 instrumentationService, | 92 instrumentationService, |
| 96 contextManager: contextManager, | |
| 97 packageResolverProvider: packageResolverProvider, | 93 packageResolverProvider: packageResolverProvider, |
| 98 rethrowExceptions: false); | 94 rethrowExceptions: false); |
| 99 analysisServer.userDefinedPlugins = userDefinedPlugins; | 95 analysisServer.userDefinedPlugins = userDefinedPlugins; |
| 100 } | 96 } |
| 101 } | 97 } |
| OLD | NEW |