@@ -11,11 +11,15 @@ import { ideServerLogger } from './logging';
1111/** Starts a new CodeQL language server process, sending progress messages to the status bar. */
1212export async function spawnIdeServer ( config : QueryServerConfig ) : Promise < StreamInfo > {
1313 return window . withProgress ( { title : 'CodeQL language server' , location : ProgressLocation . Window } , async ( progressReporter , _ ) => {
14+ const args = [ '--check-errors' , 'ON_CHANGE' ] ;
15+ if ( shouldDebug ( ) ) {
16+ args . push ( '-J=-agentlib:jdwp=transport=dt_socket,address=localhost:9009,server=y,suspend=n,quiet=y' ) ;
17+ }
1418 const child = cli . spawnServer (
1519 config . codeQlPath ,
1620 'CodeQL language server' ,
1721 [ 'execute' , 'language-server' ] ,
18- [ '--check-errors' , 'ON_CHANGE' ] ,
22+ args ,
1923 ideServerLogger ,
2024 data => ideServerLogger . log ( data . toString ( ) , { trailingNewline : false } ) ,
2125 data => ideServerLogger . log ( data . toString ( ) , { trailingNewline : false } ) ,
@@ -24,3 +28,9 @@ export async function spawnIdeServer(config: QueryServerConfig): Promise<StreamI
2428 return { writer : child . stdin ! , reader : child . stdout ! } ;
2529 } ) ;
2630}
31+
32+ function shouldDebug ( ) {
33+ return 'DEBUG_LANGUAGE_SERVER' in process . env
34+ && process . env . DEBUG_LANGUAGE_SERVER !== '0'
35+ && process . env . DEBUG_LANGUAGE_SERVER ?. toLocaleLowerCase ( ) !== 'false' ;
36+ }
0 commit comments