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

Unified Diff: pkg/analyzer/lib/src/task/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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer_cli/lib/src/driver.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/task/options.dart
diff --git a/pkg/analyzer/lib/src/task/options.dart b/pkg/analyzer/lib/src/task/options.dart
index 6d066009b5246c63735727e71a2894db9302ce2d..a5b2f5e4f08a04118ed8f2f3983aa097d00bf01e 100644
--- a/pkg/analyzer/lib/src/task/options.dart
+++ b/pkg/analyzer/lib/src/task/options.dart
@@ -55,6 +55,10 @@ class AnalyzerOptions {
static const String plugins = 'plugins';
static const String strong_mode = 'strong-mode';
+ // Strong mode options, see AnalysisOptionsImpl for documentation.
+ static const String implicitCasts = 'implicit-casts';
+ static const String implicitDynamic = 'implicit-dynamic';
+
/// Ways to say `ignore`.
static const List<String> ignoreSynonyms = const ['ignore', 'false'];
@@ -428,9 +432,8 @@ class _OptionsProcessor {
if (analyzer is Map) {
// Process strong mode option.
var strongMode = analyzer[AnalyzerOptions.strong_mode];
- if (strongMode is bool) {
- options.strongMode = strongMode;
- }
+ _applyStrongOptions(options, strongMode);
+
// Process language options.
var language = analyzer[AnalyzerOptions.language];
_applyLanguageOptions(options, language);
@@ -524,12 +527,19 @@ class _OptionsProcessor {
}
void setStrongMode(AnalysisContext context, Object strongMode) {
- bool strong = strongMode is bool ? strongMode : false;
- if (context.analysisOptions.strongMode != strong) {
+ if (strongMode is Map) {
AnalysisOptionsImpl options =
new AnalysisOptionsImpl.from(context.analysisOptions);
- options.strongMode = strong;
+ _applyStrongOptions(options, strongMode);
context.analysisOptions = options;
+ } else {
+ strongMode = strongMode is bool ? strongMode : false;
+ if (context.analysisOptions.strongMode != strongMode) {
+ AnalysisOptionsImpl options =
+ new AnalysisOptionsImpl.from(context.analysisOptions);
+ options.strongMode = strongMode;
+ context.analysisOptions = options;
+ }
}
}
@@ -562,4 +572,33 @@ class _OptionsProcessor {
.forEach((key, value) => _applyLanguageOption(options, key, value));
}
}
+
+ void _applyStrongOptions(AnalysisOptionsImpl options, Object config) {
+ if (config is YamlMap) {
+ options.strongMode = true;
+ config.nodes.forEach((k, v) {
+ if (k is YamlScalar && v is YamlScalar) {
+ _applyStrongModeOption(options, k.value?.toString(), v.value);
+ }
+ });
+ } else if (config is Map) {
+ options.strongMode = true;
+ config.forEach((k, v) => _applyStrongModeOption(options, k, v));
+ } else {
+ options.strongMode = config is bool ? config : false;
+ }
+ }
+
+ void _applyStrongModeOption(
+ AnalysisOptionsImpl options, Object feature, Object value) {
+ bool boolValue = toBool(value);
+ if (boolValue != null) {
+ if (feature == AnalyzerOptions.implicitCasts) {
+ options.implicitCasts = boolValue;
+ }
+ if (feature == AnalyzerOptions.implicitDynamic) {
+ options.implicitDynamic = boolValue;
+ }
+ }
+ }
}
« no previous file with comments | « no previous file | pkg/analyzer_cli/lib/src/driver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698