projectRoots method
Returns the project roots for the Dart Tooling Daemon connection.
A project root is any directory, contained within the current set of workspaceRoots, that contains a 'pubspec.yaml' file.
By default, the cached value _projectRoots
will be returned when
available. When forceRefresh
is true, the cached value will be cleared
and recomputed.
depth
is the maximum depth that each workspace root directory tree will
will be searched for project roots. Setting depth
to a large number
may have performance implications when traversing large trees.
Implementation
Future<UriList?> projectRoots({
int? depth = defaultGetProjectRootsDepth,
bool forceRefresh = false,
}) async {
if (!hasConnection) return null;
if (_projectRoots != null && forceRefresh) {
_projectRoots = null;
}
try {
return _projectRoots ??= await _dtd.getProjectRoots(depth: depth!);
} catch (e) {
_log.fine('Error fetching project roots: $e');
return null;
}
}