Skip to content

Commit dbee9a0

Browse files
committed
use auto attach children instead of multiple launch configs
This is a new (with js-debug) option that makes debugging child processes much easier. Use it for the LSP subprocesses. Supplants #704
1 parent 7e2f7f1 commit dbee9a0

File tree

13 files changed

+11
-123
lines changed

13 files changed

+11
-123
lines changed

lsp-embedded-language-service/.vscode/launch.json

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,12 @@
99
"runtimeExecutable": "${execPath}",
1010
"args": ["--extensionDevelopmentPath=${workspaceRoot}"],
1111
"outFiles": ["${workspaceRoot}/client/out/**/*.js"],
12+
"autoAttachChildProcesses": true,
1213
"preLaunchTask": {
1314
"type": "npm",
1415
"script": "watch"
1516
}
1617
},
17-
{
18-
"type": "node",
19-
"request": "attach",
20-
"name": "Attach to Server",
21-
"port": 6009,
22-
"restart": true,
23-
"outFiles": ["${workspaceRoot}/server/out/**/*.js"]
24-
},
2518
{
2619
"name": "Language Server E2E Test",
2720
"type": "extensionHost",
@@ -34,11 +27,5 @@
3427
],
3528
"outFiles": ["${workspaceRoot}/client/out/test/**/*.js"]
3629
}
37-
],
38-
"compounds": [
39-
{
40-
"name": "Client + Server",
41-
"configurations": ["Launch Client", "Attach to Server"]
42-
}
4330
]
4431
}

lsp-embedded-language-service/client/src/extension.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,13 @@ export function activate(context: ExtensionContext) {
2020
const serverModule = context.asAbsolutePath(
2121
path.join('server', 'out', 'server.js')
2222
);
23-
// The debug options for the server
24-
// --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging
25-
const debugOptions = { execArgv: ['--nolazy', '--inspect=6009'] };
26-
2723
// If the extension is launched in debug mode then the debug server options are used
2824
// Otherwise the run options are used
2925
const serverOptions: ServerOptions = {
3026
run: { module: serverModule, transport: TransportKind.ipc },
3127
debug: {
3228
module: serverModule,
3329
transport: TransportKind.ipc,
34-
options: debugOptions
3530
}
3631
};
3732

lsp-embedded-request-forwarding/.vscode/launch.json

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,12 @@
99
"runtimeExecutable": "${execPath}",
1010
"args": ["--extensionDevelopmentPath=${workspaceRoot}"],
1111
"outFiles": ["${workspaceRoot}/client/out/**/*.js"],
12+
"autoAttachChildProcesses": true,
1213
"preLaunchTask": {
1314
"type": "npm",
1415
"script": "watch"
1516
}
1617
},
17-
{
18-
"type": "node",
19-
"request": "attach",
20-
"name": "Attach to Server",
21-
"port": 6009,
22-
"restart": true,
23-
"outFiles": ["${workspaceRoot}/server/out/**/*.js"]
24-
},
2518
{
2619
"name": "Language Server E2E Test",
2720
"type": "extensionHost",
@@ -34,11 +27,5 @@
3427
],
3528
"outFiles": ["${workspaceRoot}/client/out/test/**/*.js"]
3629
}
37-
],
38-
"compounds": [
39-
{
40-
"name": "Client + Server",
41-
"configurations": ["Launch Client", "Attach to Server"]
42-
}
4330
]
4431
}

lsp-embedded-request-forwarding/client/src/extension.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ const htmlLanguageService = getLanguageService();
1616
export function activate(context: ExtensionContext) {
1717
// The server is implemented in node
1818
const serverModule = context.asAbsolutePath(path.join('server', 'out', 'server.js'));
19-
// The debug options for the server
20-
// --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging
21-
const debugOptions = { execArgv: ['--nolazy', '--inspect=6009'] };
2219

2320
// If the extension is launched in debug mode then the debug server options are used
2421
// Otherwise the run options are used
@@ -27,7 +24,6 @@ export function activate(context: ExtensionContext) {
2724
debug: {
2825
module: serverModule,
2926
transport: TransportKind.ipc,
30-
options: debugOptions
3127
}
3228
};
3329

lsp-log-streaming-sample/.vscode/launch.json

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,11 @@
88
"name": "Launch Client",
99
"runtimeExecutable": "${execPath}",
1010
"args": ["--extensionDevelopmentPath=${workspaceRoot}"],
11-
"stopOnEntry": false,
11+
"autoAttachChildProcesses": true,
1212
"sourceMaps": true,
1313
"outFiles": ["${workspaceRoot}/client/out/**/*.js"],
1414
"preLaunchTask": "npm: watch:client"
1515
},
16-
{
17-
"type": "node",
18-
"request": "attach",
19-
"name": "Attach to Server",
20-
"address": "localhost",
21-
"protocol": "inspector",
22-
"port": 6009,
23-
"sourceMaps": true,
24-
"outFiles": ["${workspaceRoot}/server/out/**/*.js"]
25-
},
2616
{
2717
"name": "Language Server E2E Test",
2818
"type": "extensionHost",
@@ -33,15 +23,8 @@
3323
"--extensionTestsPath=${workspaceRoot}/client/out/test",
3424
"${workspaceRoot}/client/testFixture"
3525
],
36-
"stopOnEntry": false,
3726
"sourceMaps": true,
3827
"outFiles": ["${workspaceRoot}/client/out/test/**/*.js"]
3928
}
40-
],
41-
"compounds": [
42-
{
43-
"name": "Client + Server",
44-
"configurations": ["Launch Client", "Attach to Server"]
45-
}
4629
]
4730
}

