@@ -138,8 +138,8 @@ class DeclarationsContext {
138
138
/// Packages are sorted so that inner packages are before outer.
139
139
final List <_Package > _packages = [];
140
140
141
- /// The list of paths of all files inside the context.
142
- final List <String > _contextPathList = [] ;
141
+ /// The set of paths of all files inside the context.
142
+ final Set <String > _contextPathSet = {} ;
143
143
144
144
/// The list of paths of all SDK libraries.
145
145
final List <String > _sdkLibraryPathList = [];
@@ -210,7 +210,7 @@ class DeclarationsContext {
210
210
_addKnownLibraries (dependencyLibraries);
211
211
}
212
212
213
- var contextPathList = < String > [] ;
213
+ Iterable <String > contextPaths ;
214
214
if (! _analysisContext.contextRoot.workspace.isBlaze) {
215
215
_Package ? package;
216
216
for (var candidatePackage in _packages) {
@@ -221,9 +221,10 @@ class DeclarationsContext {
221
221
}
222
222
223
223
if (package != null ) {
224
+ List <String > contextPathList = contextPaths = [];
224
225
var containingFolder = package.folderInRootContaining (path);
225
226
if (containingFolder != null ) {
226
- for (var contextPath in _contextPathList ) {
227
+ for (var contextPath in _contextPathSet ) {
227
228
// `lib/` can see only libraries in `lib/`.
228
229
// `test/` can see libraries in `lib/` and in `test/`.
229
230
if (package.containsInLib (contextPath) ||
@@ -234,17 +235,17 @@ class DeclarationsContext {
234
235
}
235
236
} else {
236
237
// Not in a package, include all libraries of the context.
237
- contextPathList = _contextPathList ;
238
+ contextPaths = _contextPathSet ;
238
239
}
239
240
} else {
240
241
// In Blaze workspaces, consider declarations from the entire context
241
- contextPathList = _contextPathList ;
242
+ contextPaths = _contextPathSet ;
242
243
}
243
244
244
245
var contextLibraries = < Library > [];
245
246
_addLibrariesWithPaths (
246
247
contextLibraries,
247
- contextPathList ,
248
+ contextPaths ,
248
249
excludingLibraryOfPath: path,
249
250
);
250
251
@@ -291,18 +292,15 @@ class DeclarationsContext {
291
292
}
292
293
293
294
void _addContextFile (String path) {
294
- if (! _contextPathList.contains (path)) {
295
- _contextPathList.add (path);
296
- }
295
+ _contextPathSet.add (path);
297
296
}
298
297
299
298
/// Add known libraries, other then in the context itself, or the SDK.
300
299
void _addKnownLibraries (List <Library > libraries) {
301
- var contextPathSet = _contextPathList.toSet ();
302
300
var sdkPathSet = _sdkLibraryPathList.toSet ();
303
301
304
302
for (var path in _knownPathList) {
305
- if (contextPathSet .contains (path) || sdkPathSet.contains (path)) {
303
+ if (_contextPathSet .contains (path) || sdkPathSet.contains (path)) {
306
304
continue ;
307
305
}
308
306
@@ -316,12 +314,12 @@ class DeclarationsContext {
316
314
}
317
315
}
318
316
319
- void _addLibrariesWithPaths (List <Library > libraries, List <String > pathList ,
317
+ void _addLibrariesWithPaths (List <Library > libraries, Iterable <String > paths ,
320
318
{String ? excludingLibraryOfPath}) {
321
319
var excludedFile = _tracker._pathToFile[excludingLibraryOfPath];
322
320
var excludedLibraryPath = (excludedFile? .library ?? excludedFile)? .path;
323
321
324
- for (var path in pathList ) {
322
+ for (var path in paths ) {
325
323
if (path == excludedLibraryPath) continue ;
326
324
327
325
var file = _tracker._pathToFile[path];
@@ -415,7 +413,7 @@ class DeclarationsContext {
415
413
void _scheduleContextFiles () {
416
414
var contextFiles = _analysisContext.contextRoot.analyzedFiles ();
417
415
for (var path in contextFiles) {
418
- _contextPathList .add (path);
416
+ _contextPathSet .add (path);
419
417
_tracker._addFile (this , path);
420
418
}
421
419
}
0 commit comments