updateDtdWorkspaceRoots static method
Future<Response>
updateDtdWorkspaceRoots(
- DartToolingDaemon dtd, {
- required DtdInfo dtdConnectionInfo,
- required Uri rootFromVmService,
- required bool connected,
- required ServerApi api,
})
Implementation
@visibleForTesting
static Future<shelf.Response> updateDtdWorkspaceRoots(
DartToolingDaemon dtd, {
required DtdInfo dtdConnectionInfo,
required Uri rootFromVmService,
required bool connected,
required ServerApi api,
}) async {
final currentRoots =
(await dtd.getIDEWorkspaceRoots()).ideWorkspaceRoots.toSet();
// Add or remove [rootFromVmService] depending on whether this was a
// connect or disconnect notification.
final newRoots = connected
? (currentRoots..add(rootFromVmService)).toList()
: (currentRoots..remove(rootFromVmService)).toList();
await dtd.setIDEWorkspaceRoots(dtdConnectionInfo.secret!, newRoots);
return api.success();
}