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

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

Issue 787763004: Hooks for instrumentation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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/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'; 11 import 'package:analysis_server/src/domain_execution.dart';
12 import 'package:analysis_server/src/domain_server.dart'; 12 import 'package:analysis_server/src/domain_server.dart';
13 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'; 14 import 'package:analysis_server/src/protocol.dart';
15 import 'package:analysis_server/src/search/search_domain.dart'; 15 import 'package:analysis_server/src/search/search_domain.dart';
16 import 'package:analysis_server/src/services/index/index.dart'; 16 import 'package:analysis_server/src/services/index/index.dart';
17 import 'package:analysis_server/src/services/index/local_file_index.dart'; 17 import 'package:analysis_server/src/services/index/local_file_index.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/instrumentation/instrumentation.dart';
19 import 'package:analyzer/source/pub_package_map_provider.dart'; 20 import 'package:analyzer/source/pub_package_map_provider.dart';
20 import 'package:analyzer/src/generated/sdk_io.dart'; 21 import 'package:analyzer/src/generated/sdk_io.dart';
21 22
22 23
23 /** 24 /**
24 * Creates and runs an [Index]. 25 * Creates and runs an [Index].
25 */ 26 */
26 Index _createIndex() { 27 Index _createIndex() {
27 Index index = createLocalFileIndex(); 28 Index index = createLocalFileIndex();
28 index.run(); 29 index.run();
29 return index; 30 return index;
30 } 31 }
31 32
32 33
33 /** 34 /**
34 * Instances of the class [SocketServer] implement the common parts of 35 * Instances of the class [SocketServer] implement the common parts of
35 * http-based and stdio-based analysis servers. The primary responsibility of 36 * http-based and stdio-based analysis servers. The primary responsibility of
36 * the SocketServer is to manage the lifetime of the AnalysisServer and to 37 * the SocketServer is to manage the lifetime of the AnalysisServer and to
37 * encode and decode the JSON messages exchanged with the client. 38 * encode and decode the JSON messages exchanged with the client.
38 */ 39 */
39 class SocketServer { 40 class SocketServer {
40 final AnalysisServerOptions analysisServerOptions; 41 final AnalysisServerOptions analysisServerOptions;
41 final DirectoryBasedDartSdk defaultSdk; 42 final DirectoryBasedDartSdk defaultSdk;
43 final InstrumentationServer instrumentationServer;
42 44
43 /** 45 /**
44 * The analysis server that was created when a client established a 46 * The analysis server that was created when a client established a
45 * connection, or `null` if no such connection has yet been established. 47 * connection, or `null` if no such connection has yet been established.
46 */ 48 */
47 AnalysisServer analysisServer; 49 AnalysisServer analysisServer;
48 50
49 SocketServer(this.analysisServerOptions, this.defaultSdk); 51 SocketServer(this.analysisServerOptions, this.defaultSdk,
52 this.instrumentationServer);
50 53
51 /** 54 /**
52 * Create an analysis server which will communicate with the client using the 55 * Create an analysis server which will communicate with the client using the
53 * given serverChannel. 56 * given serverChannel.
54 */ 57 */
55 void createAnalysisServer(ServerCommunicationChannel serverChannel) { 58 void createAnalysisServer(ServerCommunicationChannel serverChannel) {
56 if (analysisServer != null) { 59 if (analysisServer != null) {
57 RequestError error = new RequestError( 60 RequestError error = new RequestError(
58 RequestErrorCode.SERVER_ALREADY_STARTED, 61 RequestErrorCode.SERVER_ALREADY_STARTED,
59 "Server already started"); 62 "Server already started");
60 serverChannel.sendResponse(new Response('', error: error)); 63 serverChannel.sendResponse(new Response('', error: error));
61 serverChannel.listen((Request request) { 64 serverChannel.listen((Request request) {
62 serverChannel.sendResponse(new Response(request.id, error: error)); 65 serverChannel.sendResponse(new Response(request.id, error: error));
63 }); 66 });
64 return; 67 return;
65 } 68 }
66 PhysicalResourceProvider resourceProvider = 69 PhysicalResourceProvider resourceProvider =
67 PhysicalResourceProvider.INSTANCE; 70 PhysicalResourceProvider.INSTANCE;
68 analysisServer = new AnalysisServer( 71 analysisServer = new AnalysisServer(
69 serverChannel, 72 serverChannel,
70 resourceProvider, 73 resourceProvider,
71 new PubPackageMapProvider(resourceProvider, defaultSdk), 74 new PubPackageMapProvider(resourceProvider, defaultSdk),
72 _createIndex(), 75 _createIndex(),
73 analysisServerOptions, 76 analysisServerOptions,
74 defaultSdk, 77 defaultSdk,
78 instrumentationServer,
75 rethrowExceptions: false); 79 rethrowExceptions: false);
76 _initializeHandlers(analysisServer); 80 _initializeHandlers(analysisServer);
77 } 81 }
78 82
79 /** 83 /**
80 * Initialize the handlers to be used by the given [server]. 84 * Initialize the handlers to be used by the given [server].
81 */ 85 */
82 void _initializeHandlers(AnalysisServer server) { 86 void _initializeHandlers(AnalysisServer server) {
83 server.handlers = [ 87 server.handlers = [
84 new ServerDomainHandler(server), 88 new ServerDomainHandler(server),
85 new AnalysisDomainHandler(server), 89 new AnalysisDomainHandler(server),
86 new EditDomainHandler(server), 90 new EditDomainHandler(server),
87 new SearchDomainHandler(server), 91 new SearchDomainHandler(server),
88 new CompletionDomainHandler(server), 92 new CompletionDomainHandler(server),
89 new ExecutionDomainHandler(server),]; 93 new ExecutionDomainHandler(server),];
90 } 94 }
91 } 95 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.dart ('k') | pkg/analysis_server/test/analysis_abstract.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698