Файли
openidea/src/features/tools/index.ts
T
l0ng-ai 56fdc005a8 feat(java): Download JDK, and one-click "Download JDK N" where a JDK is missing (#61)
Root cause: the IDE only detected installed JDKs and had no way to get one, so any launch needing a newer JDK than the machine has (latest jdtls needs JDK 25) dead-ended in an error.

Fix: IDEA-style Download JDK (Eclipse Temurin via the Adoptium API, sha256-verified, reusing ide-tools' download/verify code; Windows zip, Linux tar.gz, macOS Contents/Home) into <app-data>/tools/jdks, registered with JDK discovery and rescanned after each download. "Download JDK…" in the Project SDK and Language Server JDK pickers; a one-click `java.downloadJdk` "Download JDK N" on "needs JDK N" errors, which also repoints a too-old language server JDK and restarts jdtls.

Siblings: language server status popup, jdtls launch notification, run console classpath error, debug launch, run configurations without a JDK ≥ the module's Java version, Maven/Gradle sync failures, single-file Java run without `java` on PATH.

Verified in the app on macOS: vendor/version/location queries, the Download JDK dialog from the Language Server JDK picker, a real Temurin 25.0.5 download that runs. Not verified on Windows/Linux.

Fixes #49

https://claude.ai/code/session_01VUYsdXA2nkF5v6zsC93dpn
2026-10-27 12:09:51 +08:00

65 рядки
2.4 KiB
TypeScript
Неформатований Анотація Історія

Цей файл містить неоднозначні символи Юнікоду
Цей файл містить символи Юнікоду, які можна сплутати з іншими символами. Якщо ви вважаєте, що це зроблено навмисно, можете сміливо ігнорувати це попередження. Щоб показати їх, скористайтеся кнопкою Escape.
/**
* Tools installer: Settings › Languages & Frameworks › Language Servers, plus
* install prompts for missing language servers.
*
* Actions: `tools.languageServers` (open the page), `tools.install` (arg: tool name),
* `java.downloadJdk` (arg: `DownloadJdkArgs`).
*/
import { lazyComponent } from "@/ui";
import { executeAction, registerActions } from "@/platform/actions";
import { registerSettingsPage } from "@/workbench/contributions";
import { installJdkPrompts, registerJdkActions } from "./jdk";
import { installMissingServerPrompts } from "./missing";
import { installTool, refreshTools, SETTINGS_PAGE_ID, toolByName, useTools } from "./store";
/** The Language Servers page (also used by the Settings window). */
export function activateSettingsPages(): () => void {
return registerSettingsPage({
id: SETTINGS_PAGE_ID,
title: "Language Servers",
group: "Languages & Frameworks",
order: 400,
keywords: ["lsp", "language server", "debugger", "adapter", "dap", "install", "rust-analyzer", "gopls", "pyright"],
component: lazyComponent(() => import("./LanguageServersPage").then((m) => m.LanguageServersPage)),
});
}
export function activate(): () => void {
const disposers = [
activateSettingsPages(),
registerActions([
{
id: "tools.languageServers",
title: "Language Servers…",
category: "Tools",
icon: "package",
keywords: ["lsp", "install", "debugger", "adapter"],
run: () => void executeAction("file.settings", SETTINGS_PAGE_ID),
},
{
id: "tools.install",
title: "Install Language Server / Debugger",
category: "Tools",
hidden: true,
// Tools the IDE can't install (no recipe, missing npm/curl) open the page with the manual hint.
run: async ({ arg }) => {
if (typeof arg === "string") {
if (!useTools.getState().loaded) await refreshTools();
const tool = toolByName(arg);
// Unknown because the list failed to load: try anyway, so the failure is reported.
if (tool ? tool.canInstall : useTools.getState().error !== null) {
await installTool(arg);
return;
}
}
await executeAction("file.settings", SETTINGS_PAGE_ID);
},
},
]),
installMissingServerPrompts(),
registerJdkActions(),
installJdkPrompts(),
];
return () => disposers.reverse().forEach((d) => d());
}