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/domain_analysis.dart'; | 9 import 'package:analysis_server/src/domain_analysis.dart'; |
10 import 'package:analysis_server/src/domain_completion.dart'; | 10 import 'package:analysis_server/src/domain_completion.dart'; |
| 11 import 'package:analysis_server/src/domain_execution.dart'; |
| 12 import 'package:analysis_server/src/domain_server.dart'; |
11 import 'package:analysis_server/src/edit/edit_domain.dart'; | 13 import 'package:analysis_server/src/edit/edit_domain.dart'; |
| 14 import 'package:analysis_server/src/protocol.dart'; |
12 import 'package:analysis_server/src/search/search_domain.dart'; | 15 import 'package:analysis_server/src/search/search_domain.dart'; |
13 import 'package:analysis_server/src/domain_server.dart'; | |
14 import 'package:analyzer/source/pub_package_map_provider.dart'; | |
15 import 'package:analysis_server/src/protocol.dart'; | |
16 import 'package:analyzer/file_system/physical_file_system.dart'; | |
17 import 'package:analyzer/src/generated/sdk_io.dart'; | |
18 import 'package:analysis_server/src/services/index/index.dart'; | 16 import 'package:analysis_server/src/services/index/index.dart'; |
19 import 'package:analysis_server/src/services/index/local_file_index.dart'; | 17 import 'package:analysis_server/src/services/index/local_file_index.dart'; |
20 import 'package:analysis_server/src/domain_execution.dart'; | 18 import 'package:analyzer/file_system/physical_file_system.dart'; |
| 19 import 'package:analyzer/source/pub_package_map_provider.dart'; |
| 20 import 'package:analyzer/src/generated/sdk_io.dart'; |
21 | 21 |
22 | 22 |
23 /** | 23 /** |
24 * Creates and runs an [Index]. | 24 * Creates and runs an [Index]. |
25 */ | 25 */ |
26 Index _createIndex() { | 26 Index _createIndex() { |
27 Index index = createLocalFileIndex(); | 27 Index index = createLocalFileIndex(); |
28 index.run(); | 28 index.run(); |
29 return index; | 29 return index; |
30 } | 30 } |
(...skipping 16 matching lines...) Expand all Loading... |
47 | 47 |
48 SocketServer(this.defaultSdk); | 48 SocketServer(this.defaultSdk); |
49 | 49 |
50 /** | 50 /** |
51 * Create an analysis server which will communicate with the client using the | 51 * Create an analysis server which will communicate with the client using the |
52 * given serverChannel. | 52 * given serverChannel. |
53 */ | 53 */ |
54 void createAnalysisServer(ServerCommunicationChannel serverChannel) { | 54 void createAnalysisServer(ServerCommunicationChannel serverChannel) { |
55 if (analysisServer != null) { | 55 if (analysisServer != null) { |
56 RequestError error = new RequestError( | 56 RequestError error = new RequestError( |
57 RequestErrorCode.SERVER_ALREADY_STARTED, "Server already started"); | 57 RequestErrorCode.SERVER_ALREADY_STARTED, |
| 58 "Server already started"); |
58 serverChannel.sendResponse(new Response('', error: error)); | 59 serverChannel.sendResponse(new Response('', error: error)); |
59 serverChannel.listen((Request request) { | 60 serverChannel.listen((Request request) { |
60 serverChannel.sendResponse(new Response(request.id, error: error)); | 61 serverChannel.sendResponse(new Response(request.id, error: error)); |
61 }); | 62 }); |
62 return; | 63 return; |
63 } | 64 } |
64 PhysicalResourceProvider resourceProvider = PhysicalResourceProvider.INSTANC
E; | 65 PhysicalResourceProvider resourceProvider = |
| 66 PhysicalResourceProvider.INSTANCE; |
65 analysisServer = new AnalysisServer( | 67 analysisServer = new AnalysisServer( |
66 serverChannel, | 68 serverChannel, |
67 resourceProvider, | 69 resourceProvider, |
68 new PubPackageMapProvider(resourceProvider, defaultSdk), | 70 new PubPackageMapProvider(resourceProvider, defaultSdk), |
69 _createIndex(), | 71 _createIndex(), |
70 defaultSdk, | 72 defaultSdk, |
71 rethrowExceptions: false); | 73 rethrowExceptions: false); |
72 _initializeHandlers(analysisServer); | 74 _initializeHandlers(analysisServer); |
73 } | 75 } |
74 | 76 |
75 /** | 77 /** |
76 * Initialize the handlers to be used by the given [server]. | 78 * Initialize the handlers to be used by the given [server]. |
77 */ | 79 */ |
78 void _initializeHandlers(AnalysisServer server) { | 80 void _initializeHandlers(AnalysisServer server) { |
79 server.handlers = [ | 81 server.handlers = [ |
80 new ServerDomainHandler(server), | 82 new ServerDomainHandler(server), |
81 new AnalysisDomainHandler(server), | 83 new AnalysisDomainHandler(server), |
82 new EditDomainHandler(server), | 84 new EditDomainHandler(server), |
83 new SearchDomainHandler(server), | 85 new SearchDomainHandler(server), |
84 new CompletionDomainHandler(server), | 86 new CompletionDomainHandler(server), |
85 new ExecutionDomainHandler(server), | 87 new ExecutionDomainHandler(server),]; |
86 ]; | |
87 } | 88 } |
88 } | 89 } |
OLD | NEW |