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