OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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_cli.src.options; | 5 library analyzer_cli.src.options; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
9 import 'package:analyzer_cli/src/driver.dart'; | 9 import 'package:analyzer_cli/src/driver.dart'; |
10 import 'package:args/args.dart'; | 10 import 'package:args/args.dart'; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 /// The path to a file to write a performance log. | 104 /// The path to a file to write a performance log. |
105 /// (Or null if not enabled.) | 105 /// (Or null if not enabled.) |
106 final String perfReport; | 106 final String perfReport; |
107 | 107 |
108 /// Batch mode (for unit testing) | 108 /// Batch mode (for unit testing) |
109 final bool shouldBatch; | 109 final bool shouldBatch; |
110 | 110 |
111 /// Whether to show package: warnings | 111 /// Whether to show package: warnings |
112 final bool showPackageWarnings; | 112 final bool showPackageWarnings; |
113 | 113 |
| 114 /// If not null, show package: warnings only for matching packages. |
| 115 final String showPackageWarningsPrefix; |
| 116 |
114 /// Whether to show SDK warnings | 117 /// Whether to show SDK warnings |
115 final bool showSdkWarnings; | 118 final bool showSdkWarnings; |
116 | 119 |
117 /// The source files to analyze | 120 /// The source files to analyze |
118 final List<String> sourceFiles; | 121 final List<String> sourceFiles; |
119 | 122 |
120 /// Whether to treat warnings as fatal | 123 /// Whether to treat warnings as fatal |
121 final bool warningsAreFatal; | 124 final bool warningsAreFatal; |
122 | 125 |
123 /// Whether to use strong static checking. | 126 /// Whether to use strong static checking. |
(...skipping 20 matching lines...) Expand all Loading... |
144 packageMode = args['package-mode'], | 147 packageMode = args['package-mode'], |
145 packageModePath = args['package-mode-path'], | 148 packageModePath = args['package-mode-path'], |
146 packageName = args['package-name'], | 149 packageName = args['package-name'], |
147 packageSummaryInputs = _parsePackageSummaryInputs(args), | 150 packageSummaryInputs = _parsePackageSummaryInputs(args), |
148 packageSummaryOnly = args['package-summary-only'], | 151 packageSummaryOnly = args['package-summary-only'], |
149 packageSummaryOutput = args['package-summary-output'], | 152 packageSummaryOutput = args['package-summary-output'], |
150 packageConfigPath = args['packages'], | 153 packageConfigPath = args['packages'], |
151 packageRootPath = args['package-root'], | 154 packageRootPath = args['package-root'], |
152 perfReport = args['x-perf-report'], | 155 perfReport = args['x-perf-report'], |
153 shouldBatch = args['batch'], | 156 shouldBatch = args['batch'], |
154 showPackageWarnings = | 157 showPackageWarnings = args['show-package-warnings'] || |
155 args['show-package-warnings'] || args['package-warnings'], | 158 args['package-warnings'] || |
| 159 args['x-package-warnings-prefix'] != null, |
| 160 showPackageWarningsPrefix = args['x-package-warnings-prefix'], |
156 showSdkWarnings = args['show-sdk-warnings'] || args['warnings'], | 161 showSdkWarnings = args['show-sdk-warnings'] || args['warnings'], |
157 sourceFiles = args.rest, | 162 sourceFiles = args.rest, |
158 warningsAreFatal = args['fatal-warnings'], | 163 warningsAreFatal = args['fatal-warnings'], |
159 strongMode = args['strong']; | 164 strongMode = args['strong']; |
160 | 165 |
161 /// Parse [args] into [CommandLineOptions] describing the specified | 166 /// Parse [args] into [CommandLineOptions] describing the specified |
162 /// analyzer options. In case of a format error, calls [printAndFail], which | 167 /// analyzer options. In case of a format error, calls [printAndFail], which |
163 /// by default prints an error message to stderr and exits. | 168 /// by default prints an error message to stderr and exits. |
164 static CommandLineOptions parse(List<String> args, | 169 static CommandLineOptions parse(List<String> args, |
165 [printAndFail = printAndFail]) { | 170 [printAndFail = printAndFail]) { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 defaultsTo: false, | 279 defaultsTo: false, |
275 negatable: false) | 280 negatable: false) |
276 ..addFlag('warnings', | 281 ..addFlag('warnings', |
277 help: 'Show warnings from SDK imports.', | 282 help: 'Show warnings from SDK imports.', |
278 defaultsTo: false, | 283 defaultsTo: false, |
279 negatable: false) | 284 negatable: false) |
280 ..addFlag('show-sdk-warnings', | 285 ..addFlag('show-sdk-warnings', |
281 help: 'Show warnings from SDK imports (deprecated).', | 286 help: 'Show warnings from SDK imports (deprecated).', |
282 defaultsTo: false, | 287 defaultsTo: false, |
283 negatable: false) | 288 negatable: false) |
| 289 ..addOption('x-package-warnings-prefix', |
| 290 help: |
| 291 'Show warnings from package: imports that match the given prefix', |
| 292 hide: true) |
284 ..addOption('x-perf-report', | 293 ..addOption('x-perf-report', |
285 help: 'Writes a performance report to the given file (experimental).') | 294 help: 'Writes a performance report to the given file (experimental).') |
286 ..addFlag('help', | 295 ..addFlag('help', |
287 abbr: 'h', | 296 abbr: 'h', |
288 help: 'Display this help message.', | 297 help: 'Display this help message.', |
289 defaultsTo: false, | 298 defaultsTo: false, |
290 negatable: false) | 299 negatable: false) |
291 ..addOption('url-mapping', | 300 ..addOption('url-mapping', |
292 help: '--url-mapping=libraryUri,/path/to/library.dart directs the ' | 301 help: '--url-mapping=libraryUri,/path/to/library.dart directs the ' |
293 'analyzer to use "library.dart" as the source for an import ' | 302 'analyzer to use "library.dart" as the source for an import ' |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 | 591 |
583 int _getNextFlagIndex(args, i) { | 592 int _getNextFlagIndex(args, i) { |
584 for (; i < args.length; ++i) { | 593 for (; i < args.length; ++i) { |
585 if (args[i].startsWith('--')) { | 594 if (args[i].startsWith('--')) { |
586 return i; | 595 return i; |
587 } | 596 } |
588 } | 597 } |
589 return i; | 598 return i; |
590 } | 599 } |
591 } | 600 } |
OLD | NEW |