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

Side by Side Diff: pkg/analysis_server/lib/src/context_manager.dart

Issue 2536303002: Exclude files from analysis when using AnalysisDriver (Closed)
Patch Set: clean-up Created 4 years 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 | pkg/analyzer/lib/src/generated/engine.dart » ('j') | 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) 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
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/engine.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698