mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-06-13 07:10:26 +08:00
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 https://github.com/microsoft/vscode-extension-samples/pull/704
This commit is contained in:
@ -9,19 +9,12 @@
|
||||
"runtimeExecutable": "${execPath}",
|
||||
"args": ["--extensionDevelopmentPath=${workspaceRoot}"],
|
||||
"outFiles": ["${workspaceRoot}/client/out/**/*.js"],
|
||||
"autoAttachChildProcesses": true,
|
||||
"preLaunchTask": {
|
||||
"type": "npm",
|
||||
"script": "watch"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "attach",
|
||||
"name": "Attach to Server",
|
||||
"port": 6009,
|
||||
"restart": true,
|
||||
"outFiles": ["${workspaceRoot}/server/out/**/*.js"]
|
||||
},
|
||||
{
|
||||
"name": "Language Server E2E Test",
|
||||
"type": "extensionHost",
|
||||
@ -34,11 +27,5 @@
|
||||
],
|
||||
"outFiles": ["${workspaceRoot}/client/out/test/**/*.js"]
|
||||
}
|
||||
],
|
||||
"compounds": [
|
||||
{
|
||||
"name": "Client + Server",
|
||||
"configurations": ["Launch Client", "Attach to Server"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -20,10 +20,6 @@ export function activate(context: ExtensionContext) {
|
||||
const serverModule = context.asAbsolutePath(
|
||||
path.join('server', 'out', 'server.js')
|
||||
);
|
||||
// The debug options for the server
|
||||
// --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging
|
||||
const debugOptions = { execArgv: ['--nolazy', '--inspect=6009'] };
|
||||
|
||||
// If the extension is launched in debug mode then the debug server options are used
|
||||
// Otherwise the run options are used
|
||||
const serverOptions: ServerOptions = {
|
||||
@ -31,7 +27,6 @@ export function activate(context: ExtensionContext) {
|
||||
debug: {
|
||||
module: serverModule,
|
||||
transport: TransportKind.ipc,
|
||||
options: debugOptions
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -9,19 +9,12 @@
|
||||
"runtimeExecutable": "${execPath}",
|
||||
"args": ["--extensionDevelopmentPath=${workspaceRoot}"],
|
||||
"outFiles": ["${workspaceRoot}/client/out/**/*.js"],
|
||||
"autoAttachChildProcesses": true,
|
||||
"preLaunchTask": {
|
||||
"type": "npm",
|
||||
"script": "watch"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "attach",
|
||||
"name": "Attach to Server",
|
||||
"port": 6009,
|
||||
"restart": true,
|
||||
"outFiles": ["${workspaceRoot}/server/out/**/*.js"]
|
||||
},
|
||||
{
|
||||
"name": "Language Server E2E Test",
|
||||
"type": "extensionHost",
|
||||
@ -34,11 +27,5 @@
|
||||
],
|
||||
"outFiles": ["${workspaceRoot}/client/out/test/**/*.js"]
|
||||
}
|
||||
],
|
||||
"compounds": [
|
||||
{
|
||||
"name": "Client + Server",
|
||||
"configurations": ["Launch Client", "Attach to Server"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -16,9 +16,6 @@ const htmlLanguageService = getLanguageService();
|
||||
export function activate(context: ExtensionContext) {
|
||||
// The server is implemented in node
|
||||
const serverModule = context.asAbsolutePath(path.join('server', 'out', 'server.js'));
|
||||
// The debug options for the server
|
||||
// --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging
|
||||
const debugOptions = { execArgv: ['--nolazy', '--inspect=6009'] };
|
||||
|
||||
// If the extension is launched in debug mode then the debug server options are used
|
||||
// Otherwise the run options are used
|
||||
@ -27,7 +24,6 @@ export function activate(context: ExtensionContext) {
|
||||
debug: {
|
||||
module: serverModule,
|
||||
transport: TransportKind.ipc,
|
||||
options: debugOptions
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
19
lsp-log-streaming-sample/.vscode/launch.json
vendored
19
lsp-log-streaming-sample/.vscode/launch.json
vendored
@ -8,21 +8,11 @@
|
||||
"name": "Launch Client",
|
||||
"runtimeExecutable": "${execPath}",
|
||||
"args": ["--extensionDevelopmentPath=${workspaceRoot}"],
|
||||
"stopOnEntry": false,
|
||||
"autoAttachChildProcesses": true,
|
||||
"sourceMaps": true,
|
||||
"outFiles": ["${workspaceRoot}/client/out/**/*.js"],
|
||||
"preLaunchTask": "npm: watch:client"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "attach",
|
||||
"name": "Attach to Server",
|
||||
"address": "localhost",
|
||||
"protocol": "inspector",
|
||||
"port": 6009,
|
||||
"sourceMaps": true,
|
||||
"outFiles": ["${workspaceRoot}/server/out/**/*.js"]
|
||||
},
|
||||
{
|
||||
"name": "Language Server E2E Test",
|
||||
"type": "extensionHost",
|
||||
@ -33,15 +23,8 @@
|
||||
"--extensionTestsPath=${workspaceRoot}/client/out/test",
|
||||
"${workspaceRoot}/client/testFixture"
|
||||
],
|
||||
"stopOnEntry": false,
|
||||
"sourceMaps": true,
|
||||
"outFiles": ["${workspaceRoot}/client/out/test/**/*.js"]
|
||||
}
|
||||
],
|
||||
"compounds": [
|
||||
{
|
||||
"name": "Client + Server",
|
||||
"configurations": ["Launch Client", "Attach to Server"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -29,9 +29,6 @@ export function activate(context: ExtensionContext) {
|
||||
const serverModule = context.asAbsolutePath(
|
||||
path.join('server', 'out', 'server.js')
|
||||
);
|
||||
// The debug options for the server
|
||||
// --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging
|
||||
const debugOptions = { execArgv: ['--nolazy', '--inspect=6009'] };
|
||||
|
||||
// If the extension is launched in debug mode then the debug server options are used
|
||||
// Otherwise the run options are used
|
||||
@ -40,7 +37,6 @@ export function activate(context: ExtensionContext) {
|
||||
debug: {
|
||||
module: serverModule,
|
||||
transport: TransportKind.ipc,
|
||||
options: debugOptions
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
22
lsp-multi-server-sample/.vscode/launch.json
vendored
22
lsp-multi-server-sample/.vscode/launch.json
vendored
@ -8,30 +8,10 @@
|
||||
"name": "Launch Client",
|
||||
"runtimeExecutable": "${execPath}",
|
||||
"args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
|
||||
"stopOnEntry": false,
|
||||
"autoAttachChildProcesses": true,
|
||||
"sourceMaps": true,
|
||||
"outFiles": ["${workspaceRoot}/client/out/**/*.js"],
|
||||
"preLaunchTask": "npm: watch"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "attach",
|
||||
"name": "Attach to Server 6011",
|
||||
"address": "localhost",
|
||||
"protocol": "inspector",
|
||||
"port": 6011,
|
||||
"sourceMaps": true,
|
||||
"outFiles": ["${workspaceRoot}/server/out/**/*.js"]
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "attach",
|
||||
"name": "Attach to Server 6012",
|
||||
"address": "localhost",
|
||||
"protocol": "inspector",
|
||||
"port": 6012,
|
||||
"sourceMaps": true,
|
||||
"outFiles": ["${workspaceRoot}/server/out/**/*.js"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -61,10 +61,9 @@ export function activate(context: ExtensionContext) {
|
||||
const uri = document.uri;
|
||||
// Untitled files go to a default client.
|
||||
if (uri.scheme === 'untitled' && !defaultClient) {
|
||||
const debugOptions = { execArgv: ["--nolazy", "--inspect=6010"] };
|
||||
const serverOptions = {
|
||||
run: { module, transport: TransportKind.ipc },
|
||||
debug: { module, transport: TransportKind.ipc, options: debugOptions}
|
||||
debug: { module, transport: TransportKind.ipc }
|
||||
};
|
||||
const clientOptions: LanguageClientOptions = {
|
||||
documentSelector: [
|
||||
@ -87,10 +86,9 @@ export function activate(context: ExtensionContext) {
|
||||
folder = getOuterMostWorkspaceFolder(folder);
|
||||
|
||||
if (!clients.has(folder.uri.toString())) {
|
||||
const debugOptions = { execArgv: ["--nolazy", `--inspect=${6011 + clients.size}`] };
|
||||
const serverOptions = {
|
||||
run: { module, transport: TransportKind.ipc },
|
||||
debug: { module, transport: TransportKind.ipc, options: debugOptions}
|
||||
debug: { module, transport: TransportKind.ipc }
|
||||
};
|
||||
const clientOptions: LanguageClientOptions = {
|
||||
documentSelector: [
|
||||
@ -128,4 +126,4 @@ export function deactivate(): Thenable<void> {
|
||||
promises.push(client.stop());
|
||||
}
|
||||
return Promise.all(promises).then(() => undefined);
|
||||
}
|
||||
}
|
||||
|
||||
15
lsp-sample/.vscode/launch.json
vendored
15
lsp-sample/.vscode/launch.json
vendored
@ -9,19 +9,12 @@
|
||||
"runtimeExecutable": "${execPath}",
|
||||
"args": ["--extensionDevelopmentPath=${workspaceRoot}"],
|
||||
"outFiles": ["${workspaceRoot}/client/out/**/*.js"],
|
||||
"autoAttachChildProcesses": true,
|
||||
"preLaunchTask": {
|
||||
"type": "npm",
|
||||
"script": "watch"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "attach",
|
||||
"name": "Attach to Server",
|
||||
"port": 6009,
|
||||
"restart": true,
|
||||
"outFiles": ["${workspaceRoot}/server/out/**/*.js"]
|
||||
},
|
||||
{
|
||||
"name": "Language Server E2E Test",
|
||||
"type": "extensionHost",
|
||||
@ -34,11 +27,5 @@
|
||||
],
|
||||
"outFiles": ["${workspaceRoot}/client/out/test/**/*.js"]
|
||||
}
|
||||
],
|
||||
"compounds": [
|
||||
{
|
||||
"name": "Client + Server",
|
||||
"configurations": ["Launch Client", "Attach to Server"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -32,7 +32,6 @@ It also includes an End-to-End test.
|
||||
- Switch to the Run and Debug View in the Sidebar (Ctrl+Shift+D).
|
||||
- Select `Launch Client` from the drop down (if it is not already).
|
||||
- Press ▷ to run the launch config (F5).
|
||||
- If you want to debug the server as well, use the launch configuration `Attach to Server`
|
||||
- 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.
|
||||
- Type `j` or `t` to see `Javascript` and `TypeScript` completion.
|
||||
- Enter text content such as `AAA aaa BBB`. The extension will emit diagnostics for all words in all-uppercase.
|
||||
|
||||
@ -20,9 +20,6 @@ export function activate(context: ExtensionContext) {
|
||||
const serverModule = context.asAbsolutePath(
|
||||
path.join('server', 'out', 'server.js')
|
||||
);
|
||||
// The debug options for the server
|
||||
// --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging
|
||||
const debugOptions = { execArgv: ['--nolazy', '--inspect=6009'] };
|
||||
|
||||
// If the extension is launched in debug mode then the debug server options are used
|
||||
// Otherwise the run options are used
|
||||
@ -31,7 +28,6 @@ export function activate(context: ExtensionContext) {
|
||||
debug: {
|
||||
module: serverModule,
|
||||
transport: TransportKind.ipc,
|
||||
options: debugOptions
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
18
lsp-user-input-sample/.vscode/launch.json
vendored
18
lsp-user-input-sample/.vscode/launch.json
vendored
@ -8,26 +8,10 @@
|
||||
"name": "Launch Client",
|
||||
"runtimeExecutable": "${execPath}",
|
||||
"args": ["--extensionDevelopmentPath=${workspaceFolder}" ],
|
||||
"stopOnEntry": false,
|
||||
"autoAttachChildProcesses": true,
|
||||
"sourceMaps": true,
|
||||
"outFiles": ["${workspaceFolder}/client/out/**/*.js"],
|
||||
"preLaunchTask": "npm: watch"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "attach",
|
||||
"name": "Attach to Server",
|
||||
"address": "localhost",
|
||||
"protocol": "inspector",
|
||||
"port": 6011,
|
||||
"sourceMaps": true,
|
||||
"outFiles": ["${workspaceFolder}/server/out/**/*.js"]
|
||||
}
|
||||
],
|
||||
"compounds": [
|
||||
{
|
||||
"name": "Client + Server",
|
||||
"configurations": ["Launch Client", "Attach to Server"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ export function activate(context: ExtensionContext): void {
|
||||
const serverModule = context.asAbsolutePath(path.join('server', 'out', 'sampleServer.js'));
|
||||
let serverOptions: ServerOptions = {
|
||||
run: { module: serverModule, transport: TransportKind.ipc, options: { cwd: process.cwd() } },
|
||||
debug: { module: serverModule, transport: TransportKind.ipc, options: { execArgv: ['--nolazy', '--inspect=6011'], cwd: process.cwd() } }
|
||||
debug: { module: serverModule, transport: TransportKind.ipc, options: { cwd: process.cwd() } }
|
||||
};
|
||||
|
||||
let clientOptions: LanguageClientOptions = {
|
||||
@ -48,4 +48,4 @@ export function activate(context: ExtensionContext): void {
|
||||
}
|
||||
|
||||
export function deactivate() {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user