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

Side by Side Diff: pkg/analyzer_cli/lib/src/options.dart

Issue 2144383002: fix #26782, add no-implicit-casts, no-implicit-dynamic options (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merged Created 4 years, 5 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
« no previous file with comments | « pkg/analyzer_cli/lib/src/driver.dart ('k') | no next file » | 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) 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 /// The source files to analyze 144 /// The source files to analyze
145 final List<String> sourceFiles; 145 final List<String> sourceFiles;
146 146
147 /// Whether to treat warnings as fatal 147 /// Whether to treat warnings as fatal
148 final bool warningsAreFatal; 148 final bool warningsAreFatal;
149 149
150 /// Whether to use strong static checking. 150 /// Whether to use strong static checking.
151 final bool strongMode; 151 final bool strongMode;
152 152
153 /// Whether implicit casts are enabled (in strong mode)
154 final bool implicitCasts;
155
156 /// Whether implicit dynamic is enabled (mainly for strong mode users)
157 final bool implicitDynamic;
158
153 /// Whether to treat lints as fatal 159 /// Whether to treat lints as fatal
154 final bool lintsAreFatal; 160 final bool lintsAreFatal;
155 161
156 /// Initialize options from the given parsed [args]. 162 /// Initialize options from the given parsed [args].
157 CommandLineOptions._fromArgs( 163 CommandLineOptions._fromArgs(
158 ArgResults args, Map<String, String> definedVariables) 164 ArgResults args, Map<String, String> definedVariables)
159 : buildAnalysisOutput = args['build-analysis-output'], 165 : buildAnalysisOutput = args['build-analysis-output'],
160 buildMode = args['build-mode'], 166 buildMode = args['build-mode'],
161 buildModePersistentWorker = args['persistent_worker'], 167 buildModePersistentWorker = args['persistent_worker'],
162 buildSummaryFallback = args['build-summary-fallback'], 168 buildSummaryFallback = args['build-summary-fallback'],
(...skipping 27 matching lines...) Expand all
190 perfReport = args['x-perf-report'], 196 perfReport = args['x-perf-report'],
191 shouldBatch = args['batch'], 197 shouldBatch = args['batch'],
192 showPackageWarnings = args['show-package-warnings'] || 198 showPackageWarnings = args['show-package-warnings'] ||
193 args['package-warnings'] || 199 args['package-warnings'] ||
194 args['x-package-warnings-prefix'] != null, 200 args['x-package-warnings-prefix'] != null,
195 showPackageWarningsPrefix = args['x-package-warnings-prefix'], 201 showPackageWarningsPrefix = args['x-package-warnings-prefix'],
196 showSdkWarnings = args['show-sdk-warnings'] || args['warnings'], 202 showSdkWarnings = args['show-sdk-warnings'] || args['warnings'],
197 sourceFiles = args.rest, 203 sourceFiles = args.rest,
198 warningsAreFatal = args['fatal-warnings'], 204 warningsAreFatal = args['fatal-warnings'],
199 strongMode = args['strong'], 205 strongMode = args['strong'],
206 implicitCasts = !args['no-implicit-casts'],
207 implicitDynamic = !args['no-implicit-dynamic'],
200 lintsAreFatal = args['fatal-lints']; 208 lintsAreFatal = args['fatal-lints'];
201 209
202 /// Parse [args] into [CommandLineOptions] describing the specified 210 /// Parse [args] into [CommandLineOptions] describing the specified
203 /// analyzer options. In case of a format error, calls [printAndFail], which 211 /// analyzer options. In case of a format error, calls [printAndFail], which
204 /// by default prints an error message to stderr and exits. 212 /// by default prints an error message to stderr and exits.
205 static CommandLineOptions parse(List<String> args, 213 static CommandLineOptions parse(List<String> args,
206 [printAndFail(String msg) = printAndFail]) { 214 [printAndFail(String msg) = printAndFail]) {
207 CommandLineOptions options = _parse(args); 215 CommandLineOptions options = _parse(args);
208 // Check SDK. 216 // Check SDK.
209 if (!options.buildModePersistentWorker) { 217 if (!options.buildModePersistentWorker) {
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 help: 'Log additional messages and exceptions.', 479 help: 'Log additional messages and exceptions.',
472 defaultsTo: false, 480 defaultsTo: false,
473 negatable: false, 481 negatable: false,
474 hide: true) 482 hide: true)
475 ..addFlag('enable_type_checks', 483 ..addFlag('enable_type_checks',
476 help: 'Check types in constant evaluation.', 484 help: 'Check types in constant evaluation.',
477 defaultsTo: false, 485 defaultsTo: false,
478 negatable: false, 486 negatable: false,
479 hide: true) 487 hide: true)
480 ..addFlag('strong', 488 ..addFlag('strong',
481 help: 'Enable strong static checks (https://goo.gl/DqcBsw)'); 489 help: 'Enable strong static checks (https://goo.gl/DqcBsw)')
490 ..addFlag('no-implicit-casts',
491 negatable: false,
492 help: 'Disable implicit casts in strong mode (https://goo.gl/cTLz40)')
493 ..addFlag('no-implicit-dynamic',
494 negatable: false,
495 help: 'Disable implicit dynamic (https://goo.gl/m0UgXD)');
482 496
483 try { 497 try {
484 // TODO(scheglov) https://code.google.com/p/dart/issues/detail?id=11061 498 // TODO(scheglov) https://code.google.com/p/dart/issues/detail?id=11061
485 args = 499 args =
486 args.map((String arg) => arg == '-batch' ? '--batch' : arg).toList(); 500 args.map((String arg) => arg == '-batch' ? '--batch' : arg).toList();
487 Map<String, String> definedVariables = <String, String>{}; 501 Map<String, String> definedVariables = <String, String>{};
488 var results = parser.parse(args, definedVariables); 502 var results = parser.parse(args, definedVariables);
489 503
490 // Persistent worker. 504 // Persistent worker.
491 if (args.contains('--persistent_worker')) { 505 if (args.contains('--persistent_worker')) {
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 708
695 int _getNextFlagIndex(args, i) { 709 int _getNextFlagIndex(args, i) {
696 for (; i < args.length; ++i) { 710 for (; i < args.length; ++i) {
697 if (args[i].startsWith('--')) { 711 if (args[i].startsWith('--')) {
698 return i; 712 return i;
699 } 713 }
700 } 714 }
701 return i; 715 return i;
702 } 716 }
703 } 717 }
OLDNEW
« no previous file with comments | « pkg/analyzer_cli/lib/src/driver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698