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

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

Issue 300023004: Partial implementation of the 'setAnalysisRoots' API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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.dart'; 8 import 'package:analysis_server/src/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_context.dart'; 10 import 'package:analysis_server/src/domain_context.dart';
11 import 'package:analysis_server/src/domain_server.dart'; 11 import 'package:analysis_server/src/domain_server.dart';
12 import 'package:analysis_server/src/protocol.dart'; 12 import 'package:analysis_server/src/protocol.dart';
13 import 'package:analysis_server/src/resource.dart';
13 14
14 /** 15 /**
15 * Instances of the class [SocketServer] implement the common parts of 16 * Instances of the class [SocketServer] implement the common parts of
16 * http-based and stdio-based analysis servers. The primary responsibility of 17 * http-based and stdio-based analysis servers. The primary responsibility of
17 * the SocketServer is to manage the lifetime of the AnalysisServer and to 18 * the SocketServer is to manage the lifetime of the AnalysisServer and to
18 * encode and decode the JSON messages exchanged with the client. 19 * encode and decode the JSON messages exchanged with the client.
19 */ 20 */
20 class SocketServer { 21 class SocketServer {
21 /** 22 /**
22 * The analysis server that was created when a client established a 23 * The analysis server that was created when a client established a
23 * connection, or `null` if no such connection has yet been established. 24 * connection, or `null` if no such connection has yet been established.
24 */ 25 */
25 AnalysisServer analysisServer; 26 AnalysisServer analysisServer;
26 27
27 /** 28 /**
28 * Create an analysis server which will communicate with the client using the 29 * Create an analysis server which will communicate with the client using the
29 * given serverChannel. 30 * given serverChannel.
30 */ 31 */
31 void createAnalysisServer(ServerCommunicationChannel serverChannel) { 32 void createAnalysisServer(ServerCommunicationChannel serverChannel) {
32 if (analysisServer != null) { 33 if (analysisServer != null) {
33 RequestError error = new RequestError.serverAlreadyStarted(); 34 RequestError error = new RequestError.serverAlreadyStarted();
34 serverChannel.sendResponse(new Response('', error)); 35 serverChannel.sendResponse(new Response('', error));
35 serverChannel.listen((Request request) { 36 serverChannel.listen((Request request) {
36 serverChannel.sendResponse(new Response(request.id, error)); 37 serverChannel.sendResponse(new Response(request.id, error));
37 }); 38 });
38 return; 39 return;
39 } 40 }
40 analysisServer = new AnalysisServer(serverChannel); 41 analysisServer = new AnalysisServer(
42 serverChannel,
43 PhysicalResourceProvider.INSTANCE);
41 _initializeHandlers(analysisServer); 44 _initializeHandlers(analysisServer);
42 } 45 }
43 46
44 /** 47 /**
45 * Initialize the handlers to be used by the given [server]. 48 * Initialize the handlers to be used by the given [server].
46 */ 49 */
47 void _initializeHandlers(AnalysisServer server) { 50 void _initializeHandlers(AnalysisServer server) {
48 server.handlers = [ 51 server.handlers = [
49 new ServerDomainHandler(server), 52 new ServerDomainHandler(server),
50 new AnalysisDomainHandler(server), 53 new AnalysisDomainHandler(server),
51 new ContextDomainHandler(server), 54 new ContextDomainHandler(server),
52 ]; 55 ];
53 } 56 }
54 57
55 } 58 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698