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/plugin/server_plugin.dart'; | 9 import 'package:analysis_server/src/plugin/server_plugin.dart'; |
10 import 'package:analysis_server/src/protocol.dart'; | 10 import 'package:analysis_server/src/protocol.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:analysis_server/src/source/optimizing_pub_package_map_provider.d
art'; | 13 import 'package:analysis_server/src/source/optimizing_pub_package_map_provider.d
art'; |
| 14 import 'package:analysis_server/uri/resolver_provider.dart'; |
14 import 'package:analyzer/file_system/physical_file_system.dart'; | 15 import 'package:analyzer/file_system/physical_file_system.dart'; |
15 import 'package:analyzer/instrumentation/instrumentation.dart'; | 16 import 'package:analyzer/instrumentation/instrumentation.dart'; |
16 import 'package:analyzer/src/generated/sdk_io.dart'; | 17 import 'package:analyzer/src/generated/sdk_io.dart'; |
17 import 'package:plugin/plugin.dart'; | 18 import 'package:plugin/plugin.dart'; |
18 | 19 |
19 /** | 20 /** |
20 * Instances of the class [SocketServer] implement the common parts of | 21 * Instances of the class [SocketServer] implement the common parts of |
21 * http-based and stdio-based analysis servers. The primary responsibility of | 22 * http-based and stdio-based analysis servers. The primary responsibility of |
22 * 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 |
23 * encode and decode the JSON messages exchanged with the client. | 24 * encode and decode the JSON messages exchanged with the client. |
24 */ | 25 */ |
25 class SocketServer { | 26 class SocketServer { |
26 final AnalysisServerOptions analysisServerOptions; | 27 final AnalysisServerOptions analysisServerOptions; |
27 final DirectoryBasedDartSdk defaultSdk; | 28 final DirectoryBasedDartSdk defaultSdk; |
28 final InstrumentationService instrumentationService; | 29 final InstrumentationService instrumentationService; |
29 final ServerPlugin serverPlugin; | 30 final ServerPlugin serverPlugin; |
| 31 final ResolverProvider packageResolverProvider; |
30 | 32 |
31 /** | 33 /** |
32 * The analysis server that was created when a client established a | 34 * The analysis server that was created when a client established a |
33 * connection, or `null` if no such connection has yet been established. | 35 * connection, or `null` if no such connection has yet been established. |
34 */ | 36 */ |
35 AnalysisServer analysisServer; | 37 AnalysisServer analysisServer; |
36 | 38 |
37 /** | 39 /** |
38 * The plugins that are defined outside the analysis_server package. | 40 * The plugins that are defined outside the analysis_server package. |
39 */ | 41 */ |
40 List<Plugin> userDefinedPlugins; | 42 List<Plugin> userDefinedPlugins; |
41 | 43 |
42 SocketServer(this.analysisServerOptions, this.defaultSdk, | 44 SocketServer(this.analysisServerOptions, this.defaultSdk, |
43 this.instrumentationService, this.serverPlugin); | 45 this.instrumentationService, this.serverPlugin, |
| 46 this.packageResolverProvider); |
44 | 47 |
45 /** | 48 /** |
46 * Create an analysis server which will communicate with the client using the | 49 * Create an analysis server which will communicate with the client using the |
47 * given serverChannel. | 50 * given serverChannel. |
48 */ | 51 */ |
49 void createAnalysisServer(ServerCommunicationChannel serverChannel) { | 52 void createAnalysisServer(ServerCommunicationChannel serverChannel) { |
50 if (analysisServer != null) { | 53 if (analysisServer != null) { |
51 RequestError error = new RequestError( | 54 RequestError error = new RequestError( |
52 RequestErrorCode.SERVER_ALREADY_STARTED, "Server already started"); | 55 RequestErrorCode.SERVER_ALREADY_STARTED, "Server already started"); |
53 serverChannel.sendResponse(new Response('', error: error)); | 56 serverChannel.sendResponse(new Response('', error: error)); |
(...skipping 17 matching lines...) Expand all Loading... |
71 Index index = null; | 74 Index index = null; |
72 if (!analysisServerOptions.noIndex) { | 75 if (!analysisServerOptions.noIndex) { |
73 index = createLocalFileIndex(); | 76 index = createLocalFileIndex(); |
74 index.contributors = serverPlugin.indexContributors; | 77 index.contributors = serverPlugin.indexContributors; |
75 index.run(); | 78 index.run(); |
76 } | 79 } |
77 | 80 |
78 analysisServer = new AnalysisServer(serverChannel, resourceProvider, | 81 analysisServer = new AnalysisServer(serverChannel, resourceProvider, |
79 new OptimizingPubPackageMapProvider(resourceProvider, defaultSdk), | 82 new OptimizingPubPackageMapProvider(resourceProvider, defaultSdk), |
80 index, serverPlugin, analysisServerOptions, defaultSdk, | 83 index, serverPlugin, analysisServerOptions, defaultSdk, |
81 instrumentationService, rethrowExceptions: false); | 84 instrumentationService, |
| 85 packageResolverProvider: packageResolverProvider, |
| 86 rethrowExceptions: false); |
82 analysisServer.userDefinedPlugins = userDefinedPlugins; | 87 analysisServer.userDefinedPlugins = userDefinedPlugins; |
83 } | 88 } |
84 } | 89 } |
OLD | NEW |