function convertToJavaProcess()

in src/processPicker.ts [19:47]


function convertToJavaProcess(pid: number, command: string, args: string): IJavaProcess | undefined {
    if (process.platform === "win32" && command.indexOf("\\??\\") === 0) {
        // remove leading device specifier
        command = command.replace("\\??\\", "");
    }

    const simpleName = path.basename(command, ".exe");
    if (JAVA_PATTERN.test(simpleName) && args) {
        const match = args.match(DEBUG_MODE_PATTERN);
        if (match && match.length) {
            const address = match[2].split("=")[1].split(":");
            const hostName = address.length > 1 ? address[0] : "127.0.0.1";
            const debugPort = parseInt(address[address.length - 1], 10);
            const exeName = path.basename(command);
            const binPath = path.dirname(command);
            const commandPath = path.basename(binPath) === "bin" ?
                path.join(path.basename(path.dirname(binPath)), "bin", exeName) : exeName;
            return {
                pid,
                command: commandPath,
                args,
                hostName,
                debugPort,
            };
        }
    }

    return undefined;
}