| 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 'dart:io' as io; | 7 import 'dart:io' as io; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/analysis_server.dart'; | 9 import 'package:analysis_server/src/analysis_server.dart'; |
| 10 import 'package:analysis_server/src/channel.dart'; | 10 import 'package:analysis_server/src/channel.dart'; |
| 11 import 'package:analysis_server/src/domain_analysis.dart'; | 11 import 'package:analysis_server/src/domain_analysis.dart'; |
| 12 import 'package:analysis_server/src/domain_completion.dart'; | 12 import 'package:analysis_server/src/domain_completion.dart'; |
| 13 import 'package:analysis_server/src/domain_edit.dart'; | 13 import 'package:analysis_server/src/domain_edit.dart'; |
| 14 import 'package:analysis_server/src/search/search_domain.dart'; | 14 import 'package:analysis_server/src/search/search_domain.dart'; |
| 15 import 'package:analysis_server/src/domain_server.dart'; | 15 import 'package:analysis_server/src/domain_server.dart'; |
| 16 import 'package:analysis_server/src/package_map_provider.dart'; | 16 import 'package:analysis_server/src/package_map_provider.dart'; |
| 17 import 'package:analysis_server/src/protocol.dart'; | 17 import 'package:analysis_server/src/protocol.dart'; |
| 18 import 'package:analyzer/file_system/physical_file_system.dart'; | 18 import 'package:analyzer/file_system/physical_file_system.dart'; |
| 19 import 'package:analyzer/src/generated/sdk_io.dart'; |
| 19 import 'package:path/path.dart' as pathos; | 20 import 'package:path/path.dart' as pathos; |
| 20 import 'package:analysis_services/index/index.dart'; | 21 import 'package:analysis_services/index/index.dart'; |
| 21 import 'package:analysis_services/index/local_file_index.dart'; | 22 import 'package:analysis_services/index/local_file_index.dart'; |
| 22 | 23 |
| 23 | 24 |
| 24 /** | 25 /** |
| 25 * Creates and runs an [Index]. | 26 * Creates and runs an [Index]. |
| 26 */ | 27 */ |
| 27 Index _createIndex() { | 28 Index _createIndex() { |
| 28 String tempPath = io.Directory.systemTemp.path; | 29 String tempPath = io.Directory.systemTemp.path; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 46 * the SocketServer is to manage the lifetime of the AnalysisServer and to | 47 * the SocketServer is to manage the lifetime of the AnalysisServer and to |
| 47 * encode and decode the JSON messages exchanged with the client. | 48 * encode and decode the JSON messages exchanged with the client. |
| 48 */ | 49 */ |
| 49 class SocketServer { | 50 class SocketServer { |
| 50 /** | 51 /** |
| 51 * The analysis server that was created when a client established a | 52 * The analysis server that was created when a client established a |
| 52 * connection, or `null` if no such connection has yet been established. | 53 * connection, or `null` if no such connection has yet been established. |
| 53 */ | 54 */ |
| 54 AnalysisServer analysisServer; | 55 AnalysisServer analysisServer; |
| 55 | 56 |
| 57 final DirectoryBasedDartSdk defaultSdk; |
| 58 |
| 59 SocketServer(this.defaultSdk); |
| 60 |
| 56 /** | 61 /** |
| 57 * Create an analysis server which will communicate with the client using the | 62 * Create an analysis server which will communicate with the client using the |
| 58 * given serverChannel. | 63 * given serverChannel. |
| 59 */ | 64 */ |
| 60 void createAnalysisServer(ServerCommunicationChannel serverChannel) { | 65 void createAnalysisServer(ServerCommunicationChannel serverChannel) { |
| 61 if (analysisServer != null) { | 66 if (analysisServer != null) { |
| 62 RequestError error = new RequestError.serverAlreadyStarted(); | 67 RequestError error = new RequestError.serverAlreadyStarted(); |
| 63 serverChannel.sendResponse(new Response('', error)); | 68 serverChannel.sendResponse(new Response('', error)); |
| 64 serverChannel.listen((Request request) { | 69 serverChannel.listen((Request request) { |
| 65 serverChannel.sendResponse(new Response(request.id, error)); | 70 serverChannel.sendResponse(new Response(request.id, error)); |
| 66 }); | 71 }); |
| 67 return; | 72 return; |
| 68 } | 73 } |
| 69 PhysicalResourceProvider resourceProvider = PhysicalResourceProvider.INSTANC
E; | 74 PhysicalResourceProvider resourceProvider = PhysicalResourceProvider.INSTANC
E; |
| 70 analysisServer = new AnalysisServer( | 75 analysisServer = new AnalysisServer( |
| 71 serverChannel, | 76 serverChannel, |
| 72 resourceProvider, | 77 resourceProvider, |
| 73 new PubPackageMapProvider(resourceProvider), | 78 new PubPackageMapProvider(resourceProvider, defaultSdk), |
| 74 _createIndex(), | 79 _createIndex(), |
| 80 defaultSdk, |
| 75 rethrowExceptions: false); | 81 rethrowExceptions: false); |
| 76 _initializeHandlers(analysisServer); | 82 _initializeHandlers(analysisServer); |
| 77 } | 83 } |
| 78 | 84 |
| 79 /** | 85 /** |
| 80 * Initialize the handlers to be used by the given [server]. | 86 * Initialize the handlers to be used by the given [server]. |
| 81 */ | 87 */ |
| 82 void _initializeHandlers(AnalysisServer server) { | 88 void _initializeHandlers(AnalysisServer server) { |
| 83 server.handlers = [ | 89 server.handlers = [ |
| 84 new ServerDomainHandler(server), | 90 new ServerDomainHandler(server), |
| 85 new AnalysisDomainHandler(server), | 91 new AnalysisDomainHandler(server), |
| 86 new EditDomainHandler(server), | 92 new EditDomainHandler(server), |
| 87 new SearchDomainHandler(server), | 93 new SearchDomainHandler(server), |
| 88 new CompletionDomainHandler(server), | 94 new CompletionDomainHandler(server), |
| 89 ]; | 95 ]; |
| 90 } | 96 } |
| 91 } | 97 } |
| OLD | NEW |