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

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

Issue 1916063003: We don't use path filter in SingleContextManager. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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/single_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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 analysis_server.src.single_context_manager; 5 library analysis_server.src.single_context_manager;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:core' hide Resource; 8 import 'dart:core' hide Resource;
9 import 'dart:math' as math; 9 import 'dart:math' as math;
10 10
11 import 'package:analysis_server/src/context_manager.dart'; 11 import 'package:analysis_server/src/context_manager.dart';
12 import 'package:analyzer/file_system/file_system.dart'; 12 import 'package:analyzer/file_system/file_system.dart';
13 import 'package:analyzer/source/path_filter.dart';
14 import 'package:analyzer/src/generated/engine.dart'; 13 import 'package:analyzer/src/generated/engine.dart';
15 import 'package:analyzer/src/generated/sdk.dart'; 14 import 'package:analyzer/src/generated/sdk.dart';
16 import 'package:analyzer/src/generated/source.dart'; 15 import 'package:analyzer/src/generated/source.dart';
17 import 'package:analyzer/src/util/glob.dart'; 16 import 'package:analyzer/src/util/glob.dart';
18 import 'package:path/path.dart' as path; 17 import 'package:path/path.dart' as path;
19 import 'package:watcher/watcher.dart'; 18 import 'package:watcher/watcher.dart';
20 19
21 /** 20 /**
22 * A function that will return a [UriResolver] that can be used to resolve 21 * A function that will return a [UriResolver] that can be used to resolve
23 * `package:` URIs in [SingleContextManager]. 22 * `package:` URIs in [SingleContextManager].
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 * The folder associated with the context. 93 * The folder associated with the context.
95 */ 94 */
96 Folder contextFolder; 95 Folder contextFolder;
97 96
98 /** 97 /**
99 * The current [contextFolder] watch subscription. 98 * The current [contextFolder] watch subscription.
100 */ 99 */
101 StreamSubscription<WatchEvent> watchSubscription; 100 StreamSubscription<WatchEvent> watchSubscription;
102 101
103 /** 102 /**
104 * The [PathFilter] used to filter sources from being analyzed.
105 */
106 PathFilter pathFilter;
107
108 /**
109 * The [packageResolverProvider] must not be `null`. 103 * The [packageResolverProvider] must not be `null`.
110 */ 104 */
111 SingleContextManager(this.resourceProvider, this.sdkManager, 105 SingleContextManager(this.resourceProvider, this.sdkManager,
112 this.packageResolverProvider, this.analyzedFilesGlobs) { 106 this.packageResolverProvider, this.analyzedFilesGlobs) {
113 pathContext = resourceProvider.pathContext; 107 pathContext = resourceProvider.pathContext;
114 } 108 }
115 109
116 @override 110 @override
117 Iterable<AnalysisContext> get analysisContexts => 111 Iterable<AnalysisContext> get analysisContexts =>
118 context == null ? <AnalysisContext>[] : <AnalysisContext>[context]; 112 context == null ? <AnalysisContext>[] : <AnalysisContext>[context];
(...skipping 13 matching lines...) Expand all
132 AnalysisContext getContextFor(String path) { 126 AnalysisContext getContextFor(String path) {
133 if (context == null) { 127 if (context == null) {
134 return null; 128 return null;
135 } else if (_isContainedIn(includedPaths, path)) { 129 } else if (_isContainedIn(includedPaths, path)) {
136 return context; 130 return context;
137 } 131 }
138 return null; 132 return null;
139 } 133 }
140 134
141 @override 135 @override
142 bool isIgnored(String path) => pathFilter.ignored(path); 136 bool isIgnored(String path) {
137 return !_isContainedIn(includedPaths, path) || _isExcludedPath(path);
138 }
143 139
144 @override 140 @override
145 bool isInAnalysisRoot(String path) { 141 bool isInAnalysisRoot(String path) {
146 return _isContainedIn(includedPaths, path) && 142 return _isContainedIn(includedPaths, path) &&
147 !_isContainedIn(excludedPaths, path); 143 !_isContainedIn(excludedPaths, path);
148 } 144 }
149 145
150 @override 146 @override
151 void refresh(List<Resource> roots) { 147 void refresh(List<Resource> roots) {
152 if (context != null) { 148 if (context != null) {
153 // TODO(brianwilkerson) Not sure whether this is right. 149 // TODO(brianwilkerson) Not sure whether this is right.
154 callbacks.removeContext(contextFolder, null); 150 callbacks.removeContext(contextFolder, null);
155 context.dispose(); 151 context.dispose();
156 context = null; 152 context = null;
157 contextFolder = null; 153 contextFolder = null;
158 pathFilter = null;
159 if (watchSubscription != null) { 154 if (watchSubscription != null) {
160 watchSubscription.cancel(); 155 watchSubscription.cancel();
161 watchSubscription = null; 156 watchSubscription = null;
162 } 157 }
163 setRoots(includedPaths, excludedPaths, packageRoots); 158 setRoots(includedPaths, excludedPaths, packageRoots);
164 } 159 }
165 } 160 }
166 161
167 @override 162 @override
168 void setRoots(List<String> includedPaths, List<String> excludedPaths, 163 void setRoots(List<String> includedPaths, List<String> excludedPaths,
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 static List<Resource> _getChildrenSafe(Folder folder) { 474 static List<Resource> _getChildrenSafe(Folder folder) {
480 try { 475 try {
481 return folder.getChildren(); 476 return folder.getChildren();
482 } on FileSystemException { 477 } on FileSystemException {
483 // The folder either doesn't exist or cannot be read. 478 // The folder either doesn't exist or cannot be read.
484 // Either way, there are no children. 479 // Either way, there are no children.
485 return const <Resource>[]; 480 return const <Resource>[];
486 } 481 }
487 } 482 }
488 } 483 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/test/single_context_manager_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698