Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ abstract class EditorClient {
String? debugSessionId, {
String? page,
bool? forceExternal,
bool? requiresDebugSession,
});

/// Requests the editor enables a new platform (for example by running
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,13 @@ class PostMessageEditorClient implements EditorClient {
String? debugSessionId, {
String? page,
bool? forceExternal,
bool? requiresDebugSession,
}) async {
await _api.openDevToolsPage(
debugSessionId,
page: page,
forceExternal: forceExternal,
requiresDebugSession: requiresDebugSession,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,15 @@ final class VsCodeApiImpl implements VsCodeApi {
String? debugSessionId, {
String? page,
bool? forceExternal,
bool? requiresDebugSession,
}) {
return sendRequest(
VsCodeApi.jsonOpenDevToolsPageMethod,
{
VsCodeApi.jsonDebugSessionIdParameter: debugSessionId,
VsCodeApi.jsonPageParameter: page,
VsCodeApi.jsonForceExternalParameter: forceExternal,
VsCodeApi.jsonRequiresDebugSessionParameter: requiresDebugSession,
},
);
}
Expand Down Expand Up @@ -212,6 +214,11 @@ class VsCodeCapabilitiesImpl implements VsCodeCapabilities {
bool get openDevToolsExternally =>
_raw?[VsCodeCapabilities.openDevToolsExternallyField] == true;

@override
bool get openDevToolsWithRequiresDebugSessionFlag =>
_raw?[VsCodeCapabilities.openDevToolsWithRequiresDebugSessionFlagField] ==
true;

@override
bool get hotReload => _raw?[VsCodeCapabilities.hotReloadField] == true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,18 @@ abstract interface class VsCodeApi {
///
/// Depending on user settings, this may open embedded (the default) or in an
/// external browser window.
///
/// If [debugSessionId] is `null` the [requiresDebugSession] flag will
/// determine whether the editor will select (or ask the user to select) a
/// debug session for the page. If [requiresDebugSession] is `null` (or if
/// the `openDevToolsWithRequiresDebugSessionFlag` capability is `false`) then
/// the editor will try to make this decision automatically (which may be
/// inaccurate for pages it does not know about, like extensions).
Future<void> openDevToolsPage(
String? debugSessionId, {
String? page,
bool? forceExternal,
bool? requiresDebugSession,
});

/// Sends a Hot Reload request to the debug session with ID [debugSessionId].
Expand Down Expand Up @@ -87,6 +95,7 @@ abstract interface class VsCodeApi {
static const jsonForceExternalParameter = 'forceExternal';
static const jsonDebugSessionIdParameter = 'debugSessionId';
static const jsonPlatformTypeParameter = 'platformType';
static const jsonRequiresDebugSessionParameter = 'requiresDebugSession';
}

/// This class defines a device event sent by the Dart/Flutter extensions in VS
Expand Down Expand Up @@ -153,6 +162,11 @@ abstract interface class VsCodeCapabilities {
/// regardless of user settings.
bool get openDevToolsExternally;

/// Whether the `openDevToolsPage` method can be called with the
/// `requiresDebugSession` flag to indicate whether the editor should select/
/// prompt for a debug session if one was not provided.
bool get openDevToolsWithRequiresDebugSessionFlag;

/// Whether the `hotReload` method is available call to hot reload a specific
/// debug session.
bool get hotReload;
Expand All @@ -164,6 +178,8 @@ abstract interface class VsCodeCapabilities {
static const jsonSelectDeviceField = 'selectDevice';
static const openDevToolsPageField = 'openDevToolsPage';
static const openDevToolsExternallyField = 'openDevToolsExternally';
static const openDevToolsWithRequiresDebugSessionFlagField =
'openDevToolsWithRequiresDebugSessionFlag';
static const hotReloadField = 'hotReload';
static const hotRestartField = 'hotRestart';
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ abstract class EditorServer {
String debugSessionId,
String? page,
bool forceExternal,
bool requiresDebugSession,
) {}

/// Overridden by subclasses to provide an implementation of the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ mixin FakeEditor on EditorServer {
String debugSessionId,
String? page,
bool forceExternal,
bool requiresDebugSession,
) {}
}

Expand Down