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

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

Issue 394923004: As a temporary measure, allow SDK to be specified on analysis server cmd line. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/analysis_server.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:analysis_server/stdio_server.dart';
12 import 'package:analyzer/src/generated/java_io.dart';
13 import 'package:analyzer/src/generated/sdk.dart';
14 import 'package:analyzer/src/generated/sdk_io.dart';
12 import 'package:args/args.dart'; 15 import 'package:args/args.dart';
13 import 'package:logging/logging.dart'; 16 import 'package:logging/logging.dart';
14 17
15 /** 18 /**
16 * The [Driver] class represents a single running instance of the analysis 19 * The [Driver] class represents a single running instance of the analysis
17 * server application. It is responsible for parsing command line options 20 * server application. It is responsible for parsing command line options
18 * and starting the HTTP and/or stdio servers. 21 * and starting the HTTP and/or stdio servers.
19 */ 22 */
20 class Driver { 23 class Driver {
21 /** 24 /**
(...skipping 10 matching lines...) Expand all
32 * The name of the option used to specify the port to which the server will 35 * The name of the option used to specify the port to which the server will
33 * connect. 36 * connect.
34 */ 37 */
35 static const String PORT_OPTION = "port"; 38 static const String PORT_OPTION = "port";
36 39
37 /** 40 /**
38 * The name of the option used to specify the log file. 41 * The name of the option used to specify the log file.
39 */ 42 */
40 static const String LOG_FILE_OPTION = "log"; 43 static const String LOG_FILE_OPTION = "log";
41 44
42 SocketServer socketServer = new SocketServer(); 45 /**
46 * The path to the SDK.
47 * TODO(paulberry): get rid of this once the 'analysis.updateSdks' request is
48 * operational.
49 */
50 static const String SDK_OPTION = 'sdk';
51
52 SocketServer socketServer;
43 53
44 HttpAnalysisServer httpServer; 54 HttpAnalysisServer httpServer;
45 55
46 StdioAnalysisServer stdioServer; 56 StdioAnalysisServer stdioServer;
47 57
48 Driver() { 58 Driver() {
49 httpServer = new HttpAnalysisServer(socketServer);
50 stdioServer = new StdioAnalysisServer(socketServer);
51 } 59 }
52 60
53 /** 61 /**
54 * Use the given command-line arguments to start this server. 62 * Use the given command-line arguments to start this server.
55 */ 63 */
56 void start(List<String> args) { 64 void start(List<String> args) {
57 ArgParser parser = new ArgParser(); 65 ArgParser parser = new ArgParser();
58 parser.addFlag(HELP_OPTION, help: 66 parser.addFlag(HELP_OPTION, help:
59 "print this help message without starting a server", defaultsTo: false, 67 "print this help message without starting a server", defaultsTo: false,
60 negatable: false); 68 negatable: false);
61 parser.addOption(PORT_OPTION, help: 69 parser.addOption(PORT_OPTION, help:
62 "[port] the port on which the server will listen"); 70 "[port] the port on which the server will listen");
63 parser.addOption(LOG_FILE_OPTION, help: 71 parser.addOption(LOG_FILE_OPTION, help:
64 "[path] file to log debugging messages to"); 72 "[path] file to log debugging messages to");
73 parser.addOption(SDK_OPTION, help:
74 "[path] path to the sdk");
65 75
66 ArgResults results = parser.parse(args); 76 ArgResults results = parser.parse(args);
67 if (results[HELP_OPTION]) { 77 if (results[HELP_OPTION]) {
68 _printUsage(parser); 78 _printUsage(parser);
69 return; 79 return;
70 } 80 }
71 if (results[LOG_FILE_OPTION] != null) { 81 if (results[LOG_FILE_OPTION] != null) {
72 try { 82 try {
73 File file = new File(results[LOG_FILE_OPTION]); 83 File file = new File(results[LOG_FILE_OPTION]);
74 IOSink sink = file.openWrite(); 84 IOSink sink = file.openWrite();
(...skipping 13 matching lines...) Expand all
88 try { 98 try {
89 port = int.parse(results[PORT_OPTION]); 99 port = int.parse(results[PORT_OPTION]);
90 } on FormatException { 100 } on FormatException {
91 print('Invalid port number: ${results[PORT_OPTION]}'); 101 print('Invalid port number: ${results[PORT_OPTION]}');
92 print(''); 102 print('');
93 _printUsage(parser); 103 _printUsage(parser);
94 exitCode = 1; 104 exitCode = 1;
95 return; 105 return;
96 } 106 }
97 } 107 }
108 DartSdk defaultSdk;
109 if (results[SDK_OPTION] != null) {
110 defaultSdk = new DirectoryBasedDartSdk(new JavaFile(results[SDK_OPTION]));
111 } else {
112 // No path to the SDK provided; use DirectoryBasedDartSdk.defaultSdk,
113 // which will make a guess.
114 defaultSdk = DirectoryBasedDartSdk.defaultSdk;
115 }
116
117 socketServer = new SocketServer(defaultSdk);
118 httpServer = new HttpAnalysisServer(socketServer);
119 stdioServer = new StdioAnalysisServer(socketServer);
98 120
99 if (serve_http) { 121 if (serve_http) {
100 httpServer.serveHttp(port); 122 httpServer.serveHttp(port);
101 } 123 }
102 stdioServer.serveStdio().then((_) { 124 stdioServer.serveStdio().then((_) {
103 if (serve_http) { 125 if (serve_http) {
104 httpServer.close(); 126 httpServer.close();
105 } 127 }
106 exit(0); 128 exit(0);
107 }); 129 });
108 } 130 }
109 131
110 /** 132 /**
111 * Print information about how to use the server. 133 * Print information about how to use the server.
112 */ 134 */
113 void _printUsage(ArgParser parser) { 135 void _printUsage(ArgParser parser) {
114 print('Usage: $BINARY_NAME [flags]'); 136 print('Usage: $BINARY_NAME [flags]');
115 print(''); 137 print('');
116 print('Supported flags are:'); 138 print('Supported flags are:');
117 print(parser.getUsage()); 139 print(parser.getUsage());
118 } 140 }
119 } 141 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/analysis_server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698