fix(java): explain recovery for unimported launch modules (#585)

Java launch preparation forwarded jdtls project-lookup failures unchanged, so a Maven module missing from the parent build or a wrongly inferred module showed a raw jdtls error in every Run and Debug entry point. Launch preparation now names the selected module and explains how to recover: wait for import, check the run configuration and the parent build, or open the folder as a project.

Covers the "does not belong to any Java project", "references non-existing project" and "not a Java project" responses. Cancellation, missing server, crash, timeout and build errors keep their existing handling. Import membership and module inference are unchanged.

Refs #197
Цей коміт міститься в:
l0ng-ai authored and GitHub committed 2026-10-31 23:56:19 +08:00
1 джерело 369c63979d
коміт 9dc736de09
4 files changed
+92 -6

No files matched your search

+24
Переглянути файл
@@ -118,6 +118,30 @@ it("still reports a real resolve failure in the preparation console", async () =
expect(ipc.debugStart).not.toHaveBeenCalled();
});
it.each([
"jdtls: Given URI does not belong to any Java project.",
"jdtls: Launch configuration 1793460461218 references non-existing project parent.",
])("explains how to import a module when Debug fails with %s", async (message) => {
const starting = executeAction("debug.startConfig", { ...config, module: "web" });
await vi.waitFor(() => expect(ipc.javaResolveLaunch).toHaveBeenCalledOnce());
respond({ status: "error", error: { kind: "protocol", message } });
await starting;
expect(notify).toHaveBeenLastCalledWith(
expect.objectContaining({
title: "Cannot start debugging",
body: expect.stringContaining("Java module 'web' is not imported."),
}),
);
expect(
Object.values(useDebug.getState().console)
.flat()
.map((line) => line.text)
.join("\n"),
).toContain("open its folder as a project");
expect(ipc.javaDebugServer).not.toHaveBeenCalled();
expect(ipc.debugStart).not.toHaveBeenCalled();
});
it("keeps progress and the originating configuration when DAP takes over", async () => {
const starting = executeAction("debug.startConfig", config);
await vi.waitFor(() => expect(ipc.javaResolveLaunch).toHaveBeenCalledOnce());