From c0892ab3b6ec67f85b813ab610356b8dfc6eba2f Mon Sep 17 00:00:00 2001 From: AlexTMjugador Date: Sat, 24 Oct 2020 17:05:09 +0200 Subject: Do not abort decompile command on decompiler errors As explained in PR #289, the decompilers may fail decompiling some vanilla Minecraft classes. Although it is my opinion that these errors should be fixed in the decompilers themselves, currently they render the decompile CLI command useless, as no output is produced whatsoever. The PR that was mentioned previously addressed this situation for the GUI part of Enigma, but not for the CLI commands, which were left untouched. These changes modify the decompiler error strategy used by the aforementioned CLI command to trace the errors, but continue decompiling classes, so at least a partial output is generated. This way users will be happy that the Enigma decompile command works, and developers will still be motivated to fix the underlying issues. Signed-off-by: AlexTMjugador --- enigma-cli/src/main/java/cuchaz/enigma/command/DecompileCommand.java | 3 ++- enigma/src/main/java/cuchaz/enigma/EnigmaProject.java | 4 ---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/enigma-cli/src/main/java/cuchaz/enigma/command/DecompileCommand.java b/enigma-cli/src/main/java/cuchaz/enigma/command/DecompileCommand.java index cc628639..12a4e886 100644 --- a/enigma-cli/src/main/java/cuchaz/enigma/command/DecompileCommand.java +++ b/enigma-cli/src/main/java/cuchaz/enigma/command/DecompileCommand.java @@ -2,6 +2,7 @@ package cuchaz.enigma.command; import cuchaz.enigma.EnigmaProject; import cuchaz.enigma.ProgressListener; +import cuchaz.enigma.EnigmaProject.DecompileErrorStrategy; import cuchaz.enigma.source.DecompilerService; import cuchaz.enigma.source.Decompilers; @@ -47,7 +48,7 @@ public class DecompileCommand extends Command { ProgressListener progress = new ConsoleProgressListener(); EnigmaProject.JarExport jar = project.exportRemappedJar(progress); - EnigmaProject.SourceExport source = jar.decompile(progress, decompilerService); + EnigmaProject.SourceExport source = jar.decompile(progress, decompilerService, DecompileErrorStrategy.TRACE_AS_SOURCE); source.write(fileJarOut, progress); } diff --git a/enigma/src/main/java/cuchaz/enigma/EnigmaProject.java b/enigma/src/main/java/cuchaz/enigma/EnigmaProject.java index f6420d2b..fcd2c96a 100644 --- a/enigma/src/main/java/cuchaz/enigma/EnigmaProject.java +++ b/enigma/src/main/java/cuchaz/enigma/EnigmaProject.java @@ -216,10 +216,6 @@ public class EnigmaProject { } } - public SourceExport decompile(ProgressListener progress, DecompilerService decompilerService) { - return this.decompile(progress, decompilerService, DecompileErrorStrategy.PROPAGATE); - } - public SourceExport decompile(ProgressListener progress, DecompilerService decompilerService, DecompileErrorStrategy errorStrategy) { List decompiled = this.decompileStream(progress, decompilerService, errorStrategy).collect(Collectors.toList()); return new SourceExport(decompiled); -- cgit v1.2.3