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

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

Issue 1441323003: Strong Mode option value validation. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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/test/src/task/options_test.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 59c617a2afc509d95539d68fe8128e65aa12b484..1ec59fab96a34a5a8406a5195b87443cd75f90dc 100644
--- a/pkg/analyzer/lib/src/task/options.dart
+++ b/pkg/analyzer/lib/src/task/options.dart
@@ -73,6 +73,7 @@ class AnalyzerOptionsValidator extends CompositeValidator {
AnalyzerOptionsValidator()
: super([
new TopLevelAnalyzerOptionsValidator(),
+ new StrongModeOptionValueValidator(),
new ErrorFilterOptionValidator(),
new LanguageOptionValidator()
]);
@@ -226,6 +227,28 @@ class GenerateOptionsErrorsTask extends SourceBasedAnalysisTask {
new GenerateOptionsErrorsTask(context, target);
}
+/// Validates `analyzer` strong-mode value configuration options.
+class StrongModeOptionValueValidator extends OptionsValidator {
+ ErrorBuilder trueOrFalseBuilder = new TrueOrFalseValueErrorBuilder();
+
+ @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);
+ }
+ }
+ }
+}
+
/// Validates `analyzer` language configuration options.
class LanguageOptionValidator extends OptionsValidator {
ErrorBuilder builder = new ErrorBuilder(AnalyzerOptions.languageOptions);
@@ -395,7 +418,7 @@ class _OptionsProcessor {
if (feature == AnalyzerOptions.enableSuperMixins) {
if (isTrue(v.value)) {
AnalysisOptionsImpl options =
- new AnalysisOptionsImpl.from(context.analysisOptions);
+ new AnalysisOptionsImpl.from(context.analysisOptions);
options.enableSuperMixins = true;
context.analysisOptions = options;
}
@@ -403,7 +426,7 @@ class _OptionsProcessor {
if (feature == AnalyzerOptions.enableGenericMethods) {
if (isTrue(v.value)) {
AnalysisOptionsImpl options =
- new AnalysisOptionsImpl.from(context.analysisOptions);
+ new AnalysisOptionsImpl.from(context.analysisOptions);
options.enableGenericMethods = true;
context.analysisOptions = options;
}
« no previous file with comments | « no previous file | pkg/analyzer/test/src/task/options_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698