@@ -145,12 +145,10 @@ class Driver implements ServerStarter {
145145
146146 HttpAnalysisServer ? httpServer;
147147
148- Driver ();
149-
150148 /// Use the given command-line [arguments] to start this server.
151149 ///
152150 /// If [sendPort] is not null, assumes this is launched in an isolate and will
153- /// connect to the original isolate via an [IsolateChannel] .
151+ /// connect to the original isolate via an isolate channel .
154152 @override
155153 void start (
156154 List <String > arguments, {
@@ -163,40 +161,39 @@ class Driver implements ServerStarter {
163161
164162 var analysisServerOptions = AnalysisServerOptions ();
165163 analysisServerOptions.newAnalysisDriverLog =
166- ( results[ ANALYSIS_DRIVER_LOG ] ?? results[ ANALYSIS_DRIVER_LOG_ALIAS ])
167- as String ? ;
164+ results. option ( ANALYSIS_DRIVER_LOG ) ??
165+ results. option ( ANALYSIS_DRIVER_LOG_ALIAS ) ;
168166 if (results.wasParsed (USE_LSP )) {
169- analysisServerOptions.useLanguageServerProtocol =
170- results[USE_LSP ] as bool ;
167+ analysisServerOptions.useLanguageServerProtocol = results.flag (USE_LSP );
171168 } else {
172169 analysisServerOptions.useLanguageServerProtocol =
173- results[ SERVER_PROTOCOL ] == PROTOCOL_LSP ;
170+ results. option ( SERVER_PROTOCOL ) == PROTOCOL_LSP ;
174171 }
175172 // For clients that don't supply their own identifier, use a default based
176173 // on whether the server will run in LSP mode or not.
177174 var clientId =
178- ( results[ CLIENT_ID ] as String ? ) ??
175+ results. option ( CLIENT_ID ) ??
179176 (analysisServerOptions.useLanguageServerProtocol
180177 ? 'unknown.client.lsp'
181178 : 'unknown.client.classic' );
182179 analysisServerOptions.clientId = clientId;
183- analysisServerOptions.clientVersion = results[CLIENT_VERSION ] as String ? ;
184- analysisServerOptions.cacheFolder = results[CACHE_FOLDER ] as String ? ;
185- analysisServerOptions.packagesFile = results[PACKAGES_FILE ] as String ? ;
186- analysisServerOptions.reportProtocolVersion =
187- results[REPORT_PROTOCOL_VERSION ] as String ? ;
180+ analysisServerOptions.clientVersion = results.option (CLIENT_VERSION );
181+ analysisServerOptions.cacheFolder = results.option (CACHE_FOLDER );
182+ analysisServerOptions.packagesFile = results.option (PACKAGES_FILE );
183+ analysisServerOptions.reportProtocolVersion = results.option (
184+ REPORT_PROTOCOL_VERSION ,
185+ );
188186
189- analysisServerOptions.enabledExperiments =
190- results.wasParsed (ENABLE_EXPERIMENT )
191- ? results[ENABLE_EXPERIMENT ] as List <String >
192- : < String > [];
187+ analysisServerOptions.enabledExperiments = results.multiOption (
188+ ENABLE_EXPERIMENT ,
189+ );
193190
194191 // Read in any per-SDK overrides specified in <sdk>/config/settings.json.
195192 var sdkConfig = SdkConfiguration .readFromSdk ();
196193 analysisServerOptions.configurationOverrides = sdkConfig;
197194
198195 // Analytics (legacy, and unified)
199- var disableAnalyticsForSession = results[ SUPPRESS_ANALYTICS_FLAG ] as bool ;
196+ var disableAnalyticsForSession = results. flag ( SUPPRESS_ANALYTICS_FLAG ) ;
200197
201198 if (results.wasParsed (TRAIN_USING )) {
202199 disableAnalyticsForSession = true ;
@@ -247,9 +244,8 @@ class Driver implements ServerStarter {
247244 );
248245
249246 {
250- var disableCompletion =
251- results[DISABLE_SERVER_FEATURE_COMPLETION ] as bool ;
252- var disableSearch = results[DISABLE_SERVER_FEATURE_SEARCH ] as bool ;
247+ var disableCompletion = results.flag (DISABLE_SERVER_FEATURE_COMPLETION );
248+ var disableSearch = results.flag (DISABLE_SERVER_FEATURE_SEARCH );
253249 if (disableCompletion || disableSearch) {
254250 analysisServerOptions.featureSet = FeatureSet (
255251 completion: ! disableCompletion,
@@ -258,7 +254,7 @@ class Driver implements ServerStarter {
258254 }
259255 }
260256
261- if (results[ HELP_OPTION ] as bool ) {
257+ if (results. flag ( HELP_OPTION ) ) {
262258 _printUsage (parser, fromHelp: true );
263259 return ;
264260 }
@@ -274,8 +270,8 @@ class Driver implements ServerStarter {
274270 // Initialize the instrumentation service.
275271 //
276272 var logFilePath =
277- ( results[ PROTOCOL_TRAFFIC_LOG ] ?? results[ PROTOCOL_TRAFFIC_LOG_ALIAS ])
278- as String ? ;
273+ results. option ( PROTOCOL_TRAFFIC_LOG ) ??
274+ results. option ( PROTOCOL_TRAFFIC_LOG_ALIAS ) ;
279275 var allInstrumentationServices =
280276 this .instrumentationService == null
281277 ? < InstrumentationService > []
@@ -301,7 +297,7 @@ class Driver implements ServerStarter {
301297 this .instrumentationService = instrumentationService;
302298
303299 instrumentationService.logVersion (
304- results[ TRAIN_USING ] != null
300+ results. option ( TRAIN_USING ) != null
305301 ? 'training-0'
306302 : _readUuid (instrumentationService),
307303 analysisServerOptions.clientId ?? '' ,
@@ -313,7 +309,8 @@ class Driver implements ServerStarter {
313309
314310 int ? diagnosticServerPort;
315311 var portValue =
316- (results[DIAGNOSTIC_PORT ] ?? results[DIAGNOSTIC_PORT_ALIAS ]) as String ? ;
312+ results.option (DIAGNOSTIC_PORT ) ??
313+ results.option (DIAGNOSTIC_PORT_ALIAS );
317314 if (portValue != null ) {
318315 try {
319316 diagnosticServerPort = int .parse (portValue);
@@ -380,10 +377,10 @@ class Driver implements ServerStarter {
380377 SendPort ? sendPort,
381378 ) {
382379 var capture =
383- results[ DISABLE_SERVER_EXCEPTION_HANDLING ] as bool
384- ? (_, Function f, {Function (String )? print}) => f ()
380+ results. flag ( DISABLE_SERVER_EXCEPTION_HANDLING )
381+ ? (_, Function f, {void Function (String )? print}) => f ()
385382 : _captureExceptions;
386- var trainDirectory = results[ TRAIN_USING ] as String ? ;
383+ var trainDirectory = results. option ( TRAIN_USING ) ;
387384 if (trainDirectory != null ) {
388385 if (! FileSystemEntity .isDirectorySync (trainDirectory)) {
389386 print ("Training directory '$trainDirectory ' not found.\n " );
@@ -472,7 +469,7 @@ class Driver implements ServerStarter {
472469 serveResult = isolateAnalysisServer.serveIsolate (sendPort);
473470 }
474471 errorNotifier.server = socketServer.analysisServer;
475- if (results[ DISABLE_SILENT_ANALYSIS_EXCEPTIONS ] as bool ) {
472+ if (results. flag ( DISABLE_SILENT_ANALYSIS_EXCEPTIONS ) ) {
476473 errorNotifier.sendSilentExceptionsToClient = true ;
477474 }
478475 serveResult.then ((_) async {
@@ -486,7 +483,7 @@ class Driver implements ServerStarter {
486483 });
487484 },
488485 print:
489- results[ INTERNAL_PRINT_TO_CONSOLE ] as bool
486+ results. flag ( INTERNAL_PRINT_TO_CONSOLE )
490487 ? null
491488 : httpServer! .recordPrint,
492489 );
@@ -503,8 +500,8 @@ class Driver implements ServerStarter {
503500 ErrorNotifier errorNotifier,
504501 ) {
505502 var capture =
506- args[ DISABLE_SERVER_EXCEPTION_HANDLING ] as bool
507- ? (_, Function f, {Function (String )? print}) => f ()
503+ args. flag ( DISABLE_SERVER_EXCEPTION_HANDLING )
504+ ? (_, Function f, {void Function (String )? print}) => f ()
508505 : _captureExceptions;
509506
510507 linter.registerLintRules ();
0 commit comments