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

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

Issue 1223413003: Hook for overriding the ContextManager and some code clean-up (with more to follow) (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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
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/context_manager.dart';
9 import 'package:analysis_server/src/plugin/server_plugin.dart'; 10 import 'package:analysis_server/src/plugin/server_plugin.dart';
10 import 'package:analysis_server/src/protocol.dart'; 11 import 'package:analysis_server/src/protocol.dart';
11 import 'package:analysis_server/src/services/index/index.dart'; 12 import 'package:analysis_server/src/services/index/index.dart';
12 import 'package:analysis_server/src/services/index/local_file_index.dart'; 13 import 'package:analysis_server/src/services/index/local_file_index.dart';
13 import 'package:analysis_server/src/source/optimizing_pub_package_map_provider.d art'; 14 import 'package:analysis_server/src/source/optimizing_pub_package_map_provider.d art';
14 import 'package:analysis_server/uri/resolver_provider.dart'; 15 import 'package:analysis_server/uri/resolver_provider.dart';
15 import 'package:analyzer/file_system/physical_file_system.dart'; 16 import 'package:analyzer/file_system/physical_file_system.dart';
16 import 'package:analyzer/instrumentation/instrumentation.dart'; 17 import 'package:analyzer/instrumentation/instrumentation.dart';
17 import 'package:analyzer/src/generated/sdk_io.dart'; 18 import 'package:analyzer/src/generated/sdk_io.dart';
18 import 'package:plugin/plugin.dart'; 19 import 'package:plugin/plugin.dart';
19 20
20 /** 21 /**
21 * Instances of the class [SocketServer] implement the common parts of 22 * Instances of the class [SocketServer] implement the common parts of
22 * http-based and stdio-based analysis servers. The primary responsibility of 23 * http-based and stdio-based analysis servers. The primary responsibility of
23 * the SocketServer is to manage the lifetime of the AnalysisServer and to 24 * the SocketServer is to manage the lifetime of the AnalysisServer and to
24 * encode and decode the JSON messages exchanged with the client. 25 * encode and decode the JSON messages exchanged with the client.
25 */ 26 */
26 class SocketServer { 27 class SocketServer {
27 final AnalysisServerOptions analysisServerOptions; 28 final AnalysisServerOptions analysisServerOptions;
28 final DirectoryBasedDartSdk defaultSdk; 29 final DirectoryBasedDartSdk defaultSdk;
29 final InstrumentationService instrumentationService; 30 final InstrumentationService instrumentationService;
30 final ServerPlugin serverPlugin; 31 final ServerPlugin serverPlugin;
32 final ContextManager contextManager;
31 final ResolverProvider packageResolverProvider; 33 final ResolverProvider packageResolverProvider;
32 34
33 /** 35 /**
34 * The analysis server that was created when a client established a 36 * The analysis server that was created when a client established a
35 * connection, or `null` if no such connection has yet been established. 37 * connection, or `null` if no such connection has yet been established.
36 */ 38 */
37 AnalysisServer analysisServer; 39 AnalysisServer analysisServer;
38 40
39 /** 41 /**
40 * The plugins that are defined outside the analysis_server package. 42 * The plugins that are defined outside the analysis_server package.
41 */ 43 */
42 List<Plugin> userDefinedPlugins; 44 List<Plugin> userDefinedPlugins;
43 45
44 SocketServer(this.analysisServerOptions, this.defaultSdk, 46 SocketServer(this.analysisServerOptions, this.defaultSdk,
45 this.instrumentationService, this.serverPlugin, 47 this.instrumentationService, this.serverPlugin, this.contextManager,
46 this.packageResolverProvider); 48 this.packageResolverProvider);
47 49
48 /** 50 /**
49 * 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
50 * given serverChannel. 52 * given serverChannel.
51 */ 53 */
52 void createAnalysisServer(ServerCommunicationChannel serverChannel) { 54 void createAnalysisServer(ServerCommunicationChannel serverChannel) {
53 if (analysisServer != null) { 55 if (analysisServer != null) {
54 RequestError error = new RequestError( 56 RequestError error = new RequestError(
55 RequestErrorCode.SERVER_ALREADY_STARTED, "Server already started"); 57 RequestErrorCode.SERVER_ALREADY_STARTED, "Server already started");
(...skipping 19 matching lines...) Expand all
75 if (!analysisServerOptions.noIndex) { 77 if (!analysisServerOptions.noIndex) {
76 index = createLocalFileIndex(); 78 index = createLocalFileIndex();
77 index.contributors = serverPlugin.indexContributors; 79 index.contributors = serverPlugin.indexContributors;
78 index.run(); 80 index.run();
79 } 81 }
80 82
81 analysisServer = new AnalysisServer(serverChannel, resourceProvider, 83 analysisServer = new AnalysisServer(serverChannel, resourceProvider,
82 new OptimizingPubPackageMapProvider(resourceProvider, defaultSdk), 84 new OptimizingPubPackageMapProvider(resourceProvider, defaultSdk),
83 index, serverPlugin, analysisServerOptions, defaultSdk, 85 index, serverPlugin, analysisServerOptions, defaultSdk,
84 instrumentationService, 86 instrumentationService,
87 contextManager: contextManager,
85 packageResolverProvider: packageResolverProvider, 88 packageResolverProvider: packageResolverProvider,
86 rethrowExceptions: false); 89 rethrowExceptions: false);
87 analysisServer.userDefinedPlugins = userDefinedPlugins; 90 analysisServer.userDefinedPlugins = userDefinedPlugins;
88 } 91 }
89 } 92 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698