fix(debugger): debug Kotlin with kotlin-lsp without asking for kotlin-debug-adapter (#3274)

Since #3172, debugging a Maven / Gradle run of a module with Kotlin sources stopped before the
build and asked to install kotlin-debug-adapter whenever it was missing, although the backend
debugs Kotlin with kotlin-lsp's own debugger when kotlin-lsp is installed and only falls back
to kotlin-debug-adapter when it can't. The check now offers kotlin-debug-adapter only when
neither is installed.
This commit is contained in:
l0ng-ai
2026-11-14 11:03:32 +08:00
committed by GitHub
parent ba0f4329ea
commit 009773c0d4
2 changed files with 36 additions and 3 deletions
+5 -2
View File
@@ -20,6 +20,7 @@ import { withEnvFiles } from "./launch";
export const JAVA_ADAPTER = "java-debug";
export const KOTLIN_ADAPTER = "kotlin-debug-adapter";
const KOTLIN_LSP = "kotlin-lsp";
export function isJavaDebuggable(rc: RunConfig): boolean {
return isJvmApplication(rc) && [JAVA_ADAPTER, KOTLIN_ADAPTER].includes(rc.debugAdapter ?? JAVA_ADAPTER);
@@ -83,12 +84,14 @@ export async function moduleHasKotlinSources(cwd: string): Promise<boolean> {
/**
* Whether the debugger for the JVMs of `module` is installed. Maven / Gradle start those JVMs
* before the debugger attaches, so a missing Kotlin debugger is offered here, before the build
* runs: "Install and Debug" installs it and calls `retry`.
* runs: "Install and Debug" installs it and calls `retry`. An installed kotlin-lsp debugs Kotlin
* itself (the backend falls back to kotlin-debug-adapter only when it can't).
*/
export async function jvmAttachDebuggerReady(module: string, root: string, retry: () => void): Promise<boolean> {
if (!(await moduleHasKotlinSources(module ? join(root, module) : root))) return true;
const tools = await call(commands.toolsList()).catch(() => []);
if (tools.find((t) => t.name === KOTLIN_ADAPTER)?.status !== "missing") return true;
const missing = (name: string) => tools.find((t) => t.name === name)?.status === "missing";
if (!missing(KOTLIN_ADAPTER) || !missing(KOTLIN_LSP)) return true;
notifications().notify({
group: "run",
level: "warning",