updateDtdWorkspaceRoots static method

  1. @visibleForTesting
Future<Response> updateDtdWorkspaceRoots(
  1. DartToolingDaemon dtd, {
  2. required DtdInfo dtdConnectionInfo,
  3. required Uri rootFromVmService,
  4. required bool connected,
  5. 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();
}