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

Unified Diff: pkg/analyzer/lib/src/command_line/arguments.dart

Issue 2598523003: cmdline flags override analysis options in file (Closed)
Patch Set: address comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/context/builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/command_line/arguments.dart
diff --git a/pkg/analyzer/lib/src/command_line/arguments.dart b/pkg/analyzer/lib/src/command_line/arguments.dart
index 5ea958eaad61039d80ed01c1b813ad1fd3ed6675..22a967065beb68a673e0f35ed641b52f78a418d9 100644
--- a/pkg/analyzer/lib/src/command_line/arguments.dart
+++ b/pkg/analyzer/lib/src/command_line/arguments.dart
@@ -18,7 +18,7 @@ const String analysisOptionsFileOption = 'options';
const String defineVariableOption = 'D';
const String enableInitializingFormalAccessFlag = 'initializing-formal-access';
const String enableStrictCallChecksFlag = 'enable-strict-call-checks';
-const String enableSuperInMixinFlag = 'supermixin';
+const String enableSuperMixinFlag = 'supermixin';
const String ignoreUnrecognizedFlagsFlag = 'ignore-unrecognized-flags';
const String noImplicitCastsFlag = 'no-implicit-casts';
const String noImplicitDynamicFlag = 'no-implicit-dynamic';
@@ -29,11 +29,33 @@ const String sdkSummaryPathOption = 'dart-sdk-summary';
const String strongModeFlag = 'strong';
/**
+ * Update [options] with the value of each analysis option command line flag.
+ */
+void applyAnalysisOptionFlags(AnalysisOptionsImpl options, ArgResults args) {
+ if (args.wasParsed(enableStrictCallChecksFlag)) {
+ options.enableStrictCallChecks = args[enableStrictCallChecksFlag];
+ }
+ if (args.wasParsed(enableSuperMixinFlag)) {
+ options.enableSuperMixins = args[enableSuperMixinFlag];
+ }
+ if (args.wasParsed(noImplicitCastsFlag)) {
+ options.implicitCasts = !args[noImplicitCastsFlag];
+ }
+ if (args.wasParsed(noImplicitDynamicFlag)) {
+ options.implicitDynamic = !args[noImplicitDynamicFlag];
+ }
+ if (args.wasParsed(strongModeFlag)) {
+ options.strongMode = args[strongModeFlag];
+ }
+}
+
+/**
* Use the given [resourceProvider], [contentCache] and command-line [args] to
* create a context builder.
*/
ContextBuilderOptions createContextBuilderOptions(ArgResults args) {
ContextBuilderOptions builderOptions = new ContextBuilderOptions();
+ builderOptions.argResults = args;
//
// File locations.
//
@@ -46,11 +68,7 @@ ContextBuilderOptions createContextBuilderOptions(ArgResults args) {
// Analysis options.
//
AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl();
- defaultOptions.enableStrictCallChecks = args[enableStrictCallChecksFlag];
- defaultOptions.enableSuperMixins = args[enableSuperInMixinFlag];
- defaultOptions.implicitCasts = !args[noImplicitCastsFlag];
- defaultOptions.implicitDynamic = !args[noImplicitDynamicFlag];
- defaultOptions.strongMode = args[strongModeFlag];
+ applyAnalysisOptionFlags(defaultOptions, args);
builderOptions.defaultOptions = defaultOptions;
//
// Declared variables.
@@ -163,7 +181,7 @@ void defineAnalysisArguments(ArgParser parser, {bool hide: true, ddc: false}) {
defaultsTo: false,
negatable: false,
hide: hide || ddc);
- parser.addFlag(enableSuperInMixinFlag,
+ parser.addFlag(enableSuperMixinFlag,
help: 'Relax restrictions on mixins (DEP 34).',
defaultsTo: false,
negatable: false,
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/context/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698