| 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 29 matching lines...) Expand all Loading... |
| 40 void configureContextOptions( | 40 void configureContextOptions( |
| 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 enableSuperMixins = 'enableSuperMixins'; | 49 static const String enableSuperMixins = 'enableSuperMixins'; |
| 50 static const String enableConditionalDirectives = |
| 51 "enableConditionalDirectives"; |
| 50 static const String errors = 'errors'; | 52 static const String errors = 'errors'; |
| 51 static const String exclude = 'exclude'; | 53 static const String exclude = 'exclude'; |
| 52 static const String language = 'language'; | 54 static const String language = 'language'; |
| 53 static const String plugins = 'plugins'; | 55 static const String plugins = 'plugins'; |
| 54 static const String strong_mode = 'strong-mode'; | 56 static const String strong_mode = 'strong-mode'; |
| 55 | 57 |
| 56 /// Ways to say `ignore`. | 58 /// Ways to say `ignore`. |
| 57 static const List<String> ignoreSynonyms = const ['ignore', 'false']; | 59 static const List<String> ignoreSynonyms = const ['ignore', 'false']; |
| 58 | 60 |
| 59 /// Valid error `severity`s. | 61 /// Valid error `severity`s. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 72 exclude, | 74 exclude, |
| 73 language, | 75 language, |
| 74 plugins, | 76 plugins, |
| 75 strong_mode | 77 strong_mode |
| 76 ]; | 78 ]; |
| 77 | 79 |
| 78 /// Supported `analyzer` language configuration options. | 80 /// Supported `analyzer` language configuration options. |
| 79 static const List<String> languageOptions = const [ | 81 static const List<String> languageOptions = const [ |
| 80 enableAsync, | 82 enableAsync, |
| 81 enableGenericMethods, | 83 enableGenericMethods, |
| 82 enableSuperMixins | 84 enableSuperMixins, |
| 85 enableConditionalDirectives, |
| 83 ]; | 86 ]; |
| 84 } | 87 } |
| 85 | 88 |
| 86 /// Validates `analyzer` options. | 89 /// Validates `analyzer` options. |
| 87 class AnalyzerOptionsValidator extends CompositeValidator { | 90 class AnalyzerOptionsValidator extends CompositeValidator { |
| 88 AnalyzerOptionsValidator() | 91 AnalyzerOptionsValidator() |
| 89 : super([ | 92 : super([ |
| 90 new TopLevelAnalyzerOptionsValidator(), | 93 new TopLevelAnalyzerOptionsValidator(), |
| 91 new StrongModeOptionValueValidator(), | 94 new StrongModeOptionValueValidator(), |
| 92 new ErrorFilterOptionValidator(), | 95 new ErrorFilterOptionValidator(), |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 } | 486 } |
| 484 } | 487 } |
| 485 if (feature == AnalyzerOptions.enableGenericMethods) { | 488 if (feature == AnalyzerOptions.enableGenericMethods) { |
| 486 if (isTrue(value)) { | 489 if (isTrue(value)) { |
| 487 AnalysisOptionsImpl options = | 490 AnalysisOptionsImpl options = |
| 488 new AnalysisOptionsImpl.from(context.analysisOptions); | 491 new AnalysisOptionsImpl.from(context.analysisOptions); |
| 489 options.enableGenericMethods = true; | 492 options.enableGenericMethods = true; |
| 490 context.analysisOptions = options; | 493 context.analysisOptions = options; |
| 491 } | 494 } |
| 492 } | 495 } |
| 496 if (feature == AnalyzerOptions.enableConditionalDirectives) { |
| 497 if (isTrue(value)) { |
| 498 AnalysisOptionsImpl options = |
| 499 new AnalysisOptionsImpl.from(context.analysisOptions); |
| 500 options.enableConditionalDirectives = true; |
| 501 context.analysisOptions = options; |
| 502 } |
| 503 } |
| 493 } | 504 } |
| 494 | 505 |
| 495 void setLanguageOptions(AnalysisContext context, Object configs) { | 506 void setLanguageOptions(AnalysisContext context, Object configs) { |
| 496 if (configs is YamlMap) { | 507 if (configs is YamlMap) { |
| 497 configs.nodes.forEach((k, v) { | 508 configs.nodes.forEach((k, v) { |
| 498 if (k is YamlScalar && v is YamlScalar) { | 509 if (k is YamlScalar && v is YamlScalar) { |
| 499 String feature = k.value?.toString(); | 510 String feature = k.value?.toString(); |
| 500 setLanguageOption(context, feature, v.value); | 511 setLanguageOption(context, feature, v.value); |
| 501 } | 512 } |
| 502 }); | 513 }); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 String feature = key.value?.toString(); | 555 String feature = key.value?.toString(); |
| 545 _applyLanguageOption(options, feature, value.value); | 556 _applyLanguageOption(options, feature, value.value); |
| 546 } | 557 } |
| 547 }); | 558 }); |
| 548 } else if (configs is Map) { | 559 } else if (configs is Map) { |
| 549 configs | 560 configs |
| 550 .forEach((key, value) => _applyLanguageOption(options, key, value)); | 561 .forEach((key, value) => _applyLanguageOption(options, key, value)); |
| 551 } | 562 } |
| 552 } | 563 } |
| 553 } | 564 } |
| OLD | NEW |