@@ -32,37 +32,25 @@ import 'package:meta/meta.dart';
32
32
import 'package:path/path.dart' ;
33
33
import 'package:yaml/yaml.dart' ;
34
34
35
- /**
36
- * An implementation of a context locator.
37
- */
35
+ /// An implementation of a context locator.
38
36
class ContextLocatorImpl implements ContextLocator {
39
- /**
40
- * The name of the analysis options file.
41
- */
37
+ /// The name of the analysis options file.
42
38
static const String ANALYSIS_OPTIONS_NAME = 'analysis_options.yaml' ;
43
39
44
- /**
45
- * The name of the packages file.
46
- */
40
+ /// The name of the packages file.
47
41
static const String PACKAGES_FILE_NAME = '.packages' ;
48
42
49
- /**
50
- * The resource provider used to access the file system.
51
- */
43
+ /// The resource provider used to access the file system.
52
44
final ResourceProvider resourceProvider;
53
45
54
- /**
55
- * Initialize a newly created context locator. If a [resourceProvider] is
56
- * supplied, it will be used to access the file system. Otherwise the default
57
- * resource provider will be used.
58
- */
46
+ /// Initialize a newly created context locator. If a [resourceProvider] is
47
+ /// supplied, it will be used to access the file system. Otherwise the default
48
+ /// resource provider will be used.
59
49
ContextLocatorImpl ({ResourceProvider resourceProvider})
60
50
: this .resourceProvider =
61
51
resourceProvider ?? PhysicalResourceProvider .INSTANCE ;
62
52
63
- /**
64
- * Return the path to the default location of the SDK.
65
- */
53
+ /// Return the path to the default location of the SDK.
66
54
String get _defaultSdkPath =>
67
55
FolderBasedDartSdk .defaultSdkDirectory (resourceProvider).path;
68
56
@@ -189,26 +177,23 @@ class ContextLocatorImpl implements ContextLocator {
189
177
return roots;
190
178
}
191
179
192
- /**
193
- * Return `true` if the given [resource] is contained in one or more of the
194
- * given [folders] .
195
- */
180
+ /// Return `true` if the given [resource] is contained in one or more of the
181
+ /// given [folders] .
196
182
bool _containedInAny (Iterable <Folder > folders, Resource resource) =>
197
183
folders.any ((Folder folder) => folder.contains (resource.path));
198
184
199
- /**
200
- * If the given [folder] should be the root of a new analysis context, then
201
- * create a new context root for it and add it to the list of context [roots] .
202
- * The [containingRoot] is the context root from an enclosing directory and is
203
- * used to inherit configuration information that isn't overridden.
204
- *
205
- * If either the [optionsFile] or [packagesFile] is non-`null` then the given
206
- * file will be used even if there is a local version of the file.
207
- *
208
- * For each directory within the given [folder] that is neither in the list of
209
- * [excludedFolders] nor excluded by the [excludedFilePatterns] , recursively
210
- * search for nested context roots.
211
- */
185
+ /// If the given [folder] should be the root of a new analysis context, then
186
+ /// create a new context root for it and add it to the list of context
187
+ /// [roots] . The [containingRoot] is the context root from an enclosing
188
+ /// directory and is used to inherit configuration information that isn't
189
+ /// overridden.
190
+ ///
191
+ /// If either the [optionsFile] or [packagesFile] is non-`null` then the given
192
+ /// file will be used even if there is a local version of the file.
193
+ ///
194
+ /// For each directory within the given [folder] that is neither in the list
195
+ /// of [excludedFolders] nor excluded by the [excludedFilePatterns] ,
196
+ /// recursively search for nested context roots.
212
197
void _createContextRoots (
213
198
List <ContextRoot > roots,
214
199
Folder folder,
@@ -253,14 +238,13 @@ class ContextLocatorImpl implements ContextLocator {
253
238
excludedFilePatterns, optionsFile, packagesFile);
254
239
}
255
240
256
- /**
257
- * For each directory within the given [folder] that is neither in the list of
258
- * [excludedFolders] nor excluded by the [excludedFilePatterns] , recursively
259
- * search for nested context roots and add them to the list of [roots] .
260
- *
261
- * If either the [optionsFile] or [packagesFile] is non-`null` then the given
262
- * file will be used even if there is a local version of the file.
263
- */
241
+ /// For each directory within the given [folder] that is neither in the list
242
+ /// of [excludedFolders] nor excluded by the [excludedFilePatterns] ,
243
+ /// recursively search for nested context roots and add them to the list of
244
+ /// [roots] .
245
+ ///
246
+ /// If either the [optionsFile] or [packagesFile] is non-`null` then the given
247
+ /// file will be used even if there is a local version of the file.
264
248
void _createContextRootsIn (
265
249
List <ContextRoot > roots,
266
250
Folder folder,
@@ -303,11 +287,9 @@ class ContextLocatorImpl implements ContextLocator {
303
287
}
304
288
}
305
289
306
- /**
307
- * Return the analysis options file to be used to analyze files in the given
308
- * [folder] , or `null` if there is no analysis options file in the given
309
- * folder or any parent folder.
310
- */
290
+ /// Return the analysis options file to be used to analyze files in the given
291
+ /// [folder] , or `null` if there is no analysis options file in the given
292
+ /// folder or any parent folder.
311
293
File _findOptionsFile (Folder folder) {
312
294
while (folder != null ) {
313
295
File packagesFile = _getOptionsFile (folder);
@@ -319,11 +301,9 @@ class ContextLocatorImpl implements ContextLocator {
319
301
return null ;
320
302
}
321
303
322
- /**
323
- * Return the packages file to be used to analyze files in the given [folder] ,
324
- * or `null` if there is no packages file in the given folder or any parent
325
- * folder.
326
- */
304
+ /// Return the packages file to be used to analyze files in the given
305
+ /// [folder] , or `null` if there is no packages file in the given folder or
306
+ /// any parent folder.
327
307
File _findPackagesFile (Folder folder) {
328
308
while (folder != null ) {
329
309
File packagesFile = _getPackagesFile (folder);
@@ -375,10 +355,8 @@ class ContextLocatorImpl implements ContextLocator {
375
355
return patterns;
376
356
}
377
357
378
- /**
379
- * If the given [directory] contains a file with the given [name] , then return
380
- * the file. Otherwise, return `null` .
381
- */
358
+ /// If the given [directory] contains a file with the given [name] , then
359
+ /// return the file. Otherwise, return `null` .
382
360
File _getFile (Folder directory, String name) {
383
361
Resource resource = directory.getChild (name);
384
362
if (resource is File && resource.exists) {
@@ -387,24 +365,18 @@ class ContextLocatorImpl implements ContextLocator {
387
365
return null ;
388
366
}
389
367
390
- /**
391
- * Return the analysis options file in the given [folder] , or `null` if the
392
- * folder does not contain an analysis options file.
393
- */
368
+ /// Return the analysis options file in the given [folder] , or `null` if the
369
+ /// folder does not contain an analysis options file.
394
370
File _getOptionsFile (Folder folder) =>
395
371
_getFile (folder, ANALYSIS_OPTIONS_NAME );
396
372
397
- /**
398
- * Return the packages file in the given [folder] , or `null` if the folder
399
- * does not contain a packages file.
400
- */
373
+ /// Return the packages file in the given [folder] , or `null` if the folder
374
+ /// does not contain a packages file.
401
375
File _getPackagesFile (Folder folder) => _getFile (folder, PACKAGES_FILE_NAME );
402
376
403
- /**
404
- * Add to the given lists of [folders] and [files] all of the resources in the
405
- * given list of [paths] that exist and are not contained within one of the
406
- * folders.
407
- */
377
+ /// Add to the given lists of [folders] and [files] all of the resources in
378
+ /// the given list of [paths] that exist and are not contained within one of
379
+ /// the folders.
408
380
void _resourcesFromPaths (
409
381
List <String > paths, List <Folder > folders, List <File > files) {
410
382
for (String path in _uniqueSortedPaths (paths)) {
@@ -421,10 +393,8 @@ class ContextLocatorImpl implements ContextLocator {
421
393
}
422
394
}
423
395
424
- /**
425
- * Return a list of paths that contains all of the unique elements from the
426
- * given list of [paths] , sorted such that shorter paths are first.
427
- */
396
+ /// Return a list of paths that contains all of the unique elements from the
397
+ /// given list of [paths] , sorted such that shorter paths are first.
428
398
List <String > _uniqueSortedPaths (List <String > paths) {
429
399
Set <String > uniquePaths = HashSet <String >.from (paths);
430
400
List <String > sortedPaths = uniquePaths.toList ();
0 commit comments