OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 context.directory.manager; | 5 library context.directory.manager; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 import 'dart:convert'; | 9 import 'dart:convert'; |
10 import 'dart:core'; | 10 import 'dart:core'; |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 // Set ignore patterns. | 669 // Set ignore patterns. |
670 YamlList exclude = analyzer[AnalyzerOptions.exclude]; | 670 YamlList exclude = analyzer[AnalyzerOptions.exclude]; |
671 List<String> excludeList = toStringList(exclude); | 671 List<String> excludeList = toStringList(exclude); |
672 if (excludeList != null) { | 672 if (excludeList != null) { |
673 setIgnorePatternsForContext(info, excludeList); | 673 setIgnorePatternsForContext(info, excludeList); |
674 } | 674 } |
675 } | 675 } |
676 } | 676 } |
677 | 677 |
678 /** | 678 /** |
| 679 * Process [options] for the given context [info]. |
| 680 */ |
| 681 void processOptionsForDriver(ContextInfo info, Map<String, Object> options, |
| 682 {bool optionsRemoved: false}) { |
| 683 if (options == null && !optionsRemoved) { |
| 684 return; |
| 685 } |
| 686 AnalysisOptions analysisOptions = info.analysisDriver.analysisOptions; |
| 687 |
| 688 // In case options files are removed, revert to defaults. |
| 689 if (optionsRemoved) { |
| 690 // Start with defaults. |
| 691 analysisOptions.resetToDefaults(); |
| 692 |
| 693 // Apply inherited options. |
| 694 options = _toStringMap(_getEmbeddedOptions(info)); |
| 695 if (options != null) { |
| 696 applyToAnalysisOptions(analysisOptions, options); |
| 697 } |
| 698 } else { |
| 699 // Check for embedded options. |
| 700 Map embeddedOptions = _getEmbeddedOptions(info); |
| 701 if (embeddedOptions != null) { |
| 702 options = _toStringMap(new Merger().merge(embeddedOptions, options)); |
| 703 } |
| 704 } |
| 705 |
| 706 // TODO(brianwilkerson) Figure out what to do here. |
| 707 // // Notify options processors. |
| 708 // AnalysisEngine.instance.optionsPlugin.optionsProcessors |
| 709 // .forEach((OptionsProcessor p) { |
| 710 // try { |
| 711 // p.optionsProcessed(info.context, options); |
| 712 // } catch (e, stacktrace) { |
| 713 // AnalysisEngine.instance.logger.logError( |
| 714 // 'Error processing analysis options', |
| 715 // new CaughtException(e, stacktrace)); |
| 716 // } |
| 717 // }); |
| 718 |
| 719 applyToAnalysisOptions(analysisOptions, options); |
| 720 |
| 721 // Nothing more to do. |
| 722 if (options == null) { |
| 723 return; |
| 724 } |
| 725 |
| 726 var analyzer = options[AnalyzerOptions.analyzer]; |
| 727 if (analyzer is Map) { |
| 728 // Set ignore patterns. |
| 729 YamlList exclude = analyzer[AnalyzerOptions.exclude]; |
| 730 List<String> excludeList = toStringList(exclude); |
| 731 if (excludeList != null) { |
| 732 setIgnorePatternsForContext(info, excludeList); |
| 733 } |
| 734 } |
| 735 } |
| 736 |
| 737 /** |
679 * Return the options from the analysis options file in the given [folder] | 738 * Return the options from the analysis options file in the given [folder] |
680 * if exists, or in one of the parent folders, or `null` if no analysis | 739 * if exists, or in one of the parent folders, or `null` if no analysis |
681 * options file is found or if the contents of the file are not valid YAML. | 740 * options file is found or if the contents of the file are not valid YAML. |
682 */ | 741 */ |
683 Map<String, Object> readOptions(Folder folder, Packages packages) { | 742 Map<String, Object> readOptions(Folder folder, Packages packages) { |
684 try { | 743 try { |
685 Map<String, List<Folder>> packageMap = | 744 Map<String, List<Folder>> packageMap = |
686 new ContextBuilder(resourceProvider, null, null) | 745 new ContextBuilder(resourceProvider, null, null) |
687 .convertPackagesToMap(packages); | 746 .convertPackagesToMap(packages); |
688 List<UriResolver> resolvers = <UriResolver>[ | 747 List<UriResolver> resolvers = <UriResolver>[ |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1098 } | 1157 } |
1099 } | 1158 } |
1100 if (pubspec == null) { | 1159 if (pubspec == null) { |
1101 Resource child = folder.getChild(PUBSPEC_NAME); | 1160 Resource child = folder.getChild(PUBSPEC_NAME); |
1102 if (child.exists && child is File) { | 1161 if (child.exists && child is File) { |
1103 pubspec = child; | 1162 pubspec = child; |
1104 } | 1163 } |
1105 } | 1164 } |
1106 | 1165 |
1107 if (enableNewAnalysisDriver) { | 1166 if (enableNewAnalysisDriver) { |
1108 // TODO(scheglov) implement for the new analysis driver | 1167 processOptionsForDriver(info, optionMap); |
1109 } else { | 1168 } else { |
1110 processOptionsForContext(info, optionMap); | 1169 processOptionsForContext(info, optionMap); |
1111 } | 1170 } |
1112 | 1171 |
1113 return info; | 1172 return info; |
1114 } | 1173 } |
1115 | 1174 |
1116 /** | 1175 /** |
1117 * Potentially create a new context associated with the given [folder]. | 1176 * Potentially create a new context associated with the given [folder]. |
1118 * | 1177 * |
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1867 } | 1926 } |
1868 return _embedderLocator; | 1927 return _embedderLocator; |
1869 } | 1928 } |
1870 | 1929 |
1871 @override | 1930 @override |
1872 SdkExtensionFinder getSdkExtensionFinder(ResourceProvider resourceProvider) { | 1931 SdkExtensionFinder getSdkExtensionFinder(ResourceProvider resourceProvider) { |
1873 return _sdkExtensionFinder ??= | 1932 return _sdkExtensionFinder ??= |
1874 new SdkExtensionFinder(buildPackageMap(resourceProvider)); | 1933 new SdkExtensionFinder(buildPackageMap(resourceProvider)); |
1875 } | 1934 } |
1876 } | 1935 } |
OLD | NEW |