Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Side by Side Diff: pkg/analysis_server/lib/src/socket_server.dart

Issue 846723002: Make domains plugable (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/plugin/server_plugin.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';
13 import 'package:analysis_server/src/edit/edit_domain.dart';
14 import 'package:analysis_server/src/protocol.dart'; 10 import 'package:analysis_server/src/protocol.dart';
15 import 'package:analysis_server/src/search/search_domain.dart';
16 import 'package:analysis_server/src/services/index/index.dart'; 11 import 'package:analysis_server/src/services/index/index.dart';
17 import 'package:analysis_server/src/services/index/local_file_index.dart'; 12 import 'package:analysis_server/src/services/index/local_file_index.dart';
18 import 'package:analyzer/file_system/physical_file_system.dart'; 13 import 'package:analyzer/file_system/physical_file_system.dart';
19 import 'package:analyzer/instrumentation/instrumentation.dart'; 14 import 'package:analyzer/instrumentation/instrumentation.dart';
20 import 'package:analyzer/source/pub_package_map_provider.dart'; 15 import 'package:analyzer/source/pub_package_map_provider.dart';
21 import 'package:analyzer/src/generated/sdk_io.dart'; 16 import 'package:analyzer/src/generated/sdk_io.dart';
22 17
23 18
24 /** 19 /**
25 * Creates and runs an [Index]. 20 * Creates and runs an [Index].
26 */ 21 */
27 Index _createIndex() { 22 Index _createIndex() {
28 Index index = createLocalFileIndex(); 23 Index index = createLocalFileIndex();
29 index.run(); 24 index.run();
30 return index; 25 return index;
31 } 26 }
32 27
33 28
34 /** 29 /**
35 * Instances of the class [SocketServer] implement the common parts of 30 * Instances of the class [SocketServer] implement the common parts of
36 * http-based and stdio-based analysis servers. The primary responsibility of 31 * http-based and stdio-based analysis servers. The primary responsibility of
37 * the SocketServer is to manage the lifetime of the AnalysisServer and to 32 * the SocketServer is to manage the lifetime of the AnalysisServer and to
38 * encode and decode the JSON messages exchanged with the client. 33 * encode and decode the JSON messages exchanged with the client.
39 */ 34 */
40 class SocketServer { 35 class SocketServer {
41 final AnalysisServerOptions analysisServerOptions; 36 final AnalysisServerOptions analysisServerOptions;
42 final DirectoryBasedDartSdk defaultSdk; 37 final DirectoryBasedDartSdk defaultSdk;
43 final InstrumentationService instrumentationService; 38 final InstrumentationService instrumentationService;
39 final ServerPlugin serverPlugin;
44 40
45 /** 41 /**
46 * The analysis server that was created when a client established a 42 * The analysis server that was created when a client established a
47 * connection, or `null` if no such connection has yet been established. 43 * connection, or `null` if no such connection has yet been established.
48 */ 44 */
49 AnalysisServer analysisServer; 45 AnalysisServer analysisServer;
50 46
51 SocketServer(this.analysisServerOptions, this.defaultSdk, 47 SocketServer(this.analysisServerOptions, this.defaultSdk,
52 this.instrumentationService); 48 this.instrumentationService, this.serverPlugin);
53 49
54 /** 50 /**
55 * 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
56 * given serverChannel. 52 * given serverChannel.
57 */ 53 */
58 void createAnalysisServer(ServerCommunicationChannel serverChannel) { 54 void createAnalysisServer(ServerCommunicationChannel serverChannel) {
59 if (analysisServer != null) { 55 if (analysisServer != null) {
60 RequestError error = new RequestError( 56 RequestError error = new RequestError(
61 RequestErrorCode.SERVER_ALREADY_STARTED, 57 RequestErrorCode.SERVER_ALREADY_STARTED,
62 "Server already started"); 58 "Server already started");
(...skipping 14 matching lines...) Expand all
77 defaultSdk, 73 defaultSdk,
78 instrumentationService, 74 instrumentationService,
79 rethrowExceptions: false); 75 rethrowExceptions: false);
80 _initializeHandlers(analysisServer); 76 _initializeHandlers(analysisServer);
81 } 77 }
82 78
83 /** 79 /**
84 * Initialize the handlers to be used by the given [server]. 80 * Initialize the handlers to be used by the given [server].
85 */ 81 */
86 void _initializeHandlers(AnalysisServer server) { 82 void _initializeHandlers(AnalysisServer server) {
87 server.handlers = [ 83 server.handlers = serverPlugin.createDomains(server);
88 new ServerDomainHandler(server),
89 new AnalysisDomainHandler(server),
90 new EditDomainHandler(server),
91 new SearchDomainHandler(server),
92 new CompletionDomainHandler(server),
93 new ExecutionDomainHandler(server),];
94 } 84 }
95 } 85 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698