Skip to content

Commit

Permalink
Fix debug mode detection
Browse files Browse the repository at this point in the history
It was no longer possible to start a remote Java debugger on lemminx,
because the debug flags used to start the hosted vscode extension have changed.

Signed-off-by: Fred Bricon <[email protected]>
  • Loading branch information
fbricon committed May 29, 2020
1 parent 4971d5b commit e01d3e0
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 deletions src/javaServerStarter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,29 +77,34 @@ function prepareParams(requirements: RequirementsData, xmlJavaExtensions: string
}

function startedInDebugMode(): boolean {
let args = (process as any).execArgv;
const args = (process as any).execArgv as string[];
return hasDebugFlag(args);
}

function hasDebugFlag(args: string[]): boolean {
if (args) {
return args.some((arg) => /^--debug=?/.test(arg) || /^--debug-brk=?/.test(arg) || /^--inspect-brk=?/.test(arg));
};
// See https://nodejs.org/en/docs/guides/debugging-getting-started/
return args.some( arg => /^--inspect/.test(arg) || /^--debug/.test(arg));
}
return false;
}

//exported for tests
export function parseVMargs(params: any[], vmargsLine: string) {
if (!vmargsLine) {
return;
}
let vmargs = vmargsLine.match(/(?:[^\s"]+|"[^"]*")+/g);
if (vmargs === null) {
return;
}
vmargs.forEach(arg => {
//remove all standalone double quotes
arg = arg.replace(/(\\)?"/g, function ($0, $1) { return ($1 ? $0 : ''); });
//unescape all escaped double quotes
arg = arg.replace(/(\\)"/g, '"');
if (params.indexOf(arg) < 0) {
params.push(arg);
}
});
if (!vmargsLine) {
return;
}
let vmargs = vmargsLine.match(/(?:[^\s"]+|"[^"]*")+/g);
if (vmargs === null) {
return;
}
vmargs.forEach(arg => {
//remove all standalone double quotes
arg = arg.replace(/(\\)?"/g, function ($0, $1) { return ($1 ? $0 : ''); });
//unescape all escaped double quotes
arg = arg.replace(/(\\)"/g, '"');
if (params.indexOf(arg) < 0) {
params.push(arg);
}
});
}

0 comments on commit e01d3e0

Please sign in to comment.