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

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

Issue 15780010: Issue 10871. Fix for analyzing file without absolute path (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 months 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) 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 8
9 import 'dart:io'; 9 import 'dart:io';
10 10
(...skipping 19 matching lines...) Expand all
30 30
31 /** Whether to show SDK warnings */ 31 /** Whether to show SDK warnings */
32 final bool showSdkWarnings; 32 final bool showSdkWarnings;
33 33
34 /** Whether to treat warnings as fatal */ 34 /** Whether to treat warnings as fatal */
35 final bool warningsAreFatal; 35 final bool warningsAreFatal;
36 36
37 /** The path to the dart SDK */ 37 /** The path to the dart SDK */
38 final String dartSdkPath; 38 final String dartSdkPath;
39 39
40 /** The path to the package root */
41 final String packageRootPath;
42
40 /** The source files to analyze */ 43 /** The source files to analyze */
41 final List<String> sourceFiles; 44 final List<String> sourceFiles;
42 45
43 /** 46 /**
44 * Initialize options from the given parsed [args]. 47 * Initialize options from the given parsed [args].
45 */ 48 */
46 CommandLineOptions._fromArgs(ArgResults args) 49 CommandLineOptions._fromArgs(ArgResults args)
47 : shouldBatch = args['batch'], 50 : shouldBatch = args['batch'],
48 machineFormat = args['machine_format'], 51 machineFormat = args['machine-format'],
49 ignoreUnrecognizedFlags = args['ignore_unrecognized_flags'], 52 ignoreUnrecognizedFlags = args['ignore-unrecognized-flags'],
50 showPackageWarnings = args['show_package_warnings'], 53 showPackageWarnings = args['show-package-warnings'],
51 showSdkWarnings = args['show_sdk_warnings'], 54 showSdkWarnings = args['show-sdk-warnings'],
52 warningsAreFatal = args['fatal_warnings'], 55 warningsAreFatal = args['fatal-warnings'],
53 dartSdkPath = args['dart_sdk'], 56 dartSdkPath = args['dart-sdk'],
57 packageRootPath = args['package-root'],
54 sourceFiles = args.rest; 58 sourceFiles = args.rest;
55 59
56 /** 60 /**
57 * Parse [args] into [CommandLineOptions] describing the specified 61 * Parse [args] into [CommandLineOptions] describing the specified
58 * analyzer options. In case of a format error, prints error and exists. 62 * analyzer options. In case of a format error, prints error and exists.
59 */ 63 */
60 static CommandLineOptions parse(List<String> args) { 64 static CommandLineOptions parse(List<String> args) {
61 CommandLineOptions options = _parse(args); 65 CommandLineOptions options = _parse(args);
62 // check SDK 66 // check SDK
63 { 67 {
(...skipping 10 matching lines...) Expand all
74 } 78 }
75 } 79 }
76 // OK 80 // OK
77 return options; 81 return options;
78 } 82 }
79 83
80 static CommandLineOptions _parse(List<String> args) { 84 static CommandLineOptions _parse(List<String> args) {
81 var parser = new _CommandLineParser() 85 var parser = new _CommandLineParser()
82 ..addFlag('batch', abbr: 'b', help: 'Run in batch mode', 86 ..addFlag('batch', abbr: 'b', help: 'Run in batch mode',
83 defaultsTo: false, negatable: false) 87 defaultsTo: false, negatable: false)
84 ..addOption('dart_sdk', help: 'Specify path to the Dart sdk') 88 ..addOption('dart-sdk', help: 'The path to the Dart SDK')
85 ..addFlag('machine_format', help: 'Specify whether errors ' 89 ..addOption('package-root', help: 'The path to the package root')
90 ..addFlag('machine-format', help: 'Specify whether errors '
86 'should be in machine format', 91 'should be in machine format',
87 defaultsTo: false, negatable: false) 92 defaultsTo: false, negatable: false)
88 ..addFlag('ignore_unrecognized_flags', 93 ..addFlag('ignore-unrecognized-flags',
89 help: 'Ignore unrecognized command line flags', 94 help: 'Ignore unrecognized command line flags',
90 defaultsTo: false, negatable: false) 95 defaultsTo: false, negatable: false)
91 ..addFlag('fatal_warnings', help: 'Treat non-type warnings as fatal', 96 ..addFlag('fatal-warnings', help: 'Treat non-type warnings as fatal',
92 defaultsTo: false, negatable: false) 97 defaultsTo: false, negatable: false)
93 ..addFlag('show_package_warnings', help: 'Show warnings from package: impo rts', 98 ..addFlag('show-package-warnings', help: 'Show warnings from package: impo rts',
94 defaultsTo: false, negatable: false) 99 defaultsTo: false, negatable: false)
95 ..addFlag('show_sdk_warnings', help: 'Show warnings from SDK imports', 100 ..addFlag('show-sdk-warnings', help: 'Show warnings from SDK imports',
96 defaultsTo: false, negatable: false) 101 defaultsTo: false, negatable: false)
97 ..addFlag('help', abbr: 'h', help: 'Display this help message', 102 ..addFlag('help', abbr: 'h', help: 'Display this help message',
98 defaultsTo: false, negatable: false); 103 defaultsTo: false, negatable: false);
99 104
100 try { 105 try {
101 var results = parser.parse(args); 106 var results = parser.parse(args);
102 // help requests 107 // help requests
103 if (results['help']) { 108 if (results['help']) {
104 _showUsage(parser); 109 _showUsage(parser);
105 exit(0); 110 exit(0);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 228
224 _getNextFlagIndex(args, i) { 229 _getNextFlagIndex(args, i) {
225 for ( ; i < args.length; ++i) { 230 for ( ; i < args.length; ++i) {
226 if (args[i].startsWith('--')) { 231 if (args[i].startsWith('--')) {
227 return i; 232 return i;
228 } 233 }
229 } 234 }
230 return i; 235 return i;
231 } 236 }
232 } 237 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698