From ff575c7fe0a13edef65ca1a62efb7363d9ac6864 Mon Sep 17 00:00:00 2001 From: Mark Sujew Date: Fri, 17 Sep 2021 10:49:52 +0000 Subject: [PATCH] Read debug options from environment variables --- packages/generator-langium/langium-template/src/extension.ts | 5 +++-- packages/langium-vscode/src/extension.ts | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/generator-langium/langium-template/src/extension.ts b/packages/generator-langium/langium-template/src/extension.ts index 375126c5a..83f3a0590 100644 --- a/packages/generator-langium/langium-template/src/extension.ts +++ b/packages/generator-langium/langium-template/src/extension.ts @@ -23,8 +23,9 @@ export function deactivate(): Thenable | undefined { function startLanguageClient(context: vscode.ExtensionContext): LanguageClient { const serverModule = context.asAbsolutePath(path.join('out', 'language-server', 'main')); // 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'] }; + // --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging. + // By setting `proces.env.DEBUG_BREAK` to a truthy value, the language server will wait until a debugger is attached. + const debugOptions = { execArgv: ['--nolazy', `--inspect${process.env.DEBUG_BREAK ? '-brk' : ''}=${process.env.DEBUG_SOCKET || '6009'}`] }; // If the extension is launched in debug mode then the debug server options are used // Otherwise the run options are used diff --git a/packages/langium-vscode/src/extension.ts b/packages/langium-vscode/src/extension.ts index 3afcb8898..0ca198254 100644 --- a/packages/langium-vscode/src/extension.ts +++ b/packages/langium-vscode/src/extension.ts @@ -29,8 +29,9 @@ export function deactivate(): Thenable | undefined { function startLanguageClient(context: vscode.ExtensionContext): LanguageClient { const serverModule = context.asAbsolutePath(path.join('out', 'language-server', 'main')); // 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'] }; + // --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging. + // By setting `proces.env.DEBUG_BREAK` to a truthy value, the language server will wait until a debugger is attached. + const debugOptions = { execArgv: ['--nolazy', `--inspect${process.env.DEBUG_BREAK ? '-brk' : ''}=${process.env.DEBUG_SOCKET || '6009'}`] }; // If the extension is launched in debug mode then the debug server options are used // Otherwise the run options are used