lsp-log-streaming-sample/client/src/extension.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ export function activate(context: ExtensionContext) {
2929
const serverModule = context.asAbsolutePath(
3030
path.join('server', 'out', 'server.js')
3131
);
32-
// The debug options for the server
33-
// --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging
34-
const debugOptions = { execArgv: ['--nolazy', '--inspect=6009'] };
3532

3633
// If the extension is launched in debug mode then the debug server options are used
3734
// Otherwise the run options are used
@@ -40,7 +37,6 @@ export function activate(context: ExtensionContext) {
4037
debug: {
4138
module: serverModule,
4239
transport: TransportKind.ipc,
43-
options: debugOptions
4440
}
4541
};
4642

lsp-multi-server-sample/.vscode/launch.json

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,10 @@
88
"name": "Launch Client",
99
"runtimeExecutable": "${execPath}",
1010
"args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
11-
"stopOnEntry": false,
11+
"autoAttachChildProcesses": true,
1212
"sourceMaps": true,
1313
"outFiles": ["${workspaceRoot}/client/out/**/*.js"],
1414
"preLaunchTask": "npm: watch"
15-
},
16-
{
17-
"type": "node",
18-
"request": "attach",
19-
"name": "Attach to Server 6011",
20-
"address": "localhost",
21-
"protocol": "inspector",
22-
"port": 6011,
23-
"sourceMaps": true,
24-
"outFiles": ["${workspaceRoot}/server/out/**/*.js"]
25-
},
26-
{
27-
"type": "node",
28-
"request": "attach",
29-
"name": "Attach to Server 6012",
30-
"address": "localhost",
31-
"protocol": "inspector",
32-
"port": 6012,
33-
"sourceMaps": true,
34-
"outFiles": ["${workspaceRoot}/server/out/**/*.js"]
3515
}
3616
]
3717
}

lsp-multi-server-sample/client/src/extension.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,9 @@ export function activate(context: ExtensionContext) {
6161
const uri = document.uri;
6262
// Untitled files go to a default client.
6363
if (uri.scheme === 'untitled' && !defaultClient) {
64-
const debugOptions = { execArgv: ["--nolazy", "--inspect=6010"] };
6564
const serverOptions = {
6665
run: { module, transport: TransportKind.ipc },
67-
debug: { module, transport: TransportKind.ipc, options: debugOptions}
66+
debug: { module, transport: TransportKind.ipc }
6867
};
6968
const clientOptions: LanguageClientOptions = {
7069
documentSelector: [
@@ -87,10 +86,9 @@ export function activate(context: ExtensionContext) {
8786
folder = getOuterMostWorkspaceFolder(folder);
8887

8988
if (!clients.has(folder.uri.toString())) {
90-
const debugOptions = { execArgv: ["--nolazy", `--inspect=${6011 + clients.size}`] };
9189
const serverOptions = {
9290
run: { module, transport: TransportKind.ipc },
93-
debug: { module, transport: TransportKind.ipc, options: debugOptions}
91+
debug: { module, transport: TransportKind.ipc }
9492
};
9593
const clientOptions: LanguageClientOptions = {
9694
documentSelector: [
@@ -128,4 +126,4 @@ export function deactivate(): Thenable<void> {
128126
promises.push(client.stop());
129127
}
130128
return Promise.all(promises).then(() => undefined);
131-
}
129+
}

lsp-sample/.vscode/launch.json

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,12 @@
99
"runtimeExecutable": "${execPath}",
1010
"args": ["--extensionDevelopmentPath=${workspaceRoot}"],
1111
"outFiles": ["${workspaceRoot}/client/out/**/*.js"],
12+
"autoAttachChildProcesses": true,
1213
"preLaunchTask": {
1314
"type": "npm",
1415
"script": "watch"
1516
}
1617
},
17-
{
18-
"type": "node",
19-
"request": "attach",
20-
"name": "Attach to Server",
21-
"port": 6009,
22-
"restart": true,
23-
"outFiles": ["${workspaceRoot}/server/out/**/*.js"]
24-
},
2518
{
2619
"name": "Language Server E2E Test",
2720
"type": "extensionHost",
@@ -34,11 +27,5 @@
3427
],
3528
"outFiles": ["${workspaceRoot}/client/out/test/**/*.js"]
3629
}
37-
],
38-
"compounds": [
39-
{
40-
"name": "Client + Server",
41-
"configurations": ["Launch Client", "Attach to Server"]
42-
}
4330
]
4431
}

lsp-sample/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ It also includes an End-to-End test.
3232
- Switch to the Run and Debug View in the Sidebar (Ctrl+Shift+D).
3333
- Select `Launch Client` from the drop down (if it is not already).
3434
- Press ▷ to run the launch config (F5).
35-
- If you want to debug the server as well, use the launch configuration `Attach to Server`
3635
- In the [Extension Development Host](https://code.visualstudio.com/api/get-started/your-first-extension#:~:text=Then%2C%20inside%20the%20editor%2C%20press%20F5.%20This%20will%20compile%20and%20run%20the%20extension%20in%20a%20new%20Extension%20Development%20Host%20window.) instance of VSCode, open a document in 'plain text' language mode.
3736
- Type `j` or `t` to see `Javascript` and `TypeScript` completion.
3837
- Enter text content such as `AAA aaa BBB`. The extension will emit diagnostics for all words in all-uppercase.

0 commit comments

Comments
 (0)