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:analysis_server/src/services/index/local_file_index.dart'; | 12 import 'package:analysis_server/src/services/index/local_file_index.dart'; |
13 import 'package:analyzer/file_system/physical_file_system.dart'; | 13 import 'package:analyzer/file_system/physical_file_system.dart'; |
14 import 'package:analyzer/instrumentation/instrumentation.dart'; | 14 import 'package:analyzer/instrumentation/instrumentation.dart'; |
15 import 'package:analyzer/plugin/embedded_resolver_provider.dart'; | 15 import 'package:analyzer/plugin/embedded_resolver_provider.dart'; |
16 import 'package:analyzer/plugin/resolver_provider.dart'; | 16 import 'package:analyzer/plugin/resolver_provider.dart'; |
17 import 'package:analyzer/source/pub_package_map_provider.dart'; | 17 import 'package:analyzer/source/pub_package_map_provider.dart'; |
| 18 import 'package:analyzer/src/generated/sdk.dart'; |
18 import 'package:analyzer/src/generated/sdk_io.dart'; | 19 import 'package:analyzer/src/generated/sdk_io.dart'; |
19 import 'package:plugin/plugin.dart'; | 20 import 'package:plugin/plugin.dart'; |
20 | 21 |
21 /** | 22 /** |
22 * Instances of the class [SocketServer] implement the common parts of | 23 * Instances of the class [SocketServer] implement the common parts of |
23 * http-based and stdio-based analysis servers. The primary responsibility of | 24 * http-based and stdio-based analysis servers. The primary responsibility of |
24 * the SocketServer is to manage the lifetime of the AnalysisServer and to | 25 * the SocketServer is to manage the lifetime of the AnalysisServer and to |
25 * encode and decode the JSON messages exchanged with the client. | 26 * encode and decode the JSON messages exchanged with the client. |
26 */ | 27 */ |
27 class SocketServer { | 28 class SocketServer { |
28 final AnalysisServerOptions analysisServerOptions; | 29 final AnalysisServerOptions analysisServerOptions; |
| 30 |
| 31 /** |
| 32 * The function used to create a new SDK using the default SDK. |
| 33 */ |
| 34 final SdkCreator defaultSdkCreator; |
| 35 |
29 final DirectoryBasedDartSdk defaultSdk; | 36 final DirectoryBasedDartSdk defaultSdk; |
30 final InstrumentationService instrumentationService; | 37 final InstrumentationService instrumentationService; |
31 final ServerPlugin serverPlugin; | 38 final ServerPlugin serverPlugin; |
32 final EmbeddedResolverProvider embeddedResolverProvider; | 39 final EmbeddedResolverProvider embeddedResolverProvider; |
33 final ResolverProvider packageResolverProvider; | 40 final ResolverProvider packageResolverProvider; |
34 | 41 |
35 /** | 42 /** |
36 * The analysis server that was created when a client established a | 43 * The analysis server that was created when a client established a |
37 * connection, or `null` if no such connection has yet been established. | 44 * connection, or `null` if no such connection has yet been established. |
38 */ | 45 */ |
39 AnalysisServer analysisServer; | 46 AnalysisServer analysisServer; |
40 | 47 |
41 /** | 48 /** |
42 * The plugins that are defined outside the analysis_server package. | 49 * The plugins that are defined outside the analysis_server package. |
43 */ | 50 */ |
44 List<Plugin> userDefinedPlugins; | 51 List<Plugin> userDefinedPlugins; |
45 | 52 |
46 SocketServer( | 53 SocketServer( |
47 this.analysisServerOptions, | 54 this.analysisServerOptions, |
| 55 this.defaultSdkCreator, |
48 this.defaultSdk, | 56 this.defaultSdk, |
49 this.instrumentationService, | 57 this.instrumentationService, |
50 this.serverPlugin, | 58 this.serverPlugin, |
51 this.packageResolverProvider, | 59 this.packageResolverProvider, |
52 this.embeddedResolverProvider); | 60 this.embeddedResolverProvider); |
53 | 61 |
54 /** | 62 /** |
55 * Create an analysis server which will communicate with the client using the | 63 * Create an analysis server which will communicate with the client using the |
56 * given serverChannel. | 64 * given serverChannel. |
57 */ | 65 */ |
(...skipping 26 matching lines...) Expand all Loading... |
84 index.run(); | 92 index.run(); |
85 } | 93 } |
86 | 94 |
87 analysisServer = new AnalysisServer( | 95 analysisServer = new AnalysisServer( |
88 serverChannel, | 96 serverChannel, |
89 resourceProvider, | 97 resourceProvider, |
90 new PubPackageMapProvider(resourceProvider, defaultSdk), | 98 new PubPackageMapProvider(resourceProvider, defaultSdk), |
91 index, | 99 index, |
92 serverPlugin, | 100 serverPlugin, |
93 analysisServerOptions, | 101 analysisServerOptions, |
94 defaultSdk, | 102 defaultSdkCreator, |
95 instrumentationService, | 103 instrumentationService, |
96 packageResolverProvider: packageResolverProvider, | 104 packageResolverProvider: packageResolverProvider, |
97 embeddedResolverProvider: embeddedResolverProvider, | 105 embeddedResolverProvider: embeddedResolverProvider, |
98 rethrowExceptions: false); | 106 rethrowExceptions: false); |
99 analysisServer.userDefinedPlugins = userDefinedPlugins; | 107 analysisServer.userDefinedPlugins = userDefinedPlugins; |
100 } | 108 } |
101 } | 109 } |
OLD | NEW |