| OLD | NEW |
| 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.src.task.options; | 5 library analyzer.src.task.options; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/analyzer.dart'; | 9 import 'package:analyzer/analyzer.dart'; |
| 10 import 'package:analyzer/plugin/options.dart'; | 10 import 'package:analyzer/plugin/options.dart'; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 AnalysisContext context, Map<String, Object> options) => | 41 AnalysisContext context, Map<String, Object> options) => |
| 42 _processor.configure(context, options); | 42 _processor.configure(context, options); |
| 43 | 43 |
| 44 /// `analyzer` analysis options constants. | 44 /// `analyzer` analysis options constants. |
| 45 class AnalyzerOptions { | 45 class AnalyzerOptions { |
| 46 static const String analyzer = 'analyzer'; | 46 static const String analyzer = 'analyzer'; |
| 47 static const String enableAsync = 'enableAsync'; | 47 static const String enableAsync = 'enableAsync'; |
| 48 static const String enableGenericMethods = 'enableGenericMethods'; | 48 static const String enableGenericMethods = 'enableGenericMethods'; |
| 49 static const String enableStrictCallChecks = 'enableStrictCallChecks'; | 49 static const String enableStrictCallChecks = 'enableStrictCallChecks'; |
| 50 static const String enableSuperMixins = 'enableSuperMixins'; | 50 static const String enableSuperMixins = 'enableSuperMixins'; |
| 51 static const String enableConditionalDirectives = | |
| 52 "enableConditionalDirectives"; | |
| 53 static const String errors = 'errors'; | 51 static const String errors = 'errors'; |
| 54 static const String exclude = 'exclude'; | 52 static const String exclude = 'exclude'; |
| 55 static const String language = 'language'; | 53 static const String language = 'language'; |
| 56 static const String plugins = 'plugins'; | 54 static const String plugins = 'plugins'; |
| 57 static const String strong_mode = 'strong-mode'; | 55 static const String strong_mode = 'strong-mode'; |
| 58 | 56 |
| 59 /// Ways to say `ignore`. | 57 /// Ways to say `ignore`. |
| 60 static const List<String> ignoreSynonyms = const ['ignore', 'false']; | 58 static const List<String> ignoreSynonyms = const ['ignore', 'false']; |
| 61 | 59 |
| 62 /// Valid error `severity`s. | 60 /// Valid error `severity`s. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 74 errors, | 72 errors, |
| 75 exclude, | 73 exclude, |
| 76 language, | 74 language, |
| 77 plugins, | 75 plugins, |
| 78 strong_mode | 76 strong_mode |
| 79 ]; | 77 ]; |
| 80 | 78 |
| 81 /// Supported `analyzer` language configuration options. | 79 /// Supported `analyzer` language configuration options. |
| 82 static const List<String> languageOptions = const [ | 80 static const List<String> languageOptions = const [ |
| 83 enableAsync, | 81 enableAsync, |
| 84 enableConditionalDirectives, | |
| 85 enableGenericMethods, | 82 enableGenericMethods, |
| 86 enableStrictCallChecks, | 83 enableStrictCallChecks, |
| 87 enableSuperMixins | 84 enableSuperMixins |
| 88 ]; | 85 ]; |
| 89 } | 86 } |
| 90 | 87 |
| 91 /// Validates `analyzer` options. | 88 /// Validates `analyzer` options. |
| 92 class AnalyzerOptionsValidator extends CompositeValidator { | 89 class AnalyzerOptionsValidator extends CompositeValidator { |
| 93 AnalyzerOptionsValidator() | 90 AnalyzerOptionsValidator() |
| 94 : super([ | 91 : super([ |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 } | 493 } |
| 497 } | 494 } |
| 498 if (feature == AnalyzerOptions.enableGenericMethods) { | 495 if (feature == AnalyzerOptions.enableGenericMethods) { |
| 499 if (isTrue(value)) { | 496 if (isTrue(value)) { |
| 500 AnalysisOptionsImpl options = | 497 AnalysisOptionsImpl options = |
| 501 new AnalysisOptionsImpl.from(context.analysisOptions); | 498 new AnalysisOptionsImpl.from(context.analysisOptions); |
| 502 options.enableGenericMethods = true; | 499 options.enableGenericMethods = true; |
| 503 context.analysisOptions = options; | 500 context.analysisOptions = options; |
| 504 } | 501 } |
| 505 } | 502 } |
| 506 if (feature == AnalyzerOptions.enableConditionalDirectives) { | |
| 507 if (isTrue(value)) { | |
| 508 AnalysisOptionsImpl options = | |
| 509 new AnalysisOptionsImpl.from(context.analysisOptions); | |
| 510 options.enableConditionalDirectives = true; | |
| 511 context.analysisOptions = options; | |
| 512 } | |
| 513 } | |
| 514 } | 503 } |
| 515 | 504 |
| 516 void setLanguageOptions(AnalysisContext context, Object configs) { | 505 void setLanguageOptions(AnalysisContext context, Object configs) { |
| 517 if (configs is YamlMap) { | 506 if (configs is YamlMap) { |
| 518 configs.nodes.forEach((k, v) { | 507 configs.nodes.forEach((k, v) { |
| 519 if (k is YamlScalar && v is YamlScalar) { | 508 if (k is YamlScalar && v is YamlScalar) { |
| 520 String feature = k.value?.toString(); | 509 String feature = k.value?.toString(); |
| 521 setLanguageOption(context, feature, v.value); | 510 setLanguageOption(context, feature, v.value); |
| 522 } | 511 } |
| 523 }); | 512 }); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 String feature = key.value?.toString(); | 554 String feature = key.value?.toString(); |
| 566 _applyLanguageOption(options, feature, value.value); | 555 _applyLanguageOption(options, feature, value.value); |
| 567 } | 556 } |
| 568 }); | 557 }); |
| 569 } else if (configs is Map) { | 558 } else if (configs is Map) { |
| 570 configs | 559 configs |
| 571 .forEach((key, value) => _applyLanguageOption(options, key, value)); | 560 .forEach((key, value) => _applyLanguageOption(options, key, value)); |
| 572 } | 561 } |
| 573 } | 562 } |
| 574 } | 563 } |
| OLD | NEW |