Search in sources :

Example 1 with AnnotatedCodeWriter

use of jadx.api.impl.AnnotatedCodeWriter in project jadx by skylot.

the class JsonCodeGen method addMethods.

private void addMethods(ClassNode cls, JsonClass jsonCls, ClassGen classGen) {
    jsonCls.setMethods(new ArrayList<>());
    for (MethodNode mth : cls.getMethods()) {
        if (mth.contains(AFlag.DONT_GENERATE)) {
            continue;
        }
        JsonMethod jsonMth = new JsonMethod();
        jsonMth.setName(mth.getName());
        if (mth.getMethodInfo().hasAlias()) {
            jsonMth.setAlias(mth.getAlias());
        }
        jsonMth.setSignature(mth.getMethodInfo().getShortId());
        jsonMth.setReturnType(getTypeAlias(mth.getReturnType()));
        jsonMth.setArguments(Utils.collectionMap(mth.getMethodInfo().getArgumentsTypes(), this::getTypeAlias));
        MethodGen mthGen = new MethodGen(classGen, mth);
        ICodeWriter cw = new AnnotatedCodeWriter();
        mthGen.addDefinition(cw);
        jsonMth.setDeclaration(cw.getCodeStr());
        jsonMth.setAccessFlags(mth.getAccessFlags().rawValue());
        jsonMth.setLines(fillMthCode(mth, mthGen));
        jsonMth.setOffset("0x" + Long.toHexString(mth.getMethodCodeOffset()));
        jsonCls.getMethods().add(jsonMth);
    }
}
Also used : MethodNode(jadx.core.dex.nodes.MethodNode) AnnotatedCodeWriter(jadx.api.impl.AnnotatedCodeWriter) JsonMethod(jadx.core.codegen.json.cls.JsonMethod) ICodeWriter(jadx.api.ICodeWriter) MethodGen(jadx.core.codegen.MethodGen)

Aggregations

ICodeWriter (jadx.api.ICodeWriter)1 AnnotatedCodeWriter (jadx.api.impl.AnnotatedCodeWriter)1 MethodGen (jadx.core.codegen.MethodGen)1 JsonMethod (jadx.core.codegen.json.cls.JsonMethod)1 MethodNode (jadx.core.dex.nodes.MethodNode)1