From e5267e2436f88864660752b082f0d677fed7dfa2 Mon Sep 17 00:00:00 2001 From: ReaJason Date: Sun, 30 Aug 2026 18:05:20 +0800 Subject: [PATCH] chore: remove decompile code comment --- web/app/lib/decompile/decompile.worker.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/web/app/lib/decompile/decompile.worker.ts b/web/app/lib/decompile/decompile.worker.ts index 8042bba8..9157eecb 100644 --- a/web/app/lib/decompile/decompile.worker.ts +++ b/web/app/lib/decompile/decompile.worker.ts @@ -69,11 +69,23 @@ function tokenizeToLines(code: string): TokenLine[] { return lines; } +/** CFR options: no "Could not load the following classes" list, no version banner */ +const CFR_OPTIONS = { comments: "false", showversion: "false" }; + +/** Strip CFR's leading "Decompiled with CFR" banner comment */ +function stripCfrBanner(source: string): string { + return source.replace(/^\/\*\r?\n \* Decompiled with CFR[\s\S]*?\*\/\r?\n?/, ""); +} + async function decompileClass( jvmClassName: string, classes: Map, ): Promise { - const source = await decompile(jvmClassName, { source: (name) => classes.get(name) ?? null }); + const raw = await decompile(jvmClassName, { + source: (name) => classes.get(name) ?? null, + options: CFR_OPTIONS, + }); + const source = stripCfrBanner(raw); return { source, lines: tokenizeToLines(source) }; }