Skip to content

Commit 94ea900

Browse files
committed
Merged PR 472883: Add support for LaunchBrowserTarget
Add support for LaunchBrowserTarget This PR adds support for LaunchBrowserTarget. It will merge with a previous ExeLaunchTarget and set its serverReadyAction.
1 parent 9e6b2b0 commit 94ea900

File tree

1 file changed

+42
-26
lines changed

1 file changed

+42
-26
lines changed

src/shared/dotnetConfigurationProvider.ts

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,12 @@ export class DotnetConfigurationResolver implements vscode.DebugConfigurationPro
117117
const noDebug: boolean = debugConfiguration.noDebug ?? false;
118118
const preferSSL: boolean = !this.platformInformation.isLinux() && !vscode.env.remoteName && vscode.env.uiKind != vscode.UIKind.Web;
119119
const launchTargets: LaunchTarget[] = await launchConfigurationServiceProxy.queryLaunchTargets(projectPath, {noDebug: noDebug, preferSSL: preferSSL}, token);
120-
for (let launchTarget of launchTargets) {
121-
const convertedLaunchTarget: vscode.DebugConfiguration | undefined = LaunchTargetToDebugConfigurationConverter.convert(debugConfiguration, launchTarget);
122-
if (convertedLaunchTarget) {
123-
debugConfigurations.push(convertedLaunchTarget);
124-
} else {
125-
throw new InternalServiceError("Unable to convert launch target to a vscode debug configuration.");
126-
}
120+
const convertedLaunchTargets: vscode.DebugConfiguration[] | undefined = LaunchTargetToDebugConfigurationConverter.convert(debugConfiguration, launchTargets);
121+
122+
if (convertedLaunchTargets) {
123+
debugConfigurations = debugConfigurations.concat(convertedLaunchTargets);
124+
} else {
125+
throw new InternalServiceError("Unable to convert launch target to a vscode debug configuration.");
127126
}
128127

129128
if (debugConfigurations.length == 1) {
@@ -209,24 +208,39 @@ export class DotnetConfigurationResolver implements vscode.DebugConfigurationPro
209208
}
210209

211210
class LaunchTargetToDebugConfigurationConverter {
212-
static convert(debugConfiguration: vscode.DebugConfiguration, launchTarget: LaunchTarget): vscode.DebugConfiguration | undefined {
213-
if (launchTarget.debugEngines.length > 1) {
214-
throw new InternalServiceError(`Multiple debug engines are currently unsupported: '${launchTarget.debugEngines.join(",")}'`);
215-
}
211+
static convert(debugConfiguration: vscode.DebugConfiguration, launchTargets: LaunchTarget[]): vscode.DebugConfiguration[] | undefined {
212+
let debugConfigurations: vscode.DebugConfiguration[] = [];
216213

217-
if (ExeLaunchTarget.is(launchTarget)) {
218-
return LaunchTargetToDebugConfigurationConverter.convertExeLaunchTarget(debugConfiguration, launchTarget);
219-
} else if (BrowserLaunchTarget.is(launchTarget)) {
220-
LaunchTargetToDebugConfigurationConverter.convertBrowserLaunchTarget(debugConfiguration, launchTarget);
221-
throw new InternalServiceError(`BrowserLaunchTarget is not implemented.\nDebugConfiguration: ${debugConfiguration}\nLaunchTarget: ${launchTarget}`);
222-
} else if (CustomLaunchTarget.is(launchTarget)) {
223-
throw new InternalServiceError(`CustomLaunchTarget is not implemented.\nDebugConfiguration: ${debugConfiguration}\nLaunchTarget: ${launchTarget}`);
224-
} else if (ErrorLaunchTarget.is(launchTarget)) {
225-
// TODO: Handle launchTarget.details
226-
throw new LaunchServiceError(launchTarget.userMessage);
214+
for (let launchTarget of launchTargets)
215+
{
216+
if (launchTarget.debugEngines.length > 1) {
217+
throw new InternalServiceError(`Multiple debug engines are currently unsupported: '${launchTarget.debugEngines.join(",")}'`);
218+
}
219+
220+
if (ExeLaunchTarget.is(launchTarget)) {
221+
debugConfigurations.push(LaunchTargetToDebugConfigurationConverter.convertExeLaunchTarget(debugConfiguration, launchTarget));
222+
} else if (BrowserLaunchTarget.is(launchTarget)) {
223+
const lastConfig: vscode.DebugConfiguration | undefined = debugConfigurations.pop();
224+
if (lastConfig) {
225+
const browserLaunchTarget: any = LaunchTargetToDebugConfigurationConverter.convertBrowserLaunchTarget(launchTarget);
226+
debugConfigurations.push({
227+
...lastConfig,
228+
...browserLaunchTarget
229+
});
230+
} else {
231+
throw new InternalServiceError(`Expected an ExeLaunchTarget before seeing a BrowserLaunchTarget.`);
232+
}
233+
} else if (CustomLaunchTarget.is(launchTarget)) {
234+
throw new InternalServiceError(`CustomLaunchTarget is not implemented.\nDebugConfiguration: ${debugConfiguration}\nLaunchTarget: ${launchTarget}`);
235+
} else if (ErrorLaunchTarget.is(launchTarget)) {
236+
// TODO: Handle launchTarget.details
237+
throw new LaunchServiceError(launchTarget.userMessage);
238+
} else {
239+
throw new InternalServiceError(`Unknown LaunchTarget type: '${launchTarget.constructor.name}'`);
240+
}
227241
}
228242

229-
return undefined;
243+
return debugConfigurations;
230244
}
231245

232246
private static convertExeLaunchTarget(debugConfiguration: vscode.DebugConfiguration, exeLaunchTarget: ExeLaunchTarget): vscode.DebugConfiguration {
@@ -243,11 +257,13 @@ class LaunchTargetToDebugConfigurationConverter {
243257
};
244258
}
245259

246-
private static convertBrowserLaunchTarget(debugConfiguration: vscode.DebugConfiguration, browserLaunchTarget: BrowserLaunchTarget): vscode.DebugConfiguration {
260+
private static convertBrowserLaunchTarget(browserLaunchTarget: BrowserLaunchTarget): any {
247261
return {
248-
"name": debugConfiguration.name,
249-
"type": browserLaunchTarget.debugEngines[0],
250-
"request": debugConfiguration.request
262+
"serverReadyAction": {
263+
"action": "openExternally",
264+
"pattern": "\\bNow listening on:\\s+https?://\\S+",
265+
"uriFormat" : browserLaunchTarget.url,
266+
}
251267
};
252268
}
253269
}

0 commit comments

Comments
 (0)