Файли
openidea/src/features/debugger/breakpoints/languages.ts
T
l0ng-ai 482241ebb9 feat(java): open class files as decompiled sources with breakpoints (#657)
Opening a .class file showed binary content. Class files from library jars, project output directories, navigation, Go to Class and debugger frames now all go through one route to JDT class documents:

- Library classes open the attached source, or the FernFlower decompilation when there is none, read-only and marked as decompiled. java-debug's decompiled-source support is enabled, so breakpoints set in decompiled code map to the original lines and hit, and stepping into such classes lands on the right line.
- Output-directory classes (target/classes, build/classes) open their project source when it exists; otherwise the decompiled text is shown read-only with breakpoints disabled, because jdt.ls returns no line mapping for classes outside the Java model.
- The preferred content provider id is corrected to fernflowerContentProvider (attached sources still win), and the decompiled marker recognises the current FernFlower header.

Verified on macOS with a Maven project: library class from Libraries and Go to Class, breakpoint hit and step into decompiled code, output class with and without source. Not run on Windows, Linux or Gradle projects.

Fixes #394
2026-11-01 15:04:28 +08:00

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

Цей файл містить неоднозначні символи Юнікоду
Цей файл містить символи Юнікоду, які можна сплутати з іншими символами. Якщо ви вважаєте, що це зроблено навмисно, можете сміливо ігнорувати це попередження. Щоб показати їх, скористайтеся кнопкою Escape.
/**
* Settings › Debugger › Breakpoints › "Allow placing breakpoints in any file":
* when off, new line breakpoints go only into files of languages that have a
* debug adapter (`languages/*.toml` `[debugger]`).
*/
import { classFileBreakpointReason } from "@/platform/classFiles";
import { commands, isTauri } from "@/platform/ipc";
import { workflowSettings } from "@/platform/workflowSettings";
let debuggable: Set<string> | null = null;
let loading = false;
function load() {
if (debuggable || loading || !isTauri()) return;
loading = true;
commands
.languages()
.then((langs) => {
debuggable = new Set(langs.filter((l) => l.debuggable).map((l) => l.id));
})
.catch(() => undefined)
.finally(() => (loading = false));
}
/** Whether a new breakpoint may be placed in a file of `language`. */
export function canPlaceBreakpoint(language: string, path = ""): boolean {
if (classFileBreakpointReason(path)) return false;
if (workflowSettings().debugger.breakpointsAnyFile) return true;
load();
// Until the language list is known, don't block anything.
return !debuggable || debuggable.has(language);
}