Chromium Code Reviews| 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 28 matching lines...) Expand all Loading... | |
| 39 /// the given [options]. If [options] is `null`, default values are applied. | 39 /// the given [options]. If [options] is `null`, default values are applied. |
| 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 enableStrictCallChecks = 'enableStrictCallChecks'; | |
| 49 static const String enableSuperMixins = 'enableSuperMixins'; | 50 static const String enableSuperMixins = 'enableSuperMixins'; |
| 50 static const String enableConditionalDirectives = | 51 static const String enableConditionalDirectives = |
| 51 "enableConditionalDirectives"; | 52 "enableConditionalDirectives"; |
| 52 static const String errors = 'errors'; | 53 static const String errors = 'errors'; |
| 53 static const String exclude = 'exclude'; | 54 static const String exclude = 'exclude'; |
| 54 static const String language = 'language'; | 55 static const String language = 'language'; |
| 55 static const String plugins = 'plugins'; | 56 static const String plugins = 'plugins'; |
| 56 static const String strong_mode = 'strong-mode'; | 57 static const String strong_mode = 'strong-mode'; |
| 57 | 58 |
| 58 /// Ways to say `ignore`. | 59 /// Ways to say `ignore`. |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 73 errors, | 74 errors, |
| 74 exclude, | 75 exclude, |
| 75 language, | 76 language, |
| 76 plugins, | 77 plugins, |
| 77 strong_mode | 78 strong_mode |
| 78 ]; | 79 ]; |
| 79 | 80 |
| 80 /// Supported `analyzer` language configuration options. | 81 /// Supported `analyzer` language configuration options. |
| 81 static const List<String> languageOptions = const [ | 82 static const List<String> languageOptions = const [ |
| 82 enableAsync, | 83 enableAsync, |
| 84 enableConditionalDirectives, | |
| 83 enableGenericMethods, | 85 enableGenericMethods, |
| 84 enableSuperMixins, | 86 enableStrictCallChecks, |
| 85 enableConditionalDirectives, | 87 enableSuperMixins |
| 86 ]; | 88 ]; |
| 87 } | 89 } |
| 88 | 90 |
| 89 /// Validates `analyzer` options. | 91 /// Validates `analyzer` options. |
| 90 class AnalyzerOptionsValidator extends CompositeValidator { | 92 class AnalyzerOptionsValidator extends CompositeValidator { |
| 91 AnalyzerOptionsValidator() | 93 AnalyzerOptionsValidator() |
| 92 : super([ | 94 : super([ |
| 93 new TopLevelAnalyzerOptionsValidator(), | 95 new TopLevelAnalyzerOptionsValidator(), |
| 94 new StrongModeOptionValueValidator(), | 96 new StrongModeOptionValueValidator(), |
| 95 new ErrorFilterOptionValidator(), | 97 new ErrorFilterOptionValidator(), |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 470 void setLanguageOption( | 472 void setLanguageOption( |
| 471 AnalysisContext context, Object feature, Object value) { | 473 AnalysisContext context, Object feature, Object value) { |
| 472 if (feature == AnalyzerOptions.enableAsync) { | 474 if (feature == AnalyzerOptions.enableAsync) { |
| 473 if (isFalse(value)) { | 475 if (isFalse(value)) { |
| 474 AnalysisOptionsImpl options = | 476 AnalysisOptionsImpl options = |
| 475 new AnalysisOptionsImpl.from(context.analysisOptions); | 477 new AnalysisOptionsImpl.from(context.analysisOptions); |
| 476 options.enableAsync = false; | 478 options.enableAsync = false; |
| 477 context.analysisOptions = options; | 479 context.analysisOptions = options; |
| 478 } | 480 } |
| 479 } | 481 } |
| 482 if (feature == AnalyzerOptions.enableStrictCallChecks) { | |
| 483 if (isTrue(value)) { | |
| 484 AnalysisOptionsImpl options = | |
| 485 new AnalysisOptionsImpl.from(context.analysisOptions); | |
|
Brian Wilkerson
2016/03/11 22:45:02
format?
| |
| 486 options.enableStrictCallChecks = true; | |
| 487 context.analysisOptions = options; | |
| 488 } | |
| 489 } | |
| 480 if (feature == AnalyzerOptions.enableSuperMixins) { | 490 if (feature == AnalyzerOptions.enableSuperMixins) { |
| 481 if (isTrue(value)) { | 491 if (isTrue(value)) { |
| 482 AnalysisOptionsImpl options = | 492 AnalysisOptionsImpl options = |
| 483 new AnalysisOptionsImpl.from(context.analysisOptions); | 493 new AnalysisOptionsImpl.from(context.analysisOptions); |
| 484 options.enableSuperMixins = true; | 494 options.enableSuperMixins = true; |
| 485 context.analysisOptions = options; | 495 context.analysisOptions = options; |
| 486 } | 496 } |
| 487 } | 497 } |
| 488 if (feature == AnalyzerOptions.enableGenericMethods) { | 498 if (feature == AnalyzerOptions.enableGenericMethods) { |
| 489 if (isTrue(value)) { | 499 if (isTrue(value)) { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 555 String feature = key.value?.toString(); | 565 String feature = key.value?.toString(); |
| 556 _applyLanguageOption(options, feature, value.value); | 566 _applyLanguageOption(options, feature, value.value); |
| 557 } | 567 } |
| 558 }); | 568 }); |
| 559 } else if (configs is Map) { | 569 } else if (configs is Map) { |
| 560 configs | 570 configs |
| 561 .forEach((key, value) => _applyLanguageOption(options, key, value)); | 571 .forEach((key, value) => _applyLanguageOption(options, key, value)); |
| 562 } | 572 } |
| 563 } | 573 } |
| 564 } | 574 } |
| OLD | NEW |