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

Side by Side Diff: pkg/analyzer/lib/src/command_line/arguments.dart

Issue 2578113002: refactor DDC to support --ignore-unrecognized-flags (Closed)
Patch Set: merge Created 4 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
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/command_line/command_line_parser.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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 analyzer.src.command_line.arguments; 5 library analyzer.src.command_line.arguments;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/file_system/file_system.dart'; 9 import 'package:analyzer/file_system/file_system.dart';
10 import 'package:analyzer/src/context/builder.dart'; 10 import 'package:analyzer/src/context/builder.dart';
11 import 'package:analyzer/src/dart/sdk/sdk.dart'; 11 import 'package:analyzer/src/dart/sdk/sdk.dart';
12 import 'package:analyzer/src/generated/engine.dart'; 12 import 'package:analyzer/src/generated/engine.dart';
13 import 'package:analyzer/src/generated/sdk.dart'; 13 import 'package:analyzer/src/generated/sdk.dart';
14 import 'package:args/args.dart'; 14 import 'package:args/args.dart';
15 import 'package:path/path.dart'; 15 import 'package:path/path.dart';
16 16
17 const String analysisOptionsFileOption = 'options'; 17 const String analysisOptionsFileOption = 'options';
18 const String defineVariableOption = 'D'; 18 const String defineVariableOption = 'D';
19 const String enableInitializingFormalAccessFlag = 'initializing-formal-access'; 19 const String enableInitializingFormalAccessFlag = 'initializing-formal-access';
20 const String enableStrictCallChecksFlag = 'enable-strict-call-checks'; 20 const String enableStrictCallChecksFlag = 'enable-strict-call-checks';
21 const String enableSuperInMixinFlag = 'supermixin'; 21 const String enableSuperInMixinFlag = 'supermixin';
22 const String ignoreUnrecognizedFlagsFlag = 'ignore_unrecognized_flags'; 22 const String ignoreUnrecognizedFlagsFlag = 'ignore-unrecognized-flags';
23 const String noImplicitCastsFlag = 'no-implicit-casts'; 23 const String noImplicitCastsFlag = 'no-implicit-casts';
24 const String noImplicitDynamicFlag = 'no-implicit-dynamic'; 24 const String noImplicitDynamicFlag = 'no-implicit-dynamic';
25 const String packageRootOption = 'package-root'; 25 const String packageRootOption = 'package-root';
26 const String packagesOption = 'packages'; 26 const String packagesOption = 'packages';
27 const String sdkPathOption = 'dart-sdk'; 27 const String sdkPathOption = 'dart-sdk';
28 const String sdkSummaryPathOption = 'dart-sdk-summary'; 28 const String sdkSummaryPathOption = 'dart-sdk-summary';
29 const String strongModeFlag = 'strong'; 29 const String strongModeFlag = 'strong';
30 30
31 /** 31 /**
32 * Use the given [resourceProvider], [contentCache] and command-line [args] to 32 * Use the given [resourceProvider], [contentCache] and command-line [args] to
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 * Return a list of command-line arguments containing all of the given [args] 200 * Return a list of command-line arguments containing all of the given [args]
201 * that are defined by the given [parser]. An argument is considered to be 201 * that are defined by the given [parser]. An argument is considered to be
202 * defined by the parser if 202 * defined by the parser if
203 * - it starts with '--' and the rest of the argument (minus any value 203 * - it starts with '--' and the rest of the argument (minus any value
204 * introduced by '=') is the name of a known option, 204 * introduced by '=') is the name of a known option,
205 * - it starts with '-' and the rest of the argument (minus any value 205 * - it starts with '-' and the rest of the argument (minus any value
206 * introduced by '=') is the name of a known abbreviation, or 206 * introduced by '=') is the name of a known abbreviation, or
207 * - it starts with something other than '--' or '-'. 207 * - it starts with something other than '--' or '-'.
208 * 208 *
209 * This function allows command-line tools to implement the 209 * This function allows command-line tools to implement the
210 * '--ignore_unrecognized_flags' option. 210 * '--ignore-unrecognized-flags' option.
211 */ 211 */
212 List<String> filterUnknownArguments(List<String> args, ArgParser parser) { 212 List<String> filterUnknownArguments(List<String> args, ArgParser parser) {
213 Set<String> knownOptions = new HashSet<String>(); 213 Set<String> knownOptions = new HashSet<String>();
214 Set<String> knownAbbreviations = new HashSet<String>(); 214 Set<String> knownAbbreviations = new HashSet<String>();
215 parser.options.forEach((String name, Option option) { 215 parser.options.forEach((String name, Option option) {
216 knownOptions.add(name); 216 knownOptions.add(name);
217 String abbreviation = option.abbreviation; 217 String abbreviation = option.abbreviation;
218 if (abbreviation != null) { 218 if (abbreviation != null) {
219 knownAbbreviations.add(abbreviation); 219 knownAbbreviations.add(abbreviation);
220 } 220 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 .replaceAll('\r\n', '\n') 279 .replaceAll('\r\n', '\n')
280 .replaceAll('\r', '\n') 280 .replaceAll('\r', '\n')
281 .split('\n') 281 .split('\n')
282 .where((String line) => line.isNotEmpty)); 282 .where((String line) => line.isNotEmpty));
283 } on FileSystemException catch (e) { 283 } on FileSystemException catch (e) {
284 throw new Exception('Failed to read file specified by $lastArg : $e'); 284 throw new Exception('Failed to read file specified by $lastArg : $e');
285 } 285 }
286 } 286 }
287 return args; 287 return args;
288 } 288 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/command_line/command_line_parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698