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

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

Issue 236133013: Allow the analysis server to connect to the client over stdio. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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:io'; 7 import 'dart:io';
8 8
9 import 'package:analysis_server/http_server.dart'; 9 import 'package:analysis_server/http_server.dart';
10 import 'package:analysis_server/src/socket_server.dart'; 10 import 'package:analysis_server/src/socket_server.dart';
11 import 'package:analysis_server/stdio_server.dart';
11 import 'package:args/args.dart'; 12 import 'package:args/args.dart';
12 13
13 /** 14 /**
14 * The [Driver] class represents a single running instance of the analysis 15 * The [Driver] class represents a single running instance of the analysis
15 * server application. It is responsible for parsing command line options 16 * server application. It is responsible for parsing command line options
16 * and starting the HTTP and/or stdio servers. 17 * and starting the HTTP and/or stdio servers.
17 */ 18 */
18 class Driver { 19 class Driver {
19 /** 20 /**
20 * The name of the application that is used to start a server. 21 * The name of the application that is used to start a server.
21 */ 22 */
22 static const BINARY_NAME = 'server'; 23 static const BINARY_NAME = 'server';
23 24
24 /** 25 /**
25 * The name of the option used to print usage information. 26 * The name of the option used to print usage information.
26 */ 27 */
27 static const String HELP_OPTION = "help"; 28 static const String HELP_OPTION = "help";
28 29
29 /** 30 /**
30 * The name of the option used to specify the port to which the server will 31 * The name of the option used to specify the port to which the server will
31 * connect. 32 * connect.
32 */ 33 */
33 static const String PORT_OPTION = "port"; 34 static const String PORT_OPTION = "port";
34 35
35 SocketServer socketServer = new SocketServer(); 36 SocketServer socketServer = new SocketServer();
36 37
37 HttpAnalysisServer httpServer; 38 HttpAnalysisServer httpServer;
38 39
40 StdioAnalysisServer stdioServer;
41
39 Driver() { 42 Driver() {
40 httpServer = new HttpAnalysisServer(socketServer); 43 httpServer = new HttpAnalysisServer(socketServer);
44 stdioServer = new StdioAnalysisServer(socketServer);
41 } 45 }
42 46
43 /** 47 /**
44 * Use the given command-line arguments to start this server. 48 * Use the given command-line arguments to start this server.
45 */ 49 */
46 void start(List<String> args) { 50 void start(List<String> args) {
47 ArgParser parser = new ArgParser(); 51 ArgParser parser = new ArgParser();
48 parser.addFlag(HELP_OPTION, help: 52 parser.addFlag(HELP_OPTION, help:
49 "print this help message without starting a server", defaultsTo: false, 53 "print this help message without starting a server", defaultsTo: false,
50 negatable: false); 54 negatable: false);
(...skipping 16 matching lines...) Expand all
67 try { 71 try {
68 int port = int.parse(results[PORT_OPTION]); 72 int port = int.parse(results[PORT_OPTION]);
69 httpServer.serveHttp(port); 73 httpServer.serveHttp(port);
70 } on FormatException { 74 } on FormatException {
71 print('Invalid port number: ${results[PORT_OPTION]}'); 75 print('Invalid port number: ${results[PORT_OPTION]}');
72 print(''); 76 print('');
73 _printUsage(parser); 77 _printUsage(parser);
74 exitCode = 1; 78 exitCode = 1;
75 return; 79 return;
76 } 80 }
81 stdioServer.serveStdio();
77 } 82 }
78 83
79 /** 84 /**
80 * Print information about how to use the server. 85 * Print information about how to use the server.
81 */ 86 */
82 void _printUsage(ArgParser parser) { 87 void _printUsage(ArgParser parser) {
83 print('Usage: $BINARY_NAME [flags]'); 88 print('Usage: $BINARY_NAME [flags]');
84 print(''); 89 print('');
85 print('Supported flags are:'); 90 print('Supported flags are:');
86 print(parser.getUsage()); 91 print(parser.getUsage());
87 } 92 }
88 } 93 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/stdio_server.dart » ('j') | pkg/analysis_server/lib/stdio_server.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698