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

Side by Side Diff: pkg/analyzer_experimental/lib/options.dart

Issue 32823008: normalize cmdline analyzer flags for dart based analyzer (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 7 years, 1 month 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/analyzer_experimental/test/options_test.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 options; 5 library options;
6 6
7 import 'package:args/args.dart'; 7 import 'package:args/args.dart';
8 import 'package:path/path.dart'; 8 import 'package:path/path.dart';
9 9
10 import 'dart:io'; 10 import 'dart:io';
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 final String packageRootPath; 51 final String packageRootPath;
52 52
53 /** The source files to analyze */ 53 /** The source files to analyze */
54 final List<String> sourceFiles; 54 final List<String> sourceFiles;
55 55
56 /** 56 /**
57 * Initialize options from the given parsed [args]. 57 * Initialize options from the given parsed [args].
58 */ 58 */
59 CommandLineOptions._fromArgs(ArgResults args) 59 CommandLineOptions._fromArgs(ArgResults args)
60 : shouldBatch = args['batch'], 60 : shouldBatch = args['batch'],
61 machineFormat = args['machine'], 61 machineFormat = args['machine'] || args['format'] == 'machine',
62 displayVersion = args['version'], 62 displayVersion = args['version'],
63 disableHints = args['no-hints'], 63 disableHints = args['no-hints'],
64 ignoreUnrecognizedFlags = args['ignore-unrecognized-flags'], 64 ignoreUnrecognizedFlags = args['ignore-unrecognized-flags'],
65 perf = args['perf'], 65 perf = args['perf'],
66 showPackageWarnings = args['show-package-warnings'], 66 showPackageWarnings = args['show-package-warnings'] || args['package-warni ngs'],
67 showSdkWarnings = args['show-sdk-warnings'], 67 showSdkWarnings = args['show-sdk-warnings'] || args['warnings'],
68 warningsAreFatal = args['fatal-warnings'], 68 warningsAreFatal = args['fatal-warnings'],
69 dartSdkPath = args['dart-sdk'], 69 dartSdkPath = args['dart-sdk'],
70 packageRootPath = args['package-root'], 70 packageRootPath = args['package-root'],
71 sourceFiles = args.rest; 71 sourceFiles = args.rest;
72 72
73 /** 73 /**
74 * Parse [args] into [CommandLineOptions] describing the specified 74 * Parse [args] into [CommandLineOptions] describing the specified
75 * analyzer options. In case of a format error, prints error and exists. 75 * analyzer options. In case of a format error, prints error and exists.
76 */ 76 */
77 static CommandLineOptions parse(List<String> args) { 77 static CommandLineOptions parse(List<String> args) {
(...skipping 15 matching lines...) Expand all
93 // OK 93 // OK
94 return options; 94 return options;
95 } 95 }
96 96
97 static CommandLineOptions _parse(List<String> args) { 97 static CommandLineOptions _parse(List<String> args) {
98 args = args.expand((String arg) => arg.split('=')).toList(); 98 args = args.expand((String arg) => arg.split('=')).toList();
99 var parser = new _CommandLineParser() 99 var parser = new _CommandLineParser()
100 ..addFlag('batch', abbr: 'b', help: 'Run in batch mode', 100 ..addFlag('batch', abbr: 'b', help: 'Run in batch mode',
101 defaultsTo: false, negatable: false) 101 defaultsTo: false, negatable: false)
102 ..addOption('dart-sdk', help: 'The path to the Dart SDK') 102 ..addOption('dart-sdk', help: 'The path to the Dart SDK')
103 ..addOption('package-root', help: 'The path to the package root') 103 ..addOption('package-root', abbr: 'p',
104 help: 'The path to the package root')
105 ..addOption('format',
106 help: 'Specifies the format in which errors are displayed')
104 ..addFlag('machine', 107 ..addFlag('machine',
105 help: 'Print errors in a format suitable for parsing', 108 help: 'Print errors in a format suitable for parsing (deprecated)',
106 defaultsTo: false, negatable: false) 109 defaultsTo: false, negatable: false)
107 ..addFlag('version', help: 'Print the analyzer version', 110 ..addFlag('version', help: 'Print the analyzer version',
108 defaultsTo: false, negatable: false) 111 defaultsTo: false, negatable: false)
109 ..addFlag('no-hints', help: 'Do not show hint results', 112 ..addFlag('no-hints', help: 'Do not show hint results',
110 defaultsTo: false, negatable: false) 113 defaultsTo: false, negatable: false)
111 ..addFlag('ignore-unrecognized-flags', 114 ..addFlag('ignore-unrecognized-flags',
112 help: 'Ignore unrecognized command line flags', 115 help: 'Ignore unrecognized command line flags',
113 defaultsTo: false, negatable: false) 116 defaultsTo: false, negatable: false)
114 ..addFlag('fatal-warnings', help: 'Treat non-type warnings as fatal', 117 ..addFlag('fatal-warnings', help: 'Treat non-type warnings as fatal',
115 defaultsTo: false, negatable: false) 118 defaultsTo: false, negatable: false)
119 ..addFlag('package-warnings',
120 help: 'Show warnings from package: imports',
121 defaultsTo: false, negatable: false)
116 ..addFlag('show-package-warnings', 122 ..addFlag('show-package-warnings',
117 help: 'Show warnings from package: imports', 123 help: 'Show warnings from package: imports (deprecated)',
118 defaultsTo: false, negatable: false) 124 defaultsTo: false, negatable: false)
119 ..addFlag('perf', 125 ..addFlag('perf',
120 help: 'Show performance statistics', 126 help: 'Show performance statistics',
121 defaultsTo: false, negatable: false) 127 defaultsTo: false, negatable: false)
122 ..addFlag('show-sdk-warnings', help: 'Show warnings from SDK imports', 128 ..addFlag('warnings', help: 'Show warnings from SDK imports',
129 defaultsTo: false, negatable: false)
130 ..addFlag('show-sdk-warnings', help: 'Show warnings from SDK imports (depr ecated)',
123 defaultsTo: false, negatable: false) 131 defaultsTo: false, negatable: false)
124 ..addFlag('help', abbr: 'h', help: 'Display this help message', 132 ..addFlag('help', abbr: 'h', help: 'Display this help message',
125 defaultsTo: false, negatable: false); 133 defaultsTo: false, negatable: false);
126 134
127 try { 135 try {
128 // TODO(scheglov) https://code.google.com/p/dart/issues/detail?id=11061 136 // TODO(scheglov) https://code.google.com/p/dart/issues/detail?id=11061
129 args = args.map((String arg) => arg == '-batch' ? '--batch' : arg).toList( ); 137 args = args.map((String arg) => arg == '-batch' ? '--batch' : arg).toList( );
130 var results = parser.parse(args); 138 var results = parser.parse(args);
131 // help requests 139 // help requests
132 if (results['help']) { 140 if (results['help']) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 277
270 _getNextFlagIndex(args, i) { 278 _getNextFlagIndex(args, i) {
271 for ( ; i < args.length; ++i) { 279 for ( ; i < args.length; ++i) {
272 if (args[i].startsWith('--')) { 280 if (args[i].startsWith('--')) {
273 return i; 281 return i;
274 } 282 }
275 } 283 }
276 return i; 284 return i;
277 } 285 }
278 } 286 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer_experimental/test/options_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698