Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(608)

Side by Side Diff: pkg/analyzer/lib/src/task/options.dart

Issue 2523833002: Respect the rest of the analysis-based options (issue 27868) (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 AnalysisOptionsImpl options, Map<String, Object> optionMap) { 494 AnalysisOptionsImpl options, Map<String, Object> optionMap) {
495 if (optionMap == null) { 495 if (optionMap == null) {
496 return; 496 return;
497 } 497 }
498 var analyzer = optionMap[AnalyzerOptions.analyzer]; 498 var analyzer = optionMap[AnalyzerOptions.analyzer];
499 if (analyzer is Map) { 499 if (analyzer is Map) {
500 // Process strong mode option. 500 // Process strong mode option.
501 var strongMode = analyzer[AnalyzerOptions.strong_mode]; 501 var strongMode = analyzer[AnalyzerOptions.strong_mode];
502 _applyStrongOptions(options, strongMode); 502 _applyStrongOptions(options, strongMode);
503 503
504 // Set filters.
505 var filters = analyzer[AnalyzerOptions.errors];
506 _applyProcessors(options, filters);
507
504 // Process language options. 508 // Process language options.
505 var language = analyzer[AnalyzerOptions.language]; 509 var language = analyzer[AnalyzerOptions.language];
506 _applyLanguageOptions(options, language); 510 _applyLanguageOptions(options, language);
511
512 // Process excludes.
513 var excludes = analyzer[AnalyzerOptions.exclude];
514 _applyExcludes(options, excludes);
507 } 515 }
508 } 516 }
509 517
510 /// Configure [context] based on the given [options] (which can be `null` 518 /// Configure [context] based on the given [options] (which can be `null`
511 /// to restore [defaults]). 519 /// to restore [defaults]).
512 void configure(AnalysisContext context, Map<String, Object> options) { 520 void configure(AnalysisContext context, Map<String, Object> options) {
513 if (options == null) { 521 if (options == null) {
514 options = defaults; 522 options = defaults;
515 } 523 }
516 524
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 strongMode = strongMode is bool ? strongMode : false; 613 strongMode = strongMode is bool ? strongMode : false;
606 if (context.analysisOptions.strongMode != strongMode) { 614 if (context.analysisOptions.strongMode != strongMode) {
607 AnalysisOptionsImpl options = 615 AnalysisOptionsImpl options =
608 new AnalysisOptionsImpl.from(context.analysisOptions); 616 new AnalysisOptionsImpl.from(context.analysisOptions);
609 options.strongMode = strongMode; 617 options.strongMode = strongMode;
610 context.analysisOptions = options; 618 context.analysisOptions = options;
611 } 619 }
612 } 620 }
613 } 621 }
614 622
623 void _applyExcludes(AnalysisOptionsImpl options, Object excludes) {
624 if (excludes is YamlList) {
625 List<String> excludeList = toStringList(excludes);
626 if (excludeList != null) {
627 options.excludePatterns = excludeList;
628 }
629 }
630 }
631
615 void _applyLanguageOption( 632 void _applyLanguageOption(
616 AnalysisOptionsImpl options, Object feature, Object value) { 633 AnalysisOptionsImpl options, Object feature, Object value) {
617 bool boolValue = toBool(value); 634 bool boolValue = toBool(value);
618 if (boolValue != null) { 635 if (boolValue != null) {
619 if (feature == AnalyzerOptions.enableAssertInitializer) { 636 if (feature == AnalyzerOptions.enableAssertInitializer) {
620 options.enableAssertInitializer = boolValue; 637 options.enableAssertInitializer = boolValue;
621 } else if (feature == AnalyzerOptions.enableInitializingFormalAccess) { 638 } else if (feature == AnalyzerOptions.enableInitializingFormalAccess) {
622 options.enableInitializingFormalAccess = boolValue; 639 options.enableInitializingFormalAccess = boolValue;
623 } else if (feature == AnalyzerOptions.enableSuperMixins) { 640 } else if (feature == AnalyzerOptions.enableSuperMixins) {
624 options.enableSuperMixins = boolValue; 641 options.enableSuperMixins = boolValue;
625 } 642 }
626 } 643 }
627 } 644 }
628 645
629 void _applyLanguageOptions(AnalysisOptionsImpl options, Object configs) { 646 void _applyLanguageOptions(AnalysisOptionsImpl options, Object configs) {
630 if (configs is YamlMap) { 647 if (configs is YamlMap) {
631 configs.nodes.forEach((key, value) { 648 configs.nodes.forEach((key, value) {
632 if (key is YamlScalar && value is YamlScalar) { 649 if (key is YamlScalar && value is YamlScalar) {
633 String feature = key.value?.toString(); 650 String feature = key.value?.toString();
634 _applyLanguageOption(options, feature, value.value); 651 _applyLanguageOption(options, feature, value.value);
635 } 652 }
636 }); 653 });
637 } else if (configs is Map) { 654 } else if (configs is Map) {
638 configs 655 configs
639 .forEach((key, value) => _applyLanguageOption(options, key, value)); 656 .forEach((key, value) => _applyLanguageOption(options, key, value));
640 } 657 }
641 } 658 }
642 659
660 void _applyProcessors(AnalysisOptionsImpl options, Object codes) {
661 ErrorConfig config = new ErrorConfig(codes);
662 options.errorProcessors = config.processors;
663 }
664
643 void _applyStrongModeOption( 665 void _applyStrongModeOption(
644 AnalysisOptionsImpl options, Object feature, Object value) { 666 AnalysisOptionsImpl options, Object feature, Object value) {
645 bool boolValue = toBool(value); 667 bool boolValue = toBool(value);
646 if (boolValue != null) { 668 if (boolValue != null) {
647 if (feature == AnalyzerOptions.implicitCasts) { 669 if (feature == AnalyzerOptions.implicitCasts) {
648 options.implicitCasts = boolValue; 670 options.implicitCasts = boolValue;
649 } 671 }
650 if (feature == AnalyzerOptions.implicitDynamic) { 672 if (feature == AnalyzerOptions.implicitDynamic) {
651 options.implicitDynamic = boolValue; 673 options.implicitDynamic = boolValue;
652 } 674 }
653 } 675 }
654 } 676 }
655 677
656 void _applyStrongOptions(AnalysisOptionsImpl options, Object config) { 678 void _applyStrongOptions(AnalysisOptionsImpl options, Object config) {
657 if (config is YamlMap) { 679 if (config is YamlMap) {
658 options.strongMode = true; 680 options.strongMode = true;
659 config.nodes.forEach((k, v) { 681 config.nodes.forEach((k, v) {
660 if (k is YamlScalar && v is YamlScalar) { 682 if (k is YamlScalar && v is YamlScalar) {
661 _applyStrongModeOption(options, k.value?.toString(), v.value); 683 _applyStrongModeOption(options, k.value?.toString(), v.value);
662 } 684 }
663 }); 685 });
664 } else if (config is Map) { 686 } else if (config is Map) {
665 options.strongMode = true; 687 options.strongMode = true;
666 config.forEach((k, v) => _applyStrongModeOption(options, k, v)); 688 config.forEach((k, v) => _applyStrongModeOption(options, k, v));
667 } else { 689 } else {
668 options.strongMode = config is bool ? config : false; 690 options.strongMode = config is bool ? config : false;
669 } 691 }
670 } 692 }
671 } 693 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698