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

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

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

Powered by Google App Engine
This is Rietveld 408576698