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 { ...@@ -47,6 +47,10 @@ public class JadxCLIArgs implements IJadxArgs {
@Parameter(names = {"--show-bad-code"}, description = "show inconsistent code (incorrectly decompiled)") @Parameter(names = {"--show-bad-code"}, description = "show inconsistent code (incorrectly decompiled)")
protected boolean showInconsistentCode = false; 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, @Parameter(names = "--no-replace-consts", converter = InvertedBooleanConverter.class,
description = "don't replace constant value with matching constant field") description = "don't replace constant value with matching constant field")
protected boolean replaceConsts = true; protected boolean replaceConsts = true;
...@@ -247,6 +251,11 @@ public class JadxCLIArgs implements IJadxArgs { ...@@ -247,6 +251,11 @@ public class JadxCLIArgs implements IJadxArgs {
} }
@Override @Override
public boolean isUsingImports() {
return useImports;
}
@Override
public boolean isVerbose() { public boolean isVerbose() {
return verbose; return verbose;
} }
......
...@@ -15,6 +15,8 @@ public interface IJadxArgs { ...@@ -15,6 +15,8 @@ public interface IJadxArgs {
boolean isShowInconsistentCode(); boolean isShowInconsistentCode();
boolean isUsingImports();
boolean isVerbose(); boolean isVerbose();
boolean isSkipResources(); boolean isSkipResources();
......
...@@ -14,6 +14,8 @@ public class JadxArgs implements IJadxArgs { ...@@ -14,6 +14,8 @@ public class JadxArgs implements IJadxArgs {
private boolean fallbackMode = false; private boolean fallbackMode = false;
private boolean showInconsistentCode = false; private boolean showInconsistentCode = false;
private boolean useImports = false;
private boolean isSkipResources = false; private boolean isSkipResources = false;
private boolean isSkipSources = false; private boolean isSkipSources = false;
...@@ -83,6 +85,15 @@ public class JadxArgs implements IJadxArgs { ...@@ -83,6 +85,15 @@ public class JadxArgs implements IJadxArgs {
} }
@Override @Override
public boolean isUsingImports() {
return useImports;
}
public void setUseImports(boolean useImports) {
this.useImports = useImports;
}
@Override
public boolean isVerbose() { public boolean isVerbose() {
return isVerbose; return isVerbose;
} }
......
...@@ -52,23 +52,25 @@ public class ClassGen { ...@@ -52,23 +52,25 @@ public class ClassGen {
private final ClassGen parentGen; private final ClassGen parentGen;
private final AnnotationGen annotationGen; private final AnnotationGen annotationGen;
private final boolean fallback; private final boolean fallback;
private final boolean useImports;
private final boolean showInconsistentCode; private final boolean showInconsistentCode;
private final Set<ClassInfo> imports = new HashSet<>(); private final Set<ClassInfo> imports = new HashSet<>();
private int clsDeclLine; private int clsDeclLine;
public ClassGen(ClassNode cls, IJadxArgs jadxArgs) { 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) { 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.cls = cls;
this.parentGen = parentClsGen; this.parentGen = parentClsGen;
this.fallback = fallback; this.fallback = fallback;
this.useImports = useImports;
this.showInconsistentCode = showBadCode; this.showInconsistentCode = showBadCode;
this.annotationGen = new AnnotationGen(cls, this); this.annotationGen = new AnnotationGen(cls, this);
...@@ -480,7 +482,7 @@ public class ClassGen { ...@@ -480,7 +482,7 @@ public class ClassGen {
private String useClassInternal(ClassInfo useCls, ClassInfo extClsInfo) { private String useClassInternal(ClassInfo useCls, ClassInfo extClsInfo) {
String fullName = extClsInfo.getFullName(); String fullName = extClsInfo.getFullName();
if (fallback) { if (fallback || !useImports) {
return fullName; return fullName;
} }
String shortName = extClsInfo.getShortName(); String shortName = extClsInfo.getShortName();
......
...@@ -245,7 +245,7 @@ public class MethodGen { ...@@ -245,7 +245,7 @@ public class MethodGen {
* Return fallback variant of method codegen * Return fallback variant of method codegen
*/ */
public static MethodGen getFallbackMethodGen(MethodNode mth) { 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); 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