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

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

Issue 923103004: Return RequestErrorCode.NO_INDEX_GENERATED for search/refactoring requests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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/plugin/server_plugin.dart'; 9 import 'package:analysis_server/src/plugin/server_plugin.dart';
10 import 'package:analysis_server/src/protocol.dart'; 10 import 'package:analysis_server/src/protocol.dart';
11 import 'package:analysis_server/src/services/index/index.dart'; 11 import 'package:analysis_server/src/services/index/index.dart';
12 import 'package:analysis_server/src/services/index/local_file_index.dart'; 12 import 'package:analysis_server/src/services/index/local_file_index.dart';
13 import 'package:analyzer/file_system/physical_file_system.dart'; 13 import 'package:analyzer/file_system/physical_file_system.dart';
14 import 'package:analyzer/instrumentation/instrumentation.dart'; 14 import 'package:analyzer/instrumentation/instrumentation.dart';
15 import 'package:analyzer/source/pub_package_map_provider.dart'; 15 import 'package:analyzer/source/pub_package_map_provider.dart';
16 import 'package:analyzer/src/generated/sdk_io.dart'; 16 import 'package:analyzer/src/generated/sdk_io.dart';
17 17
18 18
19 /** 19 /**
20 * Creates and runs an [Index].
21 */
22 Index _createIndex() {
23 Index index = createLocalFileIndex();
24 index.run();
25 return index;
26 }
27
28
29 /**
30 * Instances of the class [SocketServer] implement the common parts of 20 * Instances of the class [SocketServer] implement the common parts of
31 * http-based and stdio-based analysis servers. The primary responsibility of 21 * http-based and stdio-based analysis servers. The primary responsibility of
32 * the SocketServer is to manage the lifetime of the AnalysisServer and to 22 * the SocketServer is to manage the lifetime of the AnalysisServer and to
33 * encode and decode the JSON messages exchanged with the client. 23 * encode and decode the JSON messages exchanged with the client.
34 */ 24 */
35 class SocketServer { 25 class SocketServer {
36 final AnalysisServerOptions analysisServerOptions; 26 final AnalysisServerOptions analysisServerOptions;
37 final DirectoryBasedDartSdk defaultSdk; 27 final DirectoryBasedDartSdk defaultSdk;
38 final InstrumentationService instrumentationService; 28 final InstrumentationService instrumentationService;
39 final ServerPlugin serverPlugin; 29 final ServerPlugin serverPlugin;
(...skipping 15 matching lines...) Expand all
55 if (analysisServer != null) { 45 if (analysisServer != null) {
56 RequestError error = new RequestError( 46 RequestError error = new RequestError(
57 RequestErrorCode.SERVER_ALREADY_STARTED, 47 RequestErrorCode.SERVER_ALREADY_STARTED,
58 "Server already started"); 48 "Server already started");
59 serverChannel.sendResponse(new Response('', error: error)); 49 serverChannel.sendResponse(new Response('', error: error));
60 serverChannel.listen((Request request) { 50 serverChannel.listen((Request request) {
61 serverChannel.sendResponse(new Response(request.id, error: error)); 51 serverChannel.sendResponse(new Response(request.id, error: error));
62 }); 52 });
63 return; 53 return;
64 } 54 }
55
65 PhysicalResourceProvider resourceProvider; 56 PhysicalResourceProvider resourceProvider;
66 if (analysisServerOptions.fileReadMode == 'as-is') { 57 if (analysisServerOptions.fileReadMode == 'as-is') {
67 resourceProvider = PhysicalResourceProvider.INSTANCE; 58 resourceProvider = PhysicalResourceProvider.INSTANCE;
68 } else if (analysisServerOptions.fileReadMode == 'normalize-eol-always') { 59 } else if (analysisServerOptions.fileReadMode == 'normalize-eol-always') {
69 resourceProvider = 60 resourceProvider =
70 new PhysicalResourceProvider(PhysicalResourceProvider.NORMALIZE_EOL_AL WAYS); 61 new PhysicalResourceProvider(PhysicalResourceProvider.NORMALIZE_EOL_AL WAYS);
71 } else { 62 } else {
72 throw new Exception( 63 throw new Exception(
73 'File read mode was set to the unknown mode: $analysisServerOptions.fi leReadMode'); 64 'File read mode was set to the unknown mode: $analysisServerOptions.fi leReadMode');
74 } 65 }
75 66
67 Index index = null;
68 if (!analysisServerOptions.noIndex) {
69 index = createLocalFileIndex();
70 index.run();
71 }
72
76 analysisServer = new AnalysisServer( 73 analysisServer = new AnalysisServer(
77 serverChannel, 74 serverChannel,
78 resourceProvider, 75 resourceProvider,
79 new PubPackageMapProvider(resourceProvider, defaultSdk), 76 new PubPackageMapProvider(resourceProvider, defaultSdk),
80 _createIndex(), 77 index,
81 analysisServerOptions, 78 analysisServerOptions,
82 defaultSdk, 79 defaultSdk,
83 instrumentationService, 80 instrumentationService,
84 rethrowExceptions: false); 81 rethrowExceptions: false);
85 _initializeHandlers(analysisServer); 82 _initializeHandlers(analysisServer);
86 } 83 }
87 84
88 /** 85 /**
89 * Initialize the handlers to be used by the given [server]. 86 * Initialize the handlers to be used by the given [server].
90 */ 87 */
91 void _initializeHandlers(AnalysisServer server) { 88 void _initializeHandlers(AnalysisServer server) {
92 server.handlers = serverPlugin.createDomains(server); 89 server.handlers = serverPlugin.createDomains(server);
93 } 90 }
94 } 91 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698