java-decompiler: fixes and cleanups
- console decompiler: resource closing, lookup instead of scan, error reporting - logger interface reworked - saver interface renamed - bytecode provider returns byte array (to reduce stream leakage) - extra level of context unit avoided - unneeded exceptions, dead code, formatting
This commit is contained in:
@@ -18,7 +18,8 @@ package org.jetbrains.java.decompiler.main;
|
||||
import org.jetbrains.java.decompiler.main.ClassesProcessor.ClassNode;
|
||||
import org.jetbrains.java.decompiler.main.collectors.CounterContainer;
|
||||
import org.jetbrains.java.decompiler.main.extern.IBytecodeProvider;
|
||||
import org.jetbrains.java.decompiler.main.extern.IDecompilatSaver;
|
||||
import org.jetbrains.java.decompiler.main.extern.IFernflowerLogger;
|
||||
import org.jetbrains.java.decompiler.main.extern.IResultSaver;
|
||||
import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences;
|
||||
import org.jetbrains.java.decompiler.modules.renamer.IdentifierConverter;
|
||||
import org.jetbrains.java.decompiler.struct.IDecompiledData;
|
||||
@@ -28,16 +29,16 @@ import org.jetbrains.java.decompiler.struct.lazy.LazyLoader;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class Fernflower implements IDecompiledData {
|
||||
|
||||
private StructContext structContext;
|
||||
private ClassesProcessor classesProcessor;
|
||||
|
||||
public Fernflower(IBytecodeProvider provider, IDecompilatSaver saver, Map<String, Object> propertiesCustom) {
|
||||
public Fernflower(IBytecodeProvider provider, IResultSaver saver, Map<String, Object> options, IFernflowerLogger logger) {
|
||||
structContext = new StructContext(saver, this, new LazyLoader(provider));
|
||||
DecompilerContext.initContext(propertiesCustom);
|
||||
DecompilerContext.initContext(options);
|
||||
DecompilerContext.setCounterContainer(new CounterContainer());
|
||||
DecompilerContext.setLogger(logger);
|
||||
}
|
||||
|
||||
public void decompileContext() {
|
||||
@@ -57,6 +58,11 @@ public class Fernflower implements IDecompiledData {
|
||||
DecompilerContext.setCurrentContext(null);
|
||||
}
|
||||
|
||||
public StructContext getStructContext() {
|
||||
return structContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClassEntryName(StructClass cl, String entryName) {
|
||||
ClassNode node = classesProcessor.getMapRootClasses().get(cl.qualifiedName);
|
||||
if (node.type != ClassNode.CLASS_ROOT) {
|
||||
@@ -73,10 +79,7 @@ public class Fernflower implements IDecompiledData {
|
||||
}
|
||||
}
|
||||
|
||||
public StructContext getStructContext() {
|
||||
return structContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClassContent(StructClass cl) {
|
||||
try {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
Reference in New Issue
Block a user