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

Side by Side Diff: pkg/analysis_server/lib/src/server/driver.dart

Issue 795833005: Server clean-up (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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 driver; 5 library driver;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:analysis_server/http_server.dart';
11 import 'package:analysis_server/plugin/plugin.dart'; 10 import 'package:analysis_server/plugin/plugin.dart';
12 import 'package:analysis_server/src/analysis_server.dart'; 11 import 'package:analysis_server/src/analysis_server.dart';
13 import 'package:analysis_server/src/plugin/plugin_impl.dart'; 12 import 'package:analysis_server/src/plugin/plugin_impl.dart';
14 import 'package:analysis_server/src/plugin/server_plugin.dart'; 13 import 'package:analysis_server/src/plugin/server_plugin.dart';
14 import 'package:analysis_server/src/server/http_server.dart';
15 import 'package:analysis_server/src/server/stdio_server.dart';
15 import 'package:analysis_server/src/socket_server.dart'; 16 import 'package:analysis_server/src/socket_server.dart';
16 import 'package:analysis_server/stdio_server.dart'; 17 import 'package:analysis_server/starter.dart';
17 import 'package:analyzer/instrumentation/instrumentation.dart'; 18 import 'package:analyzer/instrumentation/instrumentation.dart';
18 import 'package:analyzer/src/generated/engine.dart'; 19 import 'package:analyzer/src/generated/engine.dart';
19 import 'package:analyzer/src/generated/incremental_logger.dart'; 20 import 'package:analyzer/src/generated/incremental_logger.dart';
20 import 'package:analyzer/src/generated/java_io.dart'; 21 import 'package:analyzer/src/generated/java_io.dart';
21 import 'package:analyzer/src/generated/sdk.dart'; 22 import 'package:analyzer/src/generated/sdk.dart';
22 import 'package:analyzer/src/generated/sdk_io.dart'; 23 import 'package:analyzer/src/generated/sdk_io.dart';
23 import 'package:args/args.dart'; 24 import 'package:args/args.dart';
24 25
25 26
26 /** 27 /**
(...skipping 20 matching lines...) Expand all
47 logger = new StringSinkLogger(sink); 48 logger = new StringSinkLogger(sink);
48 } 49 }
49 } 50 }
50 51
51 52
52 /** 53 /**
53 * The [Driver] class represents a single running instance of the analysis 54 * The [Driver] class represents a single running instance of the analysis
54 * server application. It is responsible for parsing command line options 55 * server application. It is responsible for parsing command line options
55 * and starting the HTTP and/or stdio servers. 56 * and starting the HTTP and/or stdio servers.
56 */ 57 */
57 class Driver { 58 class Driver implements ServerStarter {
58 /** 59 /**
59 * The name of the application that is used to start a server. 60 * The name of the application that is used to start a server.
60 */ 61 */
61 static const BINARY_NAME = "server"; 62 static const BINARY_NAME = "server";
62 63
63 /** 64 /**
64 * The name of the option used to set the identifier for the client. 65 * The name of the option used to set the identifier for the client.
65 */ 66 */
66 static const String CLIENT_ID = "client-id"; 67 static const String CLIENT_ID = "client-id";
67 68
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 Driver(); 138 Driver();
138 139
139 /** 140 /**
140 * Set the [plugins] that are defined outside the analysis_server package. 141 * Set the [plugins] that are defined outside the analysis_server package.
141 */ 142 */
142 void set userDefinedPlugins(List<Plugin> plugins) { 143 void set userDefinedPlugins(List<Plugin> plugins) {
143 _userDefinedPlugins = plugins == null ? <Plugin>[] : plugins; 144 _userDefinedPlugins = plugins == null ? <Plugin>[] : plugins;
144 } 145 }
145 146
146 /** 147 /**
147 * Use the given command-line arguments to start this server. 148 * Use the given command-line [arguments] to start this server.
148 */ 149 */
149 void start(List<String> args) { 150 void start(List<String> arguments) {
150 ArgParser parser = new ArgParser(); 151 ArgParser parser = _createArgParser();
151 parser.addOption( 152 ArgResults results = parser.parse(arguments);
152 CLIENT_ID,
153 help: "an identifier used to identify the client");
154 parser.addFlag(
155 ENABLE_INCREMENTAL_RESOLUTION_API,
156 help: "enable using incremental resolution for API changes",
157 defaultsTo: false,
158 negatable: false);
159 parser.addFlag(
160 ENABLE_INSTRUMENTATION_OPTION,
161 help: "enable sending instrumentation information to a server",
162 defaultsTo: false,
163 negatable: false);
164 parser.addFlag(
165 HELP_OPTION,
166 help: "print this help message without starting a server",
167 defaultsTo: false,
168 negatable: false);
169 parser.addOption(
170 INCREMENTAL_RESOLUTION_LOG,
171 help: "the description of the incremental resolution log");
172 parser.addFlag(
173 INCREMENTAL_RESOLUTION_VALIDATION,
174 help: "enable validation of incremental resolution results (slow)",
175 defaultsTo: false,
176 negatable: false);
177 parser.addFlag(
178 INTERNAL_PRINT_TO_CONSOLE,
179 help: "enable sending `print` output to the console",
180 defaultsTo: false,
181 negatable: false);
182 parser.addOption(
183 PORT_OPTION,
184 help: "[port] the port on which the server will listen");
185 parser.addOption(SDK_OPTION, help: "[path] the path to the sdk");
186 parser.addFlag(
187 NO_ERROR_NOTIFICATION,
188 help:
189 "disable sending all analysis error notifications to the server (not yet implemented)",
190 defaultsTo: false,
191 negatable: false);
192
193 ArgResults results = parser.parse(args);
194 if (results[HELP_OPTION]) { 153 if (results[HELP_OPTION]) {
195 _printUsage(parser); 154 _printUsage(parser);
196 return; 155 return;
197 } 156 }
198 157
199 // TODO(brianwilkerson) Enable this after it is possible for an 158 // TODO(brianwilkerson) Enable this after it is possible for an
200 // instrumentation server to be provided. 159 // instrumentation server to be provided.
201 // if (results[ENABLE_INSTRUMENTATION_OPTION]) { 160 // if (results[ENABLE_INSTRUMENTATION_OPTION]) {
202 // if (instrumentationServer == null) { 161 // if (instrumentationServer == null) {
203 // print('Exiting server: enabled instrumentation without providing an in strumentation server'); 162 // print('Exiting server: enabled instrumentation without providing an in strumentation server');
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 // for communication to the client. 262 // for communication to the client.
304 print(line); 263 print(line);
305 }; 264 };
306 ZoneSpecification zoneSpecification = new ZoneSpecification( 265 ZoneSpecification zoneSpecification = new ZoneSpecification(
307 handleUncaughtError: errorFunction, 266 handleUncaughtError: errorFunction,
308 print: printFunction); 267 print: printFunction);
309 return runZoned(callback, zoneSpecification: zoneSpecification); 268 return runZoned(callback, zoneSpecification: zoneSpecification);
310 } 269 }
311 270
312 /** 271 /**
272 * Create and return the parser used to parse the command-line arguments.
273 */
274 ArgParser _createArgParser() {
275 ArgParser parser = new ArgParser();
276 parser.addOption(
277 CLIENT_ID,
278 help: "an identifier used to identify the client");
279 parser.addFlag(
280 ENABLE_INCREMENTAL_RESOLUTION_API,
281 help: "enable using incremental resolution for API changes",
282 defaultsTo: false,
283 negatable: false);
284 parser.addFlag(
285 ENABLE_INSTRUMENTATION_OPTION,
286 help: "enable sending instrumentation information to a server",
287 defaultsTo: false,
288 negatable: false);
289 parser.addFlag(
290 HELP_OPTION,
291 help: "print this help message without starting a server",
292 defaultsTo: false,
293 negatable: false);
294 parser.addOption(
295 INCREMENTAL_RESOLUTION_LOG,
296 help: "the description of the incremental resolution log");
297 parser.addFlag(
298 INCREMENTAL_RESOLUTION_VALIDATION,
299 help: "enable validation of incremental resolution results (slow)",
300 defaultsTo: false,
301 negatable: false);
302 parser.addFlag(
303 INTERNAL_PRINT_TO_CONSOLE,
304 help: "enable sending `print` output to the console",
305 defaultsTo: false,
306 negatable: false);
307 parser.addOption(
308 PORT_OPTION,
309 help: "[port] the port on which the server will listen");
310 parser.addOption(SDK_OPTION, help: "[path] the path to the sdk");
311 parser.addFlag(
312 NO_ERROR_NOTIFICATION,
313 help:
314 "disable sending all analysis error notifications to the server (not yet implemented)",
315 defaultsTo: false,
316 negatable: false);
317
318 return parser;
319 }
320
321 /**
313 * Print information about how to use the server. 322 * Print information about how to use the server.
314 */ 323 */
315 void _printUsage(ArgParser parser) { 324 void _printUsage(ArgParser parser) {
316 print('Usage: $BINARY_NAME [flags]'); 325 print('Usage: $BINARY_NAME [flags]');
317 print(''); 326 print('');
318 print('Supported flags are:'); 327 print('Supported flags are:');
319 print(parser.usage); 328 print(parser.usage);
320 } 329 }
321 } 330 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/http_server.dart ('k') | pkg/analysis_server/lib/src/server/http_server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698