Порівняти коміти

..
Автор SHA1 Повідомлення Дата
l0ng-ai b27cb56093 fix(hierarchy): load library types' levels from their language server
The type hierarchy opened every node's document from disk, so a JDK or
dependency type (a jdt:// URI) failed with "No such file or directory":
its look-ahead load failed silently, leaving an expand arrow on every
library type, and expanding one showed "failed to load". Library URIs
now open as virtual documents, like the other withDocument helper does.

Fixes #3409
2026-11-17 20:24:18 +08:00
4 змінених файлів з 37 додано та 25 видалено

No files matched your search

+29
Переглянути файл
@@ -0,0 +1,29 @@
import { describe, expect, it, vi } from "vitest";
const opened = vi.hoisted(() => [] as string[]);
vi.mock("@/platform/ipc", async (importOriginal) => {
const ipc = await importOriginal<typeof import("@/platform/ipc")>();
const doc = (path: string) => Promise.resolve({ status: "ok", data: { id: 3, path } });
return {
...ipc,
isTauri: () => true,
commands: {
...ipc.commands,
docOpen: (path: string) => (opened.push(`file ${path}`), doc(path)),
docOpenVirtual: (uri: string) => (opened.push(`virtual ${uri}`), doc(uri)),
docClose: () => Promise.resolve(),
},
};
});
const { withDocument } = await import("./ipc");
describe("withDocument", () => {
it("opens a library type through its language server, a project file from disk", async () => {
const uri = "jdt://contents/java.base/java.util/UUID.class?=demo/%5C/jdk%5C/lib%5C/jrt-fs.jar%60java.base";
await withDocument(uri, async (doc) => doc);
await withDocument("/p/src/App.java", async (doc) => doc);
expect(opened).toEqual([`virtual ${uri}`, "file /p/src/App.java"]);
});
});
+2 -1
Переглянути файл
@@ -134,7 +134,8 @@ export async function readManyFileLines(
export async function withDocument<T>(path: string, fn: (doc: number) => Promise<T>): Promise<T> {
const open = editorsFor(path)[0];
if (open) return fn(open.ctx.doc);
const info = await lspRequest(() => commands.docOpen(path));
// Library types (`jdt://…`) are documents the language server provides, not files on disk.
const info = await lspRequest(() => (isVirtualUri(path) ? commands.docOpenVirtual(path) : commands.docOpen(path)));
try {
return await fn(info.id);
} finally {
-18
Переглянути файл
@@ -176,24 +176,6 @@ describe("run config → launch config", () => {
expect(extra(uv)).toMatchObject({ python: ["uv", "run", "python"], debugLauncherPython: "python" });
});
it("debugpy: a Windows venv interpreter or tool path debugs with that interpreter", () => {
usePlatform.setState({ os: "windows" });
const venv = "C:\\work\\app\\.venv\\Scripts\\";
const script = launchConfigFor(
rc({ kind: "python", command: `${venv}python.exe`, args: ["main.py"], debugAdapter: "debugpy" }),
"C:/work/app",
)!;
expect(extra(script).python).toBe(`${venv}python.exe`);
expect(extra(script).module).toBeUndefined();
expect(script.program).toBe("C:/work/app/main.py");
const pytest = launchConfigFor(
rc({ kind: "pytest", command: `${venv}pytest.exe`, args: ["-x"], debugAdapter: "debugpy" }),
"C:/work/app",
)!;
expect(extra(pytest)).toMatchObject({ module: "pytest", python: `${venv}python.exe` });
});
it("js-debug: npm scripts run through the package manager, node scripts directly", () => {
const npm = launchConfigFor(
rc({ kind: "npm", command: "pnpm", args: ["run", "dev"], cwd: "web", debugAdapter: "js-debug" }),
+6 -6
Переглянути файл
@@ -76,7 +76,7 @@ function cargoLaunch(rc: RunConfig, cwd: string, adapter: string): LaunchConfig
};
}
const PYTHON_NAME = /^python[\d.]*(\.exe)?$/i;
const PYTHON_NAME = /^python[\d.]*(\.exe)?$/;
/** `python` on Windows (`python3` is at most a Store alias there, and venvs have no `python3.exe`), `python3` elsewhere. */
function systemPython(): string {
@@ -85,10 +85,10 @@ function systemPython(): string {
function pythonFor(rc: RunConfig, cwd: string): string {
const cmd = rc.command;
if (PYTHON_NAME.test(commandName(cmd))) return resolveCommand(cmd, cwd);
// A venv tool such as `.venv/bin/pytest` or `.venv\Scripts\pytest.exe`: use the interpreter next to it.
const dir = cmd.slice(0, Math.max(cmd.lastIndexOf("/"), cmd.lastIndexOf("\\")) + 1);
if (dir) return resolveCommand(dir + (hostOs() === "windows" ? "python.exe" : "python"), cwd);
const name = cmd.split("/").pop() ?? cmd;
if (PYTHON_NAME.test(name)) return resolveCommand(cmd, cwd);
// A venv tool such as `.venv/bin/pytest`: use the interpreter next to it.
if (cmd.includes("/")) return resolveCommand(cmd.slice(0, cmd.lastIndexOf("/") + 1) + "python", cwd);
return systemPython();
}
@@ -107,7 +107,7 @@ function debugpyLaunch(rc: RunConfig, cwd: string): LaunchConfig {
subProcess: dbg.python.attachSubprocess,
};
if (dbg.python.gevent) extra.gevent = true;
const name = commandName(rc.command);
const name = (rc.command.split("/").pop() ?? rc.command).replace(/\.exe$/, "");
let args = rc.args;
let tool: string | null = PYTHON_NAME.test(name) ? null : name;
if (PYTHON_RUNNERS.has(name) && args[0] === "run" && args[1]) {