Commit 5d60f2cd authored by Sergey Toshin's avatar Sergey Toshin

PR for issue #191

parent c4765939
......@@ -47,6 +47,10 @@ public class JadxCLIArgs implements IJadxArgs {
@Parameter(names = {"--show-bad-code"}, description = "show inconsistent code (incorrectly decompiled)")
protected boolean showInconsistentCode = false;
@Parameter(names = {"--no-imports"}, converter = InvertedBooleanConverter.class,
description = "disables use of imports, always writes entire package name")
protected boolean useImports = true;
@Parameter(names = "--no-replace-consts", converter = InvertedBooleanConverter.class,
description = "don't replace constant value with matching constant field")
protected boolean replaceConsts = true;
......@@ -247,6 +251,11 @@ public class JadxCLIArgs implements IJadxArgs {
}
@Override
public boolean isUsingImports() {
return useImports;
}
@Override
public boolean isVerbose() {
return verbose;
}
......
......@@ -14,6 +14,8 @@ public interface IJadxArgs {
boolean isFallbackMode();
boolean isShowInconsistentCode();
boolean isUsingImports();
boolean isVerbose();
......
......@@ -13,6 +13,8 @@ public class JadxArgs implements IJadxArgs {
private boolean isVerbose = false;
private boolean fallbackMode = false;
private boolean showInconsistentCode = false;
private boolean useImports = false;
private boolean isSkipResources = false;
private boolean isSkipSources = false;
......@@ -83,6 +85,15 @@ public class JadxArgs implements IJadxArgs {
}
@Override
public boolean isUsingImports() {
return useImports;
}
public void setUseImports(boolean useImports) {
this.useImports = useImports;
}
@Override
public boolean isVerbose() {
return isVerbose;
}
......
......@@ -52,23 +52,25 @@ public class ClassGen {
private final ClassGen parentGen;
private final AnnotationGen annotationGen;
private final boolean fallback;
private final boolean useImports;
private final boolean showInconsistentCode;
private final Set<ClassInfo> imports = new HashSet<>();
private int clsDeclLine;
public ClassGen(ClassNode cls, IJadxArgs jadxArgs) {
this(cls, null, jadxArgs.isFallbackMode(), jadxArgs.isShowInconsistentCode());
this(cls, null, jadxArgs.isUsingImports(), jadxArgs.isFallbackMode(), jadxArgs.isShowInconsistentCode());
}
public ClassGen(ClassNode cls, ClassGen parentClsGen) {
this(cls, parentClsGen, parentClsGen.fallback, parentClsGen.showInconsistentCode);
this(cls, parentClsGen, parentClsGen.useImports, parentClsGen.fallback, parentClsGen.showInconsistentCode);
}
public ClassGen(ClassNode cls, ClassGen parentClsGen, boolean fallback, boolean showBadCode) {
public ClassGen(ClassNode cls, ClassGen parentClsGen, boolean useImports, boolean fallback, boolean showBadCode) {
this.cls = cls;
this.parentGen = parentClsGen;
this.fallback = fallback;
this.useImports = useImports;
this.showInconsistentCode = showBadCode;
this.annotationGen = new AnnotationGen(cls, this);
......@@ -480,7 +482,7 @@ public class ClassGen {
private String useClassInternal(ClassInfo useCls, ClassInfo extClsInfo) {
String fullName = extClsInfo.getFullName();
if (fallback) {
if (fallback || !useImports) {
return fullName;
}
String shortName = extClsInfo.getShortName();
......
......@@ -245,7 +245,7 @@ public class MethodGen {
* Return fallback variant of method codegen
*/
public static MethodGen getFallbackMethodGen(MethodNode mth) {
ClassGen clsGen = new ClassGen(mth.getParentClass(), null, true, true);
ClassGen clsGen = new ClassGen(mth.getParentClass(), null, true, true, true);
return new MethodGen(clsGen, mth);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment