| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 AnalysisContext context, Map<String, Object> options) => | 42 AnalysisContext context, Map<String, Object> options) => |
| 43 _processor.configure(context, options); | 43 _processor.configure(context, options); |
| 44 | 44 |
| 45 /// `analyzer` analysis options constants. | 45 /// `analyzer` analysis options constants. |
| 46 class AnalyzerOptions { | 46 class AnalyzerOptions { |
| 47 static const String analyzer = 'analyzer'; | 47 static const String analyzer = 'analyzer'; |
| 48 static const String enableAsync = 'enableAsync'; | 48 static const String enableAsync = 'enableAsync'; |
| 49 static const String enableGenericMethods = 'enableGenericMethods'; | 49 static const String enableGenericMethods = 'enableGenericMethods'; |
| 50 static const String enableStrictCallChecks = 'enableStrictCallChecks'; | 50 static const String enableStrictCallChecks = 'enableStrictCallChecks'; |
| 51 static const String enableSuperMixins = 'enableSuperMixins'; | 51 static const String enableSuperMixins = 'enableSuperMixins'; |
| 52 static const String enableTrailingCommas = 'enableTrailingCommas'; | |
| 53 | 52 |
| 54 static const String errors = 'errors'; | 53 static const String errors = 'errors'; |
| 55 static const String exclude = 'exclude'; | 54 static const String exclude = 'exclude'; |
| 56 static const String language = 'language'; | 55 static const String language = 'language'; |
| 57 static const String plugins = 'plugins'; | 56 static const String plugins = 'plugins'; |
| 58 static const String strong_mode = 'strong-mode'; | 57 static const String strong_mode = 'strong-mode'; |
| 59 | 58 |
| 60 // Strong mode options, see AnalysisOptionsImpl for documentation. | 59 // Strong mode options, see AnalysisOptionsImpl for documentation. |
| 61 static const String implicitCasts = 'implicit-casts'; | 60 static const String implicitCasts = 'implicit-casts'; |
| 62 static const String implicitDynamic = 'implicit-dynamic'; | 61 static const String implicitDynamic = 'implicit-dynamic'; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 81 language, | 80 language, |
| 82 plugins, | 81 plugins, |
| 83 strong_mode | 82 strong_mode |
| 84 ]; | 83 ]; |
| 85 | 84 |
| 86 /// Supported `analyzer` language configuration options. | 85 /// Supported `analyzer` language configuration options. |
| 87 static const List<String> languageOptions = const [ | 86 static const List<String> languageOptions = const [ |
| 88 enableAsync, | 87 enableAsync, |
| 89 enableGenericMethods, | 88 enableGenericMethods, |
| 90 enableStrictCallChecks, | 89 enableStrictCallChecks, |
| 91 enableSuperMixins, | 90 enableSuperMixins |
| 92 enableTrailingCommas | |
| 93 ]; | 91 ]; |
| 94 } | 92 } |
| 95 | 93 |
| 96 /// Validates `analyzer` options. | 94 /// Validates `analyzer` options. |
| 97 class AnalyzerOptionsValidator extends CompositeValidator { | 95 class AnalyzerOptionsValidator extends CompositeValidator { |
| 98 AnalyzerOptionsValidator() | 96 AnalyzerOptionsValidator() |
| 99 : super([ | 97 : super([ |
| 100 new TopLevelAnalyzerOptionsValidator(), | 98 new TopLevelAnalyzerOptionsValidator(), |
| 101 new StrongModeOptionValueValidator(), | 99 new StrongModeOptionValueValidator(), |
| 102 new ErrorFilterOptionValidator(), | 100 new ErrorFilterOptionValidator(), |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 } | 495 } |
| 498 } | 496 } |
| 499 if (feature == AnalyzerOptions.enableSuperMixins) { | 497 if (feature == AnalyzerOptions.enableSuperMixins) { |
| 500 if (isTrue(value)) { | 498 if (isTrue(value)) { |
| 501 AnalysisOptionsImpl options = | 499 AnalysisOptionsImpl options = |
| 502 new AnalysisOptionsImpl.from(context.analysisOptions); | 500 new AnalysisOptionsImpl.from(context.analysisOptions); |
| 503 options.enableSuperMixins = true; | 501 options.enableSuperMixins = true; |
| 504 context.analysisOptions = options; | 502 context.analysisOptions = options; |
| 505 } | 503 } |
| 506 } | 504 } |
| 507 if (feature == AnalyzerOptions.enableTrailingCommas) { | |
| 508 if (isTrue(value)) { | |
| 509 AnalysisOptionsImpl options = | |
| 510 new AnalysisOptionsImpl.from(context.analysisOptions); | |
| 511 options.enableTrailingCommas = true; | |
| 512 context.analysisOptions = options; | |
| 513 } | |
| 514 } | |
| 515 if (feature == AnalyzerOptions.enableGenericMethods) { | 505 if (feature == AnalyzerOptions.enableGenericMethods) { |
| 516 if (isTrue(value)) { | 506 if (isTrue(value)) { |
| 517 AnalysisOptionsImpl options = | 507 AnalysisOptionsImpl options = |
| 518 new AnalysisOptionsImpl.from(context.analysisOptions); | 508 new AnalysisOptionsImpl.from(context.analysisOptions); |
| 519 options.enableGenericMethods = true; | 509 options.enableGenericMethods = true; |
| 520 context.analysisOptions = options; | 510 context.analysisOptions = options; |
| 521 } | 511 } |
| 522 } | 512 } |
| 523 } | 513 } |
| 524 | 514 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 } | 600 } |
| 611 }); | 601 }); |
| 612 } else if (config is Map) { | 602 } else if (config is Map) { |
| 613 options.strongMode = true; | 603 options.strongMode = true; |
| 614 config.forEach((k, v) => _applyStrongModeOption(options, k, v)); | 604 config.forEach((k, v) => _applyStrongModeOption(options, k, v)); |
| 615 } else { | 605 } else { |
| 616 options.strongMode = config is bool ? config : false; | 606 options.strongMode = config is bool ? config : false; |
| 617 } | 607 } |
| 618 } | 608 } |
| 619 } | 609 } |
| OLD | NEW |