[flutter_tools/dap] Inform DAP client whether restart is supported (#121610)

[flutter_tools/dap] Inform DAP client whether restart is supported
This commit is contained in:
Danny Tuppeny
2023-03-03 12:54:23 +00:00
committed by GitHub
parent 4ab053c252
commit 3494c08448
3 changed files with 49 additions and 7 deletions

View File

@@ -48,13 +48,6 @@ class FlutterDebugAdapter extends FlutterBaseDebugAdapter {
/// their handlers.
final Map<int, Completer<Object?>> _flutterRequestCompleters = <int, Completer<Object?>>{};
/// Whether or not this adapter can handle the restartRequest.
///
/// For Flutter apps we can handle this with a Hot Restart rather than having
/// the whole debug session stopped and restarted.
@override
bool get supportsRestartRequest => true;
/// A list of reverse-requests from `flutter run --machine` that should be forwarded to the client.
static const Set<String> _requestsToForwardToClient = <String>{
// The 'app.exposeUrl' request is sent by Flutter to request the client
@@ -399,6 +392,12 @@ class FlutterDebugAdapter extends FlutterBaseDebugAdapter {
if (_appId == null) {
throw DebugAdapterException('Unexpected null `appId` in app.start event');
}
// Notify the client whether it can call 'restartRequest' when the user
// clicks restart, instead of terminating and re-starting its own debug
// session (which is much slower, but required for profile/release mode).
final bool supportsRestart = (params['supportsRestart'] as bool?) ?? false;
sendEvent(CapabilitiesEventBody(capabilities: Capabilities(supportsRestartRequest: supportsRestart)));
}
/// Handles the app.started event from Flutter.