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 21 matching lines...) Expand all Loading... |
32 | 32 |
33 /// Configure this [context] based on configuration details specified in | 33 /// Configure this [context] based on configuration details specified in |
34 /// the given [options]. If [options] is `null`, default values are applied. | 34 /// the given [options]. If [options] is `null`, default values are applied. |
35 void configureContextOptions( | 35 void configureContextOptions( |
36 AnalysisContext context, Map<String, Object> options) => | 36 AnalysisContext context, Map<String, Object> options) => |
37 _processor.configure(context, options); | 37 _processor.configure(context, options); |
38 | 38 |
39 /// `analyzer` analysis options constants. | 39 /// `analyzer` analysis options constants. |
40 class AnalyzerOptions { | 40 class AnalyzerOptions { |
41 static const String analyzer = 'analyzer'; | 41 static const String analyzer = 'analyzer'; |
| 42 static const String enableAsync = 'enableAsync'; |
42 static const String enableGenericMethods = 'enableGenericMethods'; | 43 static const String enableGenericMethods = 'enableGenericMethods'; |
43 static const String enableSuperMixins = 'enableSuperMixins'; | 44 static const String enableSuperMixins = 'enableSuperMixins'; |
44 static const String errors = 'errors'; | 45 static const String errors = 'errors'; |
45 static const String exclude = 'exclude'; | 46 static const String exclude = 'exclude'; |
46 static const String language = 'language'; | 47 static const String language = 'language'; |
47 static const String plugins = 'plugins'; | 48 static const String plugins = 'plugins'; |
48 static const String strong_mode = 'strong-mode'; | 49 static const String strong_mode = 'strong-mode'; |
49 | 50 |
50 /// Ways to say `ignore`. | 51 /// Ways to say `ignore`. |
51 static const List<String> ignoreSynonyms = const ['ignore', 'false']; | 52 static const List<String> ignoreSynonyms = const ['ignore', 'false']; |
(...skipping 12 matching lines...) Expand all Loading... |
64 static const List<String> topLevel = const [ | 65 static const List<String> topLevel = const [ |
65 errors, | 66 errors, |
66 exclude, | 67 exclude, |
67 language, | 68 language, |
68 plugins, | 69 plugins, |
69 strong_mode | 70 strong_mode |
70 ]; | 71 ]; |
71 | 72 |
72 /// Supported `analyzer` language configuration options. | 73 /// Supported `analyzer` language configuration options. |
73 static const List<String> languageOptions = const [ | 74 static const List<String> languageOptions = const [ |
| 75 enableAsync, |
74 enableGenericMethods, | 76 enableGenericMethods, |
75 enableSuperMixins | 77 enableSuperMixins |
76 ]; | 78 ]; |
77 } | 79 } |
78 | 80 |
79 /// Validates `analyzer` options. | 81 /// Validates `analyzer` options. |
80 class AnalyzerOptionsValidator extends CompositeValidator { | 82 class AnalyzerOptionsValidator extends CompositeValidator { |
81 AnalyzerOptionsValidator() | 83 AnalyzerOptionsValidator() |
82 : super([ | 84 : super([ |
83 new TopLevelAnalyzerOptionsValidator(), | 85 new TopLevelAnalyzerOptionsValidator(), |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 var filters = analyzer[AnalyzerOptions.errors]; | 420 var filters = analyzer[AnalyzerOptions.errors]; |
419 setProcessors(context, filters); | 421 setProcessors(context, filters); |
420 | 422 |
421 // Process language options. | 423 // Process language options. |
422 var language = analyzer[AnalyzerOptions.language]; | 424 var language = analyzer[AnalyzerOptions.language]; |
423 setLanguageOptions(context, language); | 425 setLanguageOptions(context, language); |
424 } | 426 } |
425 | 427 |
426 void setLanguageOption( | 428 void setLanguageOption( |
427 AnalysisContext context, Object feature, Object value) { | 429 AnalysisContext context, Object feature, Object value) { |
| 430 if (feature == AnalyzerOptions.enableAsync) { |
| 431 if (isFalse(value)) { |
| 432 AnalysisOptionsImpl options = |
| 433 new AnalysisOptionsImpl.from(context.analysisOptions); |
| 434 options.enableAsync = false; |
| 435 context.analysisOptions = options; |
| 436 } |
| 437 } |
428 if (feature == AnalyzerOptions.enableSuperMixins) { | 438 if (feature == AnalyzerOptions.enableSuperMixins) { |
429 if (isTrue(value)) { | 439 if (isTrue(value)) { |
430 AnalysisOptionsImpl options = | 440 AnalysisOptionsImpl options = |
431 new AnalysisOptionsImpl.from(context.analysisOptions); | 441 new AnalysisOptionsImpl.from(context.analysisOptions); |
432 options.enableSuperMixins = true; | 442 options.enableSuperMixins = true; |
433 context.analysisOptions = options; | 443 context.analysisOptions = options; |
434 } | 444 } |
435 } | 445 } |
436 if (feature == AnalyzerOptions.enableGenericMethods) { | 446 if (feature == AnalyzerOptions.enableGenericMethods) { |
437 if (isTrue(value)) { | 447 if (isTrue(value)) { |
(...skipping 27 matching lines...) Expand all Loading... |
465 void setStrongMode(AnalysisContext context, Object strongMode) { | 475 void setStrongMode(AnalysisContext context, Object strongMode) { |
466 bool strong = strongMode is bool ? strongMode : false; | 476 bool strong = strongMode is bool ? strongMode : false; |
467 if (context.analysisOptions.strongMode != strong) { | 477 if (context.analysisOptions.strongMode != strong) { |
468 AnalysisOptionsImpl options = | 478 AnalysisOptionsImpl options = |
469 new AnalysisOptionsImpl.from(context.analysisOptions); | 479 new AnalysisOptionsImpl.from(context.analysisOptions); |
470 options.strongMode = strong; | 480 options.strongMode = strong; |
471 context.analysisOptions = options; | 481 context.analysisOptions = options; |
472 } | 482 } |
473 } | 483 } |
474 } | 484 } |
OLD | NEW |