async function findDefaultRuntimeFromSettings()

in src/java-runtime/utils/upstreamApi.ts [127:150]


async function findDefaultRuntimeFromSettings(): Promise<string | undefined> {
    const runtimes = workspace.getConfiguration().get("java.configuration.runtimes");
    if (Array.isArray(runtimes) && runtimes.length) {
        let candidate: string | undefined;
        for (const runtime of runtimes) {
            if (!runtime || typeof runtime !== 'object' || !runtime.path) {
                continue;
            }

            const jr = await getRuntime(runtime.path);
            if (jr) {
                candidate = jr.homedir;
            }

            if (runtime.default) {
                break;
            }
        }

        return candidate;
    }

    return undefined;
}