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

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

Issue 1234293003: Make analysis_server use ignore patterns from .analysis_options file (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 months 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/analysis_server/test/context_manager_test.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:core' hide Resource; 9 import 'dart:core' hide Resource;
10 10
11 import 'package:analysis_server/src/analysis_server.dart'; 11 import 'package:analysis_server/src/analysis_server.dart';
12 import 'package:analysis_server/src/source/optimizing_pub_package_map_provider.d art'; 12 import 'package:analysis_server/src/source/optimizing_pub_package_map_provider.d art';
13 import 'package:analysis_server/uri/resolver_provider.dart'; 13 import 'package:analysis_server/uri/resolver_provider.dart';
14 import 'package:analyzer/file_system/file_system.dart'; 14 import 'package:analyzer/file_system/file_system.dart';
15 import 'package:analyzer/instrumentation/instrumentation.dart'; 15 import 'package:analyzer/instrumentation/instrumentation.dart';
16 import 'package:analyzer/source/analysis_options_provider.dart';
16 import 'package:analyzer/source/package_map_resolver.dart'; 17 import 'package:analyzer/source/package_map_resolver.dart';
17 import 'package:analyzer/source/path_filter.dart'; 18 import 'package:analyzer/source/path_filter.dart';
18 import 'package:analyzer/src/generated/engine.dart'; 19 import 'package:analyzer/src/generated/engine.dart';
19 import 'package:analyzer/src/generated/java_io.dart'; 20 import 'package:analyzer/src/generated/java_io.dart';
20 import 'package:analyzer/src/generated/source.dart'; 21 import 'package:analyzer/src/generated/source.dart';
21 import 'package:analyzer/src/generated/source_io.dart'; 22 import 'package:analyzer/src/generated/source_io.dart';
22 import 'package:path/path.dart' as pathos; 23 import 'package:path/path.dart' as pathos;
23 import 'package:watcher/watcher.dart'; 24 import 'package:watcher/watcher.dart';
25 import 'package:yaml/yaml.dart';
24 26
25 /** 27 /**
26 * Class that maintains a mapping from included/excluded paths to a set of 28 * Class that maintains a mapping from included/excluded paths to a set of
27 * folders that should correspond to analysis contexts. 29 * folders that should correspond to analysis contexts.
28 */ 30 */
29 abstract class AbstractContextManager implements ContextManager { 31 abstract class AbstractContextManager implements ContextManager {
30 /** 32 /**
31 * The name of the `lib` directory. 33 * The name of the `lib` directory.
32 */ 34 */
33 static const String LIB_DIR_NAME = 'lib'; 35 static const String LIB_DIR_NAME = 'lib';
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 * to the standard URI resolver. 89 * to the standard URI resolver.
88 */ 90 */
89 final ResolverProvider packageResolverProvider; 91 final ResolverProvider packageResolverProvider;
90 92
91 /** 93 /**
92 * Provider which is used to determine the mapping from package name to 94 * Provider which is used to determine the mapping from package name to
93 * package folder. 95 * package folder.
94 */ 96 */
95 final OptimizingPubPackageMapProvider _packageMapProvider; 97 final OptimizingPubPackageMapProvider _packageMapProvider;
96 98
99 /// Provider of analysis options.
100 AnalysisOptionsProvider analysisOptionsProvider =
101 new AnalysisOptionsProvider();
102
97 /** 103 /**
98 * The instrumentation service used to report instrumentation data. 104 * The instrumentation service used to report instrumentation data.
99 */ 105 */
100 final InstrumentationService _instrumentationService; 106 final InstrumentationService _instrumentationService;
101 107
102 AbstractContextManager(this.resourceProvider, this.packageResolverProvider, 108 AbstractContextManager(this.resourceProvider, this.packageResolverProvider,
103 this._packageMapProvider, this._instrumentationService) { 109 this._packageMapProvider, this._instrumentationService) {
104 pathContext = resourceProvider.pathContext; 110 pathContext = resourceProvider.pathContext;
105 } 111 }
106 112
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 return contexts; 163 return contexts;
158 } 164 }
159 165
160 /** 166 /**
161 * We have finished computing the package map. 167 * We have finished computing the package map.
162 */ 168 */
163 void endComputePackageMap() { 169 void endComputePackageMap() {
164 // Do nothing. 170 // Do nothing.
165 } 171 }
166 172
167 // Sets the [ignorePatterns] for the context [folder]. 173 /// Sets the [ignorePatterns] for the context [folder].
168 void setIgnorePatternsForContext(Folder folder, List<String> ignorePatterns) { 174 void setIgnorePatternsForContext(Folder folder, List<String> ignorePatterns) {
169 _ContextInfo info = _contexts[folder]; 175 _ContextInfo info = _contexts[folder];
170 if (info == null) { 176 if (info == null) {
171 return; 177 return;
172 } 178 }
173 var pathFilter = info.pathFilter; 179 var pathFilter = info.pathFilter;
174 pathFilter.setIgnorePatterns(ignorePatterns); 180 pathFilter.setIgnorePatterns(ignorePatterns);
175 } 181 }
176 182
183 /// Process [options] for the context [folder].
184 void processOptionsForContext(Folder folder, Map<String, YamlNode> options) {
185 _ContextInfo info = _contexts[folder];
186 if (info == null) {
187 return;
188 }
189 YamlMap analyzer = options['analyzer'];
190 if (analyzer == null) {
191 // No options for analyzer.
192 return;
193 }
194
195 // Set ignore patterns.
196 YamlList exclude = analyzer['exclude'];
197 if (exclude != null) {
198 setIgnorePatternsForContext(folder, exclude);
199 }
200 }
201
177 @override 202 @override
178 bool isInAnalysisRoot(String path) { 203 bool isInAnalysisRoot(String path) {
179 // check if excluded 204 // check if excluded
180 if (_isExcluded(path)) { 205 if (_isExcluded(path)) {
181 return false; 206 return false;
182 } 207 }
183 // check if in of the roots 208 // check if in of the roots
184 for (Folder root in _contexts.keys) { 209 for (Folder root in _contexts.keys) {
185 if (root.contains(path)) { 210 if (root.contains(path)) {
186 return true; 211 return true;
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 } 508 }
484 509
485 /** 510 /**
486 * Create a new empty context associated with [folder]. 511 * Create a new empty context associated with [folder].
487 */ 512 */
488 _ContextInfo _createContext( 513 _ContextInfo _createContext(
489 Folder folder, File pubspecFile, List<_ContextInfo> children) { 514 Folder folder, File pubspecFile, List<_ContextInfo> children) {
490 _ContextInfo info = new _ContextInfo( 515 _ContextInfo info = new _ContextInfo(
491 folder, pubspecFile, children, normalizedPackageRoots[folder.path]); 516 folder, pubspecFile, children, normalizedPackageRoots[folder.path]);
492 _contexts[folder] = info; 517 _contexts[folder] = info;
518 try {
519 var options = analysisOptionsProvider.getOptions(folder);
520 processOptionsForContext(folder, options);
521 } catch (_) {
522 rethrow;
523 }
493 info.changeSubscription = folder.changes.listen((WatchEvent event) { 524 info.changeSubscription = folder.changes.listen((WatchEvent event) {
494 _handleWatchEvent(folder, info, event); 525 _handleWatchEvent(folder, info, event);
495 }); 526 });
496 try { 527 try {
497 UriResolver packageUriResolver = _computePackageUriResolver(folder, info); 528 UriResolver packageUriResolver = _computePackageUriResolver(folder, info);
498 info.context = addContext(folder, packageUriResolver); 529 info.context = addContext(folder, packageUriResolver);
499 info.context.name = folder.path; 530 info.context.name = folder.path;
500 } catch (_) { 531 } catch (_) {
501 info.changeSubscription.cancel(); 532 info.changeSubscription.cancel();
502 rethrow; 533 rethrow;
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 return excludes(resource.path); 995 return excludes(resource.path);
965 } 996 }
966 997
967 /** 998 /**
968 * Returns `true` if [path] is the pubspec file of this context. 999 * Returns `true` if [path] is the pubspec file of this context.
969 */ 1000 */
970 bool isPubspec(String path) { 1001 bool isPubspec(String path) {
971 return path == pubspecPath; 1002 return path == pubspecPath;
972 } 1003 }
973 } 1004 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/test/context_manager_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698