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

Unified Diff: pkg/analyzer/lib/src/task/options.dart

Issue 1847633002: Fix more strong mode errors in analyzer (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix copied comment Created 4 years, 9 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
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 8c6980b7fac9be931488ca0b6e489b1efac1a540..d3cc82f883fa24962395dca6be993fc6bfb3a8a7 100644
--- a/pkg/analyzer/lib/src/task/options.dart
+++ b/pkg/analyzer/lib/src/task/options.dart
@@ -168,36 +168,36 @@ class ErrorFilterOptionValidator extends OptionsValidator {
@override
void validate(ErrorReporter reporter, Map<String, YamlNode> options) {
var analyzer = options[AnalyzerOptions.analyzer];
- if (analyzer is! YamlMap) {
- return;
- }
-
- var filters = analyzer[AnalyzerOptions.errors];
- if (filters is YamlMap) {
- String value;
- filters.nodes.forEach((k, v) {
- if (k is YamlScalar) {
- value = toUpperCase(k.value);
- if (!errorCodes.contains(value)) {
- reporter.reportErrorForSpan(
- AnalysisOptionsWarningCode.UNRECOGNIZED_ERROR_CODE,
- k.span,
- [k.value?.toString()]);
+ if (analyzer is YamlMap) {
+ var filters = analyzer[AnalyzerOptions.errors];
+ if (filters is YamlMap) {
+ String value;
+ filters.nodes.forEach((k, v) {
+ if (k is YamlScalar) {
+ value = toUpperCase(k.value);
+ if (!errorCodes.contains(value)) {
+ reporter.reportErrorForSpan(
+ AnalysisOptionsWarningCode.UNRECOGNIZED_ERROR_CODE,
+ k.span,
+ [k.value?.toString()]);
+ }
}
- }
- if (v is YamlScalar) {
- value = toLowerCase(v.value);
- if (!legalValues.contains(value)) {
- reporter.reportErrorForSpan(
- AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUES,
- v.span, [
- AnalyzerOptions.errors,
- v.value?.toString(),
- legalValueString
- ]);
+ if (v is YamlScalar) {
+ value = toLowerCase(v.value);
+ if (!legalValues.contains(value)) {
+ reporter.reportErrorForSpan(
+ AnalysisOptionsWarningCode
+ .UNSUPPORTED_OPTION_WITH_LEGAL_VALUES,
+ v.span,
+ [
+ AnalyzerOptions.errors,
+ v.value?.toString(),
+ legalValueString
+ ]);
+ }
}
- }
- });
+ });
+ }
}
}
}
@@ -255,7 +255,7 @@ class GenerateOptionsErrorsTask extends SourceBasedAnalysisTask {
/// Return a map from the names of the inputs of this kind of task to the
/// task input descriptors describing those inputs for a task with the
/// given [target].
- static Map<String, TaskInput> buildInputs(Source source) =>
+ static Map<String, TaskInput> buildInputs(AnalysisTarget source) =>
<String, TaskInput>{CONTENT_INPUT_NAME: CONTENT.of(source)};
/// Compute [LineInfo] for the given [content].
@@ -289,31 +289,29 @@ class LanguageOptionValidator extends OptionsValidator {
@override
void validate(ErrorReporter reporter, Map<String, YamlNode> options) {
var analyzer = options[AnalyzerOptions.analyzer];
- if (analyzer is! YamlMap) {
- return;
- }
-
- var language = analyzer[AnalyzerOptions.language];
- if (language is YamlMap) {
- language.nodes.forEach((k, v) {
- String key, value;
- bool validKey = false;
- if (k is YamlScalar) {
- key = k.value?.toString();
- if (!AnalyzerOptions.languageOptions.contains(key)) {
- builder.reportError(reporter, AnalyzerOptions.language, k);
- } else {
- // If we have a valid key, go on and check the value.
- validKey = true;
+ if (analyzer is YamlMap) {
+ var language = analyzer[AnalyzerOptions.language];
+ if (language is YamlMap) {
+ language.nodes.forEach((k, v) {
+ String key, value;
+ bool validKey = false;
+ if (k is YamlScalar) {
+ key = k.value?.toString();
+ if (!AnalyzerOptions.languageOptions.contains(key)) {
+ builder.reportError(reporter, AnalyzerOptions.language, k);
+ } else {
+ // If we have a valid key, go on and check the value.
+ validKey = true;
+ }
}
- }
- if (validKey && v is YamlScalar) {
- value = toLowerCase(v.value);
- if (!AnalyzerOptions.trueOrFalse.contains(value)) {
- trueOrFalseBuilder.reportError(reporter, key, v);
+ if (validKey && v is YamlScalar) {
+ value = toLowerCase(v.value);
+ if (!AnalyzerOptions.trueOrFalse.contains(value)) {
+ trueOrFalseBuilder.reportError(reporter, key, v);
+ }
}
- }
- });
+ });
+ }
}
}
}
@@ -352,16 +350,14 @@ class StrongModeOptionValueValidator extends OptionsValidator {
@override
void validate(ErrorReporter reporter, Map<String, YamlNode> options) {
var analyzer = options[AnalyzerOptions.analyzer];
- if (analyzer is! YamlMap) {
- return;
- }
-
- var v = analyzer.nodes[AnalyzerOptions.strong_mode];
- if (v is YamlScalar) {
- var value = toLowerCase(v.value);
- if (!AnalyzerOptions.trueOrFalse.contains(value)) {
- trueOrFalseBuilder.reportError(
- reporter, AnalyzerOptions.strong_mode, v);
+ if (analyzer is YamlMap) {
+ var v = analyzer.nodes[AnalyzerOptions.strong_mode];
+ if (v is YamlScalar) {
+ var value = toLowerCase(v.value);
+ if (!AnalyzerOptions.trueOrFalse.contains(value)) {
+ trueOrFalseBuilder.reportError(
+ reporter, AnalyzerOptions.strong_mode, v);
+ }
}
}
}
@@ -431,17 +427,16 @@ class _OptionsProcessor {
return;
}
var analyzer = optionMap[AnalyzerOptions.analyzer];
- if (analyzer is! Map) {
- return;
- }
- // Process strong mode option.
- var strongMode = analyzer[AnalyzerOptions.strong_mode];
- if (strongMode is bool) {
- options.strongMode = strongMode;
+ if (analyzer is Map) {
+ // Process strong mode option.
+ var strongMode = analyzer[AnalyzerOptions.strong_mode];
+ if (strongMode is bool) {
+ options.strongMode = strongMode;
+ }
+ // Process language options.
+ var language = analyzer[AnalyzerOptions.language];
+ _applyLanguageOptions(options, language);
}
- // Process language options.
- var language = analyzer[AnalyzerOptions.language];
- _applyLanguageOptions(options, language);
}
/// Configure [context] based on the given [options] (which can be `null`
@@ -452,21 +447,19 @@ class _OptionsProcessor {
}
var analyzer = options[AnalyzerOptions.analyzer];
- if (analyzer is! Map) {
- return;
+ if (analyzer is Map) {
+ // Set strong mode (default is false).
+ var strongMode = analyzer[AnalyzerOptions.strong_mode];
+ setStrongMode(context, strongMode);
+
+ // Set filters.
+ var filters = analyzer[AnalyzerOptions.errors];
+ setProcessors(context, filters);
+
+ // Process language options.
+ var language = analyzer[AnalyzerOptions.language];
+ setLanguageOptions(context, language);
}
-
- // Set strong mode (default is false).
- var strongMode = analyzer[AnalyzerOptions.strong_mode];
- setStrongMode(context, strongMode);
-
- // Set filters.
- var filters = analyzer[AnalyzerOptions.errors];
- setProcessors(context, filters);
-
- // Process language options.
- var language = analyzer[AnalyzerOptions.language];
- setLanguageOptions(context, language);
}
void setLanguageOption(

Powered by Google App Engine
This is Rietveld 408576698