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/plugin/protocol/protocol.dart'; | 7 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
8 import 'package:analysis_server/src/analysis_server.dart'; | 8 import 'package:analysis_server/src/analysis_server.dart'; |
9 import 'package:analysis_server/src/channel/channel.dart'; | 9 import 'package:analysis_server/src/channel/channel.dart'; |
10 import 'package:analysis_server/src/plugin/server_plugin.dart'; | 10 import 'package:analysis_server/src/plugin/server_plugin.dart'; |
11 import 'package:analysis_server/src/services/index/index.dart'; | 11 import 'package:analysis_server/src/services/index/index.dart'; |
12 import 'package:analyzer/file_system/physical_file_system.dart'; | 12 import 'package:analyzer/file_system/physical_file_system.dart'; |
13 import 'package:analyzer/instrumentation/instrumentation.dart'; | 13 import 'package:analyzer/instrumentation/instrumentation.dart'; |
14 import 'package:analyzer/plugin/embedded_resolver_provider.dart'; | |
15 import 'package:analyzer/plugin/resolver_provider.dart'; | 14 import 'package:analyzer/plugin/resolver_provider.dart'; |
16 import 'package:analyzer/source/pub_package_map_provider.dart'; | 15 import 'package:analyzer/source/pub_package_map_provider.dart'; |
17 import 'package:analyzer/src/generated/sdk.dart'; | 16 import 'package:analyzer/src/generated/sdk.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 | 28 |
30 /** | 29 /** |
31 * The function used to create a new SDK using the default SDK. | 30 * The function used to create a new SDK using the default SDK. |
32 */ | 31 */ |
33 final SdkCreator defaultSdkCreator; | 32 final SdkCreator defaultSdkCreator; |
34 | 33 |
35 final DirectoryBasedDartSdk defaultSdk; | 34 final DirectoryBasedDartSdk defaultSdk; |
36 final InstrumentationService instrumentationService; | 35 final InstrumentationService instrumentationService; |
37 final ServerPlugin serverPlugin; | 36 final ServerPlugin serverPlugin; |
38 final EmbeddedResolverProvider embeddedResolverProvider; | |
39 final ResolverProvider packageResolverProvider; | 37 final ResolverProvider packageResolverProvider; |
40 final bool useSingleContextManager; | 38 final bool useSingleContextManager; |
41 | 39 |
42 /** | 40 /** |
43 * The analysis server that was created when a client established a | 41 * The analysis server that was created when a client established a |
44 * connection, or `null` if no such connection has yet been established. | 42 * connection, or `null` if no such connection has yet been established. |
45 */ | 43 */ |
46 AnalysisServer analysisServer; | 44 AnalysisServer analysisServer; |
47 | 45 |
48 /** | 46 /** |
49 * The plugins that are defined outside the analysis_server package. | 47 * The plugins that are defined outside the analysis_server package. |
50 */ | 48 */ |
51 List<Plugin> userDefinedPlugins; | 49 List<Plugin> userDefinedPlugins; |
52 | 50 |
53 SocketServer( | 51 SocketServer( |
54 this.analysisServerOptions, | 52 this.analysisServerOptions, |
55 this.defaultSdkCreator, | 53 this.defaultSdkCreator, |
56 this.defaultSdk, | 54 this.defaultSdk, |
57 this.instrumentationService, | 55 this.instrumentationService, |
58 this.serverPlugin, | 56 this.serverPlugin, |
59 this.embeddedResolverProvider, | |
60 this.packageResolverProvider, | 57 this.packageResolverProvider, |
61 this.useSingleContextManager); | 58 this.useSingleContextManager); |
62 | 59 |
63 /** | 60 /** |
64 * Create an analysis server which will communicate with the client using the | 61 * Create an analysis server which will communicate with the client using the |
65 * given serverChannel. | 62 * given serverChannel. |
66 */ | 63 */ |
67 void createAnalysisServer(ServerCommunicationChannel serverChannel) { | 64 void createAnalysisServer(ServerCommunicationChannel serverChannel) { |
68 if (analysisServer != null) { | 65 if (analysisServer != null) { |
69 RequestError error = new RequestError( | 66 RequestError error = new RequestError( |
(...skipping 23 matching lines...) Expand all Loading... |
93 | 90 |
94 analysisServer = new AnalysisServer( | 91 analysisServer = new AnalysisServer( |
95 serverChannel, | 92 serverChannel, |
96 resourceProvider, | 93 resourceProvider, |
97 new PubPackageMapProvider(resourceProvider, defaultSdk), | 94 new PubPackageMapProvider(resourceProvider, defaultSdk), |
98 index, | 95 index, |
99 serverPlugin, | 96 serverPlugin, |
100 analysisServerOptions, | 97 analysisServerOptions, |
101 defaultSdkCreator, | 98 defaultSdkCreator, |
102 instrumentationService, | 99 instrumentationService, |
103 embeddedResolverProvider: embeddedResolverProvider, | |
104 packageResolverProvider: packageResolverProvider, | 100 packageResolverProvider: packageResolverProvider, |
105 useSingleContextManager: useSingleContextManager, | 101 useSingleContextManager: useSingleContextManager, |
106 rethrowExceptions: false); | 102 rethrowExceptions: false); |
107 analysisServer.userDefinedPlugins = userDefinedPlugins; | 103 analysisServer.userDefinedPlugins = userDefinedPlugins; |
108 } | 104 } |
109 } | 105 } |
OLD | NEW |