mirror of
https://github.com/revanced/smali.git
synced 2025-05-23 18:16:23 +02:00
Fix how parameter delegates are handled
This commit is contained in:
parent
c12b7e6e00
commit
9f794030da
@ -34,6 +34,7 @@ package org.jf.baksmali;
|
||||
import com.beust.jcommander.JCommander;
|
||||
import com.beust.jcommander.Parameter;
|
||||
import com.beust.jcommander.Parameters;
|
||||
import com.beust.jcommander.ParametersDelegate;
|
||||
import org.jf.baksmali.AnalysisArguments.CheckPackagePrivateArgument;
|
||||
import org.jf.dexlib2.analysis.CustomInlineMethodResolver;
|
||||
import org.jf.dexlib2.analysis.InlineMethodResolver;
|
||||
@ -52,6 +53,8 @@ import java.util.List;
|
||||
commandName = "deodex",
|
||||
commandAliases = { "de", "x" })
|
||||
public class DeodexCommand extends DisassembleCommand {
|
||||
|
||||
@ParametersDelegate
|
||||
protected CheckPackagePrivateArgument checkPackagePrivateArgument = new CheckPackagePrivateArgument();
|
||||
|
||||
@Parameter(names = {"--inline-table", "--inline", "--it"},
|
||||
@ -65,10 +68,6 @@ public class DeodexCommand extends DisassembleCommand {
|
||||
super(commandAncestors);
|
||||
}
|
||||
|
||||
@Override protected void setupCommand(JCommander jc) {
|
||||
jc.addObject(checkPackagePrivateArgument);
|
||||
}
|
||||
|
||||
@Override protected BaksmaliOptions getOptions(DexFile dexFile) {
|
||||
BaksmaliOptions options = super.getOptions(dexFile);
|
||||
|
||||
|
@ -34,6 +34,7 @@ package org.jf.baksmali;
|
||||
import com.beust.jcommander.JCommander;
|
||||
import com.beust.jcommander.Parameter;
|
||||
import com.beust.jcommander.Parameters;
|
||||
import com.beust.jcommander.ParametersDelegate;
|
||||
import com.beust.jcommander.validators.PositiveInteger;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
@ -62,6 +63,7 @@ public class DisassembleCommand extends DexInputCommand {
|
||||
description = "Show usage information for this command.")
|
||||
private boolean help;
|
||||
|
||||
@ParametersDelegate
|
||||
protected AnalysisArguments analysisArguments = new AnalysisArguments();
|
||||
|
||||
@Parameter(names = {"--debug-info", "--di"}, arity = 1,
|
||||
@ -137,10 +139,6 @@ public class DisassembleCommand extends DexInputCommand {
|
||||
super(commandAncestors);
|
||||
}
|
||||
|
||||
@Override protected void setupCommand(JCommander jc) {
|
||||
jc.addObject(analysisArguments);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
if (help || inputList == null || inputList.isEmpty()) {
|
||||
usage();
|
||||
|
@ -34,6 +34,7 @@ package org.jf.baksmali;
|
||||
import com.beust.jcommander.JCommander;
|
||||
import com.beust.jcommander.Parameter;
|
||||
import com.beust.jcommander.Parameters;
|
||||
import com.beust.jcommander.ParametersDelegate;
|
||||
import org.jf.dexlib2.analysis.ClassPath;
|
||||
import org.jf.dexlib2.analysis.ClassProto;
|
||||
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||
@ -57,16 +58,13 @@ public class ListFieldOffsetsCommand extends DexInputCommand {
|
||||
description = "Show usage information")
|
||||
private boolean help;
|
||||
|
||||
@ParametersDelegate
|
||||
private AnalysisArguments analysisArguments = new AnalysisArguments();
|
||||
|
||||
public ListFieldOffsetsCommand(@Nonnull List<JCommander> commandAncestors) {
|
||||
super(commandAncestors);
|
||||
}
|
||||
|
||||
@Override protected void setupCommand(JCommander jc) {
|
||||
jc.addObject(analysisArguments);
|
||||
}
|
||||
|
||||
@Override public void run() {
|
||||
if (help || inputList == null || inputList.isEmpty()) {
|
||||
usage();
|
||||
|
@ -59,6 +59,7 @@ public class ListVtablesCommand extends DexInputCommand {
|
||||
description = "Show usage information")
|
||||
private boolean help;
|
||||
|
||||
@ParametersDelegate
|
||||
private AnalysisArguments analysisArguments = new AnalysisArguments();
|
||||
|
||||
@ParametersDelegate
|
||||
@ -73,11 +74,6 @@ public class ListVtablesCommand extends DexInputCommand {
|
||||
super(commandAncestors);
|
||||
}
|
||||
|
||||
@Override protected void setupCommand(JCommander jc) {
|
||||
jc.addObject(analysisArguments);
|
||||
jc.addObject(checkPackagePrivateArgument);
|
||||
}
|
||||
|
||||
@Override public void run() {
|
||||
if (help || inputList == null || inputList.isEmpty()) {
|
||||
usage();
|
||||
|
@ -32,6 +32,7 @@
|
||||
package org.jf.util.jcommander;
|
||||
|
||||
import com.beust.jcommander.JCommander;
|
||||
import com.beust.jcommander.ParameterDescription;
|
||||
import com.beust.jcommander.Parameterized;
|
||||
import com.beust.jcommander.Parameters;
|
||||
|
||||
@ -98,10 +99,10 @@ public class ExtendedCommands {
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static String[] parameterArgumentNames(JCommander jc, Parameterized parameterized) {
|
||||
// TODO: this won't work if we're using additional objects to collect parameters
|
||||
public static String[] parameterArgumentNames(ParameterDescription parameterDescription) {
|
||||
Parameterized parameterized = parameterDescription.getParameterized();
|
||||
|
||||
Class cls = jc.getObjects().get(0).getClass();
|
||||
Class cls = parameterDescription.getObject().getClass();
|
||||
Field field = null;
|
||||
while (cls != Object.class) {
|
||||
try {
|
||||
|
@ -163,8 +163,7 @@ public class HelpFormatter {
|
||||
}
|
||||
|
||||
if (leafJc.getMainParameter() != null) {
|
||||
String[] argumentNames = ExtendedCommands.parameterArgumentNames(
|
||||
leafJc, leafJc.getMainParameter().getParameterized());
|
||||
String[] argumentNames = ExtendedCommands.parameterArgumentNames(leafJc.getMainParameter());
|
||||
if (argumentNames.length == 0) {
|
||||
writer.write(" <args>");
|
||||
} else {
|
||||
@ -200,8 +199,7 @@ public class HelpFormatter {
|
||||
writer.write(Joiner.on(',').join(param.getParameter().names()));
|
||||
}
|
||||
if (getParameterArity(param) > 0) {
|
||||
String[] argumentNames = ExtendedCommands.parameterArgumentNames(
|
||||
leafJc, param.getParameterized());
|
||||
String[] argumentNames = ExtendedCommands.parameterArgumentNames(param);
|
||||
for (int i = 0; i < getParameterArity(param); i++) {
|
||||
writer.write(" ");
|
||||
if (i < argumentNames.length) {
|
||||
@ -242,8 +240,7 @@ public class HelpFormatter {
|
||||
}
|
||||
|
||||
if (leafJc.getMainParameter() != null) {
|
||||
String[] argumentNames = ExtendedCommands.parameterArgumentNames(leafJc,
|
||||
leafJc.getMainParameter().getParameterized());
|
||||
String[] argumentNames = ExtendedCommands.parameterArgumentNames(leafJc.getMainParameter());
|
||||
writer.write("\n");
|
||||
writer.indent(4);
|
||||
if (argumentNames.length > 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user