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'; |
11 import 'package:analyzer/source/analysis_options_provider.dart'; | 11 import 'package:analyzer/source/analysis_options_provider.dart'; |
12 import 'package:analyzer/source/error_processor.dart'; | 12 import 'package:analyzer/source/error_processor.dart'; |
13 import 'package:analyzer/src/context/context.dart'; | |
14 import 'package:analyzer/src/generated/engine.dart'; | 13 import 'package:analyzer/src/generated/engine.dart'; |
15 import 'package:analyzer/src/generated/java_engine.dart'; | 14 import 'package:analyzer/src/generated/java_engine.dart'; |
16 import 'package:analyzer/src/generated/source.dart'; | 15 import 'package:analyzer/src/generated/source.dart'; |
17 import 'package:analyzer/src/generated/utilities_general.dart'; | 16 import 'package:analyzer/src/generated/utilities_general.dart'; |
18 import 'package:analyzer/src/task/general.dart'; | 17 import 'package:analyzer/src/task/general.dart'; |
19 import 'package:analyzer/src/util/yaml.dart'; | 18 import 'package:analyzer/src/util/yaml.dart'; |
20 import 'package:analyzer/task/general.dart'; | 19 import 'package:analyzer/task/general.dart'; |
21 import 'package:analyzer/task/model.dart'; | 20 import 'package:analyzer/task/model.dart'; |
22 import 'package:source_span/source_span.dart'; | 21 import 'package:source_span/source_span.dart'; |
23 import 'package:yaml/yaml.dart'; | 22 import 'package:yaml/yaml.dart'; |
24 | 23 |
25 /// The errors produced while parsing an analysis options file. | 24 /// The errors produced while parsing an analysis options file. |
26 /// | 25 /// |
27 /// The list will be empty if there were no errors, but will not be `null`. | 26 /// The list will be empty if there were no errors, but will not be `null`. |
28 final ListResultDescriptor<AnalysisError> ANALYSIS_OPTIONS_ERRORS = | 27 final ListResultDescriptor<AnalysisError> ANALYSIS_OPTIONS_ERRORS = |
29 new ListResultDescriptor<AnalysisError>( | 28 new ListResultDescriptor<AnalysisError>( |
30 'ANALYSIS_OPTIONS_ERRORS', AnalysisError.NO_ERRORS); | 29 'ANALYSIS_OPTIONS_ERRORS', AnalysisError.NO_ERRORS); |
31 | 30 |
32 /** | |
33 * The descriptor used to associate error processors with analysis contexts in | |
34 * configuration data. | |
35 */ | |
36 final ListResultDescriptor<ErrorProcessor> CONFIGURED_ERROR_PROCESSORS = | |
37 new ListResultDescriptor<ErrorProcessor>( | |
38 'configured.errors', const <ErrorProcessor>[]); | |
39 | |
40 final _OptionsProcessor _processor = new _OptionsProcessor(); | 31 final _OptionsProcessor _processor = new _OptionsProcessor(); |
41 | 32 |
42 void applyToAnalysisOptions( | 33 void applyToAnalysisOptions( |
43 AnalysisOptionsImpl options, Map<String, Object> optionMap) { | 34 AnalysisOptionsImpl options, Map<String, Object> optionMap) { |
44 _processor.applyToAnalysisOptions(options, optionMap); | 35 _processor.applyToAnalysisOptions(options, optionMap); |
45 } | 36 } |
46 | 37 |
47 /// Configure this [context] based on configuration details specified in | 38 /// Configure this [context] based on configuration details specified in |
48 /// the given [options]. If [options] is `null`, default values are applied. | 39 /// the given [options]. If [options] is `null`, default values are applied. |
49 void configureContextOptions( | 40 void configureContextOptions( |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 // Process excludes. | 531 // Process excludes. |
541 var excludes = analyzer[AnalyzerOptions.exclude]; | 532 var excludes = analyzer[AnalyzerOptions.exclude]; |
542 setExcludes(context, excludes); | 533 setExcludes(context, excludes); |
543 } | 534 } |
544 } | 535 } |
545 | 536 |
546 void setExcludes(AnalysisContext context, Object excludes) { | 537 void setExcludes(AnalysisContext context, Object excludes) { |
547 if (excludes is YamlList) { | 538 if (excludes is YamlList) { |
548 List<String> excludeList = toStringList(excludes); | 539 List<String> excludeList = toStringList(excludes); |
549 if (excludeList != null) { | 540 if (excludeList != null) { |
550 context.setConfigurationData(CONTEXT_EXCLUDES, excludeList); | 541 AnalysisOptionsImpl options = |
| 542 new AnalysisOptionsImpl.from(context.analysisOptions); |
| 543 options.excludePatterns = excludeList; |
| 544 context.analysisOptions = options; |
551 } | 545 } |
552 } | 546 } |
553 } | 547 } |
554 | 548 |
555 void setLanguageOption( | 549 void setLanguageOption( |
556 AnalysisContext context, Object feature, Object value) { | 550 AnalysisContext context, Object feature, Object value) { |
557 if (feature == AnalyzerOptions.enableAssertInitializer) { | 551 if (feature == AnalyzerOptions.enableAssertInitializer) { |
558 if (isTrue(value)) { | 552 if (isTrue(value)) { |
559 AnalysisOptionsImpl options = | 553 AnalysisOptionsImpl options = |
560 new AnalysisOptionsImpl.from(context.analysisOptions); | 554 new AnalysisOptionsImpl.from(context.analysisOptions); |
(...skipping 27 matching lines...) Expand all Loading... |
588 setLanguageOption(context, feature, v.value); | 582 setLanguageOption(context, feature, v.value); |
589 } | 583 } |
590 }); | 584 }); |
591 } else if (configs is Map) { | 585 } else if (configs is Map) { |
592 configs.forEach((k, v) => setLanguageOption(context, k, v)); | 586 configs.forEach((k, v) => setLanguageOption(context, k, v)); |
593 } | 587 } |
594 } | 588 } |
595 | 589 |
596 void setProcessors(AnalysisContext context, Object codes) { | 590 void setProcessors(AnalysisContext context, Object codes) { |
597 ErrorConfig config = new ErrorConfig(codes); | 591 ErrorConfig config = new ErrorConfig(codes); |
598 context.setConfigurationData( | 592 AnalysisOptionsImpl options = |
599 CONFIGURED_ERROR_PROCESSORS, config.processors); | 593 new AnalysisOptionsImpl.from(context.analysisOptions); |
| 594 options.errorProcessors = config.processors; |
| 595 context.analysisOptions = options; |
600 } | 596 } |
601 | 597 |
602 void setStrongMode(AnalysisContext context, Object strongMode) { | 598 void setStrongMode(AnalysisContext context, Object strongMode) { |
603 if (strongMode is Map) { | 599 if (strongMode is Map) { |
604 AnalysisOptionsImpl options = | 600 AnalysisOptionsImpl options = |
605 new AnalysisOptionsImpl.from(context.analysisOptions); | 601 new AnalysisOptionsImpl.from(context.analysisOptions); |
606 _applyStrongOptions(options, strongMode); | 602 _applyStrongOptions(options, strongMode); |
607 context.analysisOptions = options; | 603 context.analysisOptions = options; |
608 } else { | 604 } else { |
609 strongMode = strongMode is bool ? strongMode : false; | 605 strongMode = strongMode is bool ? strongMode : false; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 } | 662 } |
667 }); | 663 }); |
668 } else if (config is Map) { | 664 } else if (config is Map) { |
669 options.strongMode = true; | 665 options.strongMode = true; |
670 config.forEach((k, v) => _applyStrongModeOption(options, k, v)); | 666 config.forEach((k, v) => _applyStrongModeOption(options, k, v)); |
671 } else { | 667 } else { |
672 options.strongMode = config is bool ? config : false; | 668 options.strongMode = config is bool ? config : false; |
673 } | 669 } |
674 } | 670 } |
675 } | 671 } |
OLD | NEW |