setAnalysisRoots method

Future setAnalysisRoots(
  1. List<String>? included,
  2. List<String>? excluded, {
  3. Map<String, String>? packageRoots,
})

Sets the root paths used to determine which files to analyze. The set of files to be analyzed are all of the files in one of the root paths that are not either explicitly or implicitly excluded. A file is explicitly excluded if it is in one of the excluded paths. A file is implicitly excluded if it is in a subdirectory of one of the root paths where the name of the subdirectory starts with a period (that is, a hidden directory).

Note that this request determines the set of requested analysis roots. The actual set of analysis roots at any given time is the intersection of this set with the set of files and directories actually present on the filesystem. When the filesystem changes, the actual set of analysis roots is automatically updated, but the set of requested analysis roots is unchanged. This means that if the client sets an analysis root before the root becomes visible to server in the filesystem, there is no error; once the server sees the root in the filesystem it will start analyzing it. Similarly, server will stop analyzing files that are removed from the file system but they will remain in the set of requested roots.

If an included path represents a file, then server will look in the directory containing the file for a pubspec.yaml file. If none is found, then the parents of the directory will be searched until such a file is found or the root of the file system is reached. If such a file is found, it will be used to resolve package: URI's within the file.

Implementation

Future setAnalysisRoots(List<String>? included, List<String>? excluded,
    {Map<String, String>? packageRoots}) {
  final Map m = {'included': included, 'excluded': excluded};
  if (packageRoots != null) m['packageRoots'] = packageRoots;
  return _call('analysis.setAnalysisRoots', m);
}