Skip to content

Commit

Permalink
simplified decompilation report generation
Browse files Browse the repository at this point in the history
  • Loading branch information
jpstotz committed Apr 30, 2023
1 parent 2d04a74 commit 8b91fb1
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.net.MalformedURLException;
import java.net.URL;

import org.benf.cfr.reader.util.CfrVersionInfo;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.IPropertyChangeListener;
Expand All @@ -18,6 +19,8 @@ public class CfrDecompilerPlugin extends AbstractUIPlugin implements IPropertyCh

public static final String decompilerType = "CFR"; //$NON-NLS-1$

public static final String decompilerVersion = CfrVersionInfo.VERSION;

private static CfrDecompilerPlugin plugin;

private IPreferenceStore preferenceStore;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

import java.util.Collection;

import org.benf.cfr.reader.util.CfrVersionInfo;
import org.eclipse.core.runtime.Path;
import org.sf.feeling.decompiler.cfr.CfrDecompilerPlugin;
import org.sf.feeling.decompiler.editor.BaseDecompilerSourceMapper;

public class CfrSourceMapper extends BaseDecompilerSourceMapper {
Expand All @@ -24,20 +24,22 @@ public CfrSourceMapper() {
@Override
protected void printDecompileReport(StringBuffer source, String fileLocation, Collection<Exception> exceptions,
long decompilationTime) {
String location = "\tDecompiled from: " //$NON-NLS-1$
+ fileLocation;
String logMsg = origionalDecompiler.getLog().replaceAll("\t", "") //$NON-NLS-1$ //$NON-NLS-2$
.replaceAll("\n\\s*", "\n\t"); //$NON-NLS-1$ //$NON-NLS-2$
source.append("\n\n/*"); //$NON-NLS-1$
source.append("\n\tDECOMPILATION REPORT\n\n"); //$NON-NLS-1$
source.append(location).append("\n"); //$NON-NLS-1$
source.append("\tTotal time: ") //$NON-NLS-1$
.append(decompilationTime).append(" ms\n"); //$NON-NLS-1$
source.append("\t" //$NON-NLS-1$
+ origionalDecompiler.getLog().replaceAll("\t", "") //$NON-NLS-1$ //$NON-NLS-2$
.replaceAll("\n\\s*", "\n\t")); //$NON-NLS-1$ //$NON-NLS-2$
source.append("\n\tDECOMPILATION REPORT\n"); //$NON-NLS-1$
source.append("\n\tDecompiled from: "); //$NON-NLS-1$
source.append(fileLocation);
source.append(decompilationTime);
source.append(" ms\n\t"); //$NON-NLS-1$
source.append(logMsg);
exceptions.addAll(origionalDecompiler.getExceptions());
logExceptions(exceptions, source);
source.append("\n\tDecompiled with CFR " + CfrVersionInfo.VERSION + "."); //$NON-NLS-1$
source.append("\n*/"); //$NON-NLS-1$
source.append("\n\tDecompiled with "); //$NON-NLS-1$
source.append(CfrDecompilerPlugin.decompilerType);
source.append(" version "); //$NON-NLS-1$
source.append(CfrDecompilerPlugin.decompilerVersion);
source.append(".\n*/"); //$NON-NLS-1$
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@
import org.osgi.framework.BundleContext;
import org.sf.feeling.decompiler.JavaDecompilerPlugin;

import com.strobel.Procyon;

public class ProcyonDecompilerPlugin extends AbstractUIPlugin implements IPropertyChangeListener {

public static final String PLUGIN_ID = "org.sf.feeling.decompiler.procyon"; //$NON-NLS-1$

public static final String decompilerType = "Procyon"; //$NON-NLS-1$

public static final String decompilerVersion = Procyon.version();

private static ProcyonDecompilerPlugin plugin;

private IPreferenceStore preferenceStore;
Expand Down Expand Up @@ -77,8 +81,9 @@ public static ImageDescriptor getImageDescriptor(String path) {
e.printStackTrace();
}
ImageDescriptor actionIcon = null;
if (url != null)
if (url != null) {
actionIcon = ImageDescriptor.createFromURL(url);
}
return actionIcon;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

import org.eclipse.core.runtime.Path;
import org.sf.feeling.decompiler.editor.BaseDecompilerSourceMapper;

import com.strobel.Procyon;
import org.sf.feeling.decompiler.procyon.ProcyonDecompilerPlugin;

public class ProcyonSourceMapper extends BaseDecompilerSourceMapper {

Expand All @@ -25,21 +24,24 @@ public ProcyonSourceMapper() {
@Override
protected void printDecompileReport(StringBuffer source, String fileLocation, Collection<Exception> exceptions,
long decompilationTime) {
String location = "\tDecompiled from: " //$NON-NLS-1$
+ fileLocation;
String logMsg = origionalDecompiler.getLog().replaceAll("\t", "") //$NON-NLS-1$ //$NON-NLS-2$
.replaceAll("\n\\s*", "\n\t"); //$NON-NLS-1$ //$NON-NLS-2$

source.append("\n\n/*"); //$NON-NLS-1$
source.append("\n\tDECOMPILATION REPORT\n\n"); //$NON-NLS-1$
source.append(location).append("\n"); //$NON-NLS-1$
source.append("\tTotal time: ") //$NON-NLS-1$
.append(decompilationTime).append(" ms\n"); //$NON-NLS-1$
source.append("\t" //$NON-NLS-1$
+ origionalDecompiler.getLog().replaceAll("\t", "") //$NON-NLS-1$ //$NON-NLS-2$
.replaceAll("\n\\s*", "\n\t")); //$NON-NLS-1$ //$NON-NLS-2$
source.append("\n\tDECOMPILATION REPORT\n"); //$NON-NLS-1$
source.append("\n\tDecompiled from: "); //$NON-NLS-1$
source.append(fileLocation);
source.append("\n\tTotal time: "); //$NON-NLS-1$
source.append(decompilationTime);
source.append(" ms\n\t"); //$NON-NLS-1$
source.append(logMsg);
exceptions.addAll(origionalDecompiler.getExceptions());
logExceptions(exceptions, source);
source.append("\n\tDecompiled with Procyon " //$NON-NLS-1$
+ Procyon.version() + "."); //$NON-NLS-1$
source.append("\n*/"); //$NON-NLS-1$
source.append("\n\tDecompiled with "); //$NON-NLS-1$
source.append(ProcyonDecompilerPlugin.decompilerType);
source.append(" version ");//$NON-NLS-1$
source.append(ProcyonDecompilerPlugin.decompilerVersion);
source.append(".\n*/"); //$NON-NLS-1$
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class QuiltflowerDecompilerPlugin extends AbstractUIPlugin implements IPr

public static final String decompilerType = "Quiltflower"; //$NON-NLS-1$

public static final String decompilerVersion = "1.9"; //$NON-NLS-1$

private static QuiltflowerDecompilerPlugin plugin;

private IPreferenceStore preferenceStore;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import org.eclipse.core.runtime.Path;
import org.sf.feeling.decompiler.editor.BaseDecompilerSourceMapper;
import org.sf.feeling.decompiler.quiltflower.QuiltflowerDecompilerPlugin;

public class QuiltflowerSourceMapper extends BaseDecompilerSourceMapper {

Expand All @@ -23,20 +24,24 @@ public QuiltflowerSourceMapper() {
@Override
protected void printDecompileReport(StringBuffer source, String fileLocation, Collection<Exception> exceptions,
long decompilationTime) {
String location = "\tDecompiled from: " //$NON-NLS-1$
+ fileLocation;
String logMsg = origionalDecompiler.getLog().replaceAll("\t", "") //$NON-NLS-1$ //$NON-NLS-2$
.replaceAll("\n\\s*", "\n\t"); //$NON-NLS-1$ //$NON-NLS-2$

source.append("\n\n/*"); //$NON-NLS-1$
source.append("\n\tDECOMPILATION REPORT\n\n"); //$NON-NLS-1$
source.append(location).append("\n"); //$NON-NLS-1$
source.append("\tTotal time: ") //$NON-NLS-1$
.append(decompilationTime).append(" ms\n"); //$NON-NLS-1$
source.append("\t" //$NON-NLS-1$
+ origionalDecompiler.getLog().replaceAll("\t", "") //$NON-NLS-1$ //$NON-NLS-2$
.replaceAll("\n\\s*", "\n\t")); //$NON-NLS-1$ //$NON-NLS-2$
source.append("\n\tDECOMPILATION REPORT\n"); //$NON-NLS-1$
source.append("\n\tDecompiled from: "); //$NON-NLS-1$
source.append(fileLocation);
source.append("\n\tTotal time: "); //$NON-NLS-1$
source.append(decompilationTime);
source.append(" ms\n\t"); //$NON-NLS-1$
source.append(logMsg);
exceptions.addAll(origionalDecompiler.getExceptions());
logExceptions(exceptions, source);
source.append("\n\tDecompiled with Quiltflower."); //$NON-NLS-1$
source.append("\n*/"); //$NON-NLS-1$
source.append("\n\tDecompiled with "); //$NON-NLS-1$
source.append(QuiltflowerDecompilerPlugin.decompilerType);
source.append(" version "); //$NON-NLS-1$
source.append(QuiltflowerDecompilerPlugin.decompilerVersion);
source.append(".\n*/"); //$NON-NLS-1$
}

}

0 comments on commit 8b91fb1

Please sign in to comment.