| 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 import 'package:analysis_server/protocol/protocol.dart'; | 5 import 'package:analysis_server/protocol/protocol.dart'; |
| 6 import 'package:analysis_server/protocol/protocol_generated.dart'; | 6 import 'package:analysis_server/protocol/protocol_generated.dart'; |
| 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'; | |
| 10 import 'package:analysis_server/src/server/diagnostic_server.dart'; | 9 import 'package:analysis_server/src/server/diagnostic_server.dart'; |
| 11 import 'package:analyzer/file_system/physical_file_system.dart'; | 10 import 'package:analyzer/file_system/physical_file_system.dart'; |
| 12 import 'package:analyzer/instrumentation/instrumentation.dart'; | 11 import 'package:analyzer/instrumentation/instrumentation.dart'; |
| 13 import 'package:analyzer/plugin/resolver_provider.dart'; | 12 import 'package:analyzer/plugin/resolver_provider.dart'; |
| 14 import 'package:analyzer/source/pub_package_map_provider.dart'; | 13 import 'package:analyzer/source/pub_package_map_provider.dart'; |
| 15 import 'package:analyzer/src/generated/sdk.dart'; | 14 import 'package:analyzer/src/generated/sdk.dart'; |
| 16 import 'package:plugin/plugin.dart'; | 15 import 'package:plugin/plugin.dart'; |
| 17 | 16 |
| 18 /** | 17 /** |
| 19 * Instances of the class [SocketServer] implement the common parts of | 18 * Instances of the class [SocketServer] implement the common parts of |
| 20 * http-based and stdio-based analysis servers. The primary responsibility of | 19 * http-based and stdio-based analysis servers. The primary responsibility of |
| 21 * the SocketServer is to manage the lifetime of the AnalysisServer and to | 20 * the SocketServer is to manage the lifetime of the AnalysisServer and to |
| 22 * encode and decode the JSON messages exchanged with the client. | 21 * encode and decode the JSON messages exchanged with the client. |
| 23 */ | 22 */ |
| 24 class SocketServer { | 23 class SocketServer { |
| 25 final AnalysisServerOptions analysisServerOptions; | 24 final AnalysisServerOptions analysisServerOptions; |
| 26 | 25 |
| 27 /** | 26 /** |
| 28 * The function used to create a new SDK using the default SDK. | 27 * The function used to create a new SDK using the default SDK. |
| 29 */ | 28 */ |
| 30 final DartSdkManager sdkManager; | 29 final DartSdkManager sdkManager; |
| 31 | 30 |
| 32 final DartSdk defaultSdk; | 31 final DartSdk defaultSdk; |
| 33 final InstrumentationService instrumentationService; | 32 final InstrumentationService instrumentationService; |
| 34 final DiagnosticServer diagnosticServer; | 33 final DiagnosticServer diagnosticServer; |
| 35 final ServerPlugin serverPlugin; | |
| 36 final ResolverProvider fileResolverProvider; | 34 final ResolverProvider fileResolverProvider; |
| 37 final ResolverProvider packageResolverProvider; | 35 final ResolverProvider packageResolverProvider; |
| 38 | 36 |
| 39 /** | 37 /** |
| 40 * The analysis server that was created when a client established a | 38 * The analysis server that was created when a client established a |
| 41 * connection, or `null` if no such connection has yet been established. | 39 * connection, or `null` if no such connection has yet been established. |
| 42 */ | 40 */ |
| 43 AnalysisServer analysisServer; | 41 AnalysisServer analysisServer; |
| 44 | 42 |
| 45 /** | 43 /** |
| 46 * The plugins that are defined outside the analysis_server package. | 44 * The plugins that are defined outside the analysis_server package. |
| 47 */ | 45 */ |
| 48 List<Plugin> userDefinedPlugins; | 46 List<Plugin> userDefinedPlugins; |
| 49 | 47 |
| 50 SocketServer( | 48 SocketServer( |
| 51 this.analysisServerOptions, | 49 this.analysisServerOptions, |
| 52 this.sdkManager, | 50 this.sdkManager, |
| 53 this.defaultSdk, | 51 this.defaultSdk, |
| 54 this.instrumentationService, | 52 this.instrumentationService, |
| 55 this.diagnosticServer, | 53 this.diagnosticServer, |
| 56 this.serverPlugin, | |
| 57 this.fileResolverProvider, | 54 this.fileResolverProvider, |
| 58 this.packageResolverProvider); | 55 this.packageResolverProvider); |
| 59 | 56 |
| 60 /** | 57 /** |
| 61 * Create an analysis server which will communicate with the client using the | 58 * Create an analysis server which will communicate with the client using the |
| 62 * given serverChannel. | 59 * given serverChannel. |
| 63 */ | 60 */ |
| 64 void createAnalysisServer(ServerCommunicationChannel serverChannel) { | 61 void createAnalysisServer(ServerCommunicationChannel serverChannel) { |
| 65 if (analysisServer != null) { | 62 if (analysisServer != null) { |
| 66 RequestError error = new RequestError( | 63 RequestError error = new RequestError( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 80 PhysicalResourceProvider.NORMALIZE_EOL_ALWAYS); | 77 PhysicalResourceProvider.NORMALIZE_EOL_ALWAYS); |
| 81 } else { | 78 } else { |
| 82 throw new Exception( | 79 throw new Exception( |
| 83 'File read mode was set to the unknown mode: $analysisServerOptions.fi
leReadMode'); | 80 'File read mode was set to the unknown mode: $analysisServerOptions.fi
leReadMode'); |
| 84 } | 81 } |
| 85 | 82 |
| 86 analysisServer = new AnalysisServer( | 83 analysisServer = new AnalysisServer( |
| 87 serverChannel, | 84 serverChannel, |
| 88 resourceProvider, | 85 resourceProvider, |
| 89 new PubPackageMapProvider(resourceProvider, defaultSdk), | 86 new PubPackageMapProvider(resourceProvider, defaultSdk), |
| 90 serverPlugin, | |
| 91 analysisServerOptions, | 87 analysisServerOptions, |
| 92 sdkManager, | 88 sdkManager, |
| 93 instrumentationService, | 89 instrumentationService, |
| 94 diagnosticServer: diagnosticServer, | 90 diagnosticServer: diagnosticServer, |
| 95 fileResolverProvider: fileResolverProvider, | 91 fileResolverProvider: fileResolverProvider, |
| 96 packageResolverProvider: packageResolverProvider); | 92 packageResolverProvider: packageResolverProvider); |
| 97 analysisServer.userDefinedPlugins = userDefinedPlugins; | 93 analysisServer.userDefinedPlugins = userDefinedPlugins; |
| 98 } | 94 } |
| 99 } | 95 } |
| OLD | NEW |