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

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

Issue 756193002: Add --enable-incremental-resolution option. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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'; 10 import 'package:analysis_server/http_server.dart';
11 import 'package:analysis_server/src/analysis_server.dart';
11 import 'package:analysis_server/src/socket_server.dart'; 12 import 'package:analysis_server/src/socket_server.dart';
12 import 'package:analysis_server/stdio_server.dart'; 13 import 'package:analysis_server/stdio_server.dart';
13 import 'package:analyzer/src/generated/java_io.dart'; 14 import 'package:analyzer/src/generated/java_io.dart';
14 import 'package:analyzer/src/generated/sdk.dart'; 15 import 'package:analyzer/src/generated/sdk.dart';
15 import 'package:analyzer/src/generated/sdk_io.dart'; 16 import 'package:analyzer/src/generated/sdk_io.dart';
16 import 'package:args/args.dart'; 17 import 'package:args/args.dart';
17 18
18 /** 19 /**
19 * The [Driver] class represents a single running instance of the analysis 20 * The [Driver] class represents a single running instance of the analysis
20 * server application. It is responsible for parsing command line options 21 * server application. It is responsible for parsing command line options
21 * and starting the HTTP and/or stdio servers. 22 * and starting the HTTP and/or stdio servers.
22 */ 23 */
23 class Driver { 24 class Driver {
24 /** 25 /**
25 * The name of the application that is used to start a server. 26 * The name of the application that is used to start a server.
26 */ 27 */
27 static const BINARY_NAME = "server"; 28 static const BINARY_NAME = "server";
28 29
29 /** 30 /**
31 * The name of the option used to enable incremental resolution.
32 */
33 static const String ENABLE_INCREMENTAL_RESOLUTION =
34 "enable-incremental-resolution";
35
36 /**
30 * The name of the option used to enable instrumentation. 37 * The name of the option used to enable instrumentation.
31 */ 38 */
32 static const String ENABLE_INSTRUMENTATION_OPTION = "enable-instrumentation"; 39 static const String ENABLE_INSTRUMENTATION_OPTION = "enable-instrumentation";
33 40
34 /** 41 /**
35 * The name of the option used to print usage information. 42 * The name of the option used to print usage information.
36 */ 43 */
37 static const String HELP_OPTION = "help"; 44 static const String HELP_OPTION = "help";
38 45
39 /** 46 /**
(...skipping 27 matching lines...) Expand all
67 74
68 StdioAnalysisServer stdioServer; 75 StdioAnalysisServer stdioServer;
69 76
70 Driver(); 77 Driver();
71 /** 78 /**
72 * Use the given command-line arguments to start this server. 79 * Use the given command-line arguments to start this server.
73 */ 80 */
74 void start(List<String> args) { 81 void start(List<String> args) {
75 ArgParser parser = new ArgParser(); 82 ArgParser parser = new ArgParser();
76 parser.addFlag( 83 parser.addFlag(
84 ENABLE_INCREMENTAL_RESOLUTION,
85 help: "enable using incremental resolution",
86 defaultsTo: false,
87 negatable: false);
88 parser.addFlag(
77 ENABLE_INSTRUMENTATION_OPTION, 89 ENABLE_INSTRUMENTATION_OPTION,
78 help: "enable sending instrumentation information to a server", 90 help: "enable sending instrumentation information to a server",
79 defaultsTo: false, 91 defaultsTo: false,
80 negatable: false); 92 negatable: false);
81 parser.addFlag( 93 parser.addFlag(
82 HELP_OPTION, 94 HELP_OPTION,
83 help: "print this help message without starting a server", 95 help: "print this help message without starting a server",
84 defaultsTo: false, 96 defaultsTo: false,
85 negatable: false); 97 negatable: false);
86 parser.addOption( 98 parser.addOption(
(...skipping 17 matching lines...) Expand all
104 } 116 }
105 if (results[ENABLE_INSTRUMENTATION_OPTION]) { 117 if (results[ENABLE_INSTRUMENTATION_OPTION]) {
106 if (results[INSTRUMENTATION_LOG_FILE_OPTION] != null) { 118 if (results[INSTRUMENTATION_LOG_FILE_OPTION] != null) {
107 // TODO(brianwilkerson) Initialize the instrumentation system with 119 // TODO(brianwilkerson) Initialize the instrumentation system with
108 // logging. 120 // logging.
109 } else { 121 } else {
110 // TODO(brianwilkerson) Initialize the instrumentation system without 122 // TODO(brianwilkerson) Initialize the instrumentation system without
111 // logging. 123 // logging.
112 } 124 }
113 } 125 }
126
114 int port; 127 int port;
115 bool serve_http = false; 128 bool serve_http = false;
116 if (results[PORT_OPTION] != null) { 129 if (results[PORT_OPTION] != null) {
117 serve_http = true; 130 serve_http = true;
118 try { 131 try {
119 port = int.parse(results[PORT_OPTION]); 132 port = int.parse(results[PORT_OPTION]);
120 } on FormatException { 133 } on FormatException {
121 print('Invalid port number: ${results[PORT_OPTION]}'); 134 print('Invalid port number: ${results[PORT_OPTION]}');
122 print(''); 135 print('');
123 _printUsage(parser); 136 _printUsage(parser);
124 exitCode = 1; 137 exitCode = 1;
125 return; 138 return;
126 } 139 }
127 } 140 }
141
142 AnalysisServerOptions analysisServerOptions = new AnalysisServerOptions();
143 analysisServerOptions.enableIncrementalResolution =
144 results[ENABLE_INCREMENTAL_RESOLUTION];
145
128 DartSdk defaultSdk; 146 DartSdk defaultSdk;
129 if (results[SDK_OPTION] != null) { 147 if (results[SDK_OPTION] != null) {
130 defaultSdk = new DirectoryBasedDartSdk(new JavaFile(results[SDK_OPTION])); 148 defaultSdk = new DirectoryBasedDartSdk(new JavaFile(results[SDK_OPTION]));
131 } else { 149 } else {
132 // No path to the SDK provided; use DirectoryBasedDartSdk.defaultSdk, 150 // No path to the SDK provided; use DirectoryBasedDartSdk.defaultSdk,
133 // which will make a guess. 151 // which will make a guess.
134 defaultSdk = DirectoryBasedDartSdk.defaultSdk; 152 defaultSdk = DirectoryBasedDartSdk.defaultSdk;
135 } 153 }
136 154
137 socketServer = new SocketServer(defaultSdk); 155 socketServer = new SocketServer(analysisServerOptions, defaultSdk);
138 httpServer = new HttpAnalysisServer(socketServer); 156 httpServer = new HttpAnalysisServer(socketServer);
139 stdioServer = new StdioAnalysisServer(socketServer); 157 stdioServer = new StdioAnalysisServer(socketServer);
140 158
141 if (serve_http) { 159 if (serve_http) {
142 httpServer.serveHttp(port); 160 httpServer.serveHttp(port);
143 } 161 }
144 _capturePrints(() { 162 _capturePrints(() {
145 stdioServer.serveStdio().then((_) { 163 stdioServer.serveStdio().then((_) {
146 if (serve_http) { 164 if (serve_http) {
147 httpServer.close(); 165 httpServer.close();
(...skipping 20 matching lines...) Expand all
168 /** 186 /**
169 * Print information about how to use the server. 187 * Print information about how to use the server.
170 */ 188 */
171 void _printUsage(ArgParser parser) { 189 void _printUsage(ArgParser parser) {
172 print('Usage: $BINARY_NAME [flags]'); 190 print('Usage: $BINARY_NAME [flags]');
173 print(''); 191 print('');
174 print('Supported flags are:'); 192 print('Supported flags are:');
175 print(parser.usage); 193 print(parser.usage);
176 } 194 }
177 } 195 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698