handleAnalysisSetContextRoots method
Future<AnalysisSetContextRootsResult>
handleAnalysisSetContextRoots(
- AnalysisSetContextRootsParams parameters
inherited
Handle an 'analysis.setContextRoots' request.
Throw a RequestFailure
if the request could not be handled.
Implementation
Future<AnalysisSetContextRootsResult> handleAnalysisSetContextRoots(
AnalysisSetContextRootsParams parameters) async {
var contextRoots = parameters.roots;
var oldRoots = driverMap.keys.toList();
for (var contextRoot in contextRoots) {
if (!oldRoots.remove(contextRoot)) {
// The context is new, so we create a driver for it. Creating the driver
// has the side-effect of adding it to the analysis driver scheduler.
var driver = createAnalysisDriver(contextRoot);
driverMap[contextRoot] = driver;
_addFilesToDriver(
driver,
resourceProvider.getResource(contextRoot.root),
contextRoot.exclude);
}
}
for (var contextRoot in oldRoots) {
// The context has been removed, so we remove its driver.
var driver = driverMap.remove(contextRoot);
// The `dispose` method has the side-effect of removing the driver from
// the analysis driver scheduler.
driver?.dispose();
}
return AnalysisSetContextRootsResult();
}