Search in sources :

Example 1 with JavaMethod

use of jadx.api.JavaMethod in project jadx by skylot.

the class CodeLinesInfo method addClass.

public void addClass(JavaClass cls) {
    map.put(cls.getDecompiledLine(), cls);
    for (JavaClass innerCls : cls.getInnerClasses()) {
        map.put(innerCls.getDecompiledLine(), innerCls);
        addClass(innerCls);
    }
    for (JavaMethod mth : cls.getMethods()) {
        map.put(mth.getDecompiledLine(), mth);
    }
}
Also used : JavaClass(jadx.api.JavaClass) JavaMethod(jadx.api.JavaMethod)

Example 2 with JavaMethod

use of jadx.api.JavaMethod in project jadx by skylot.

the class JClass method update.

public synchronized void update() {
    removeAllChildren();
    if (!loaded) {
        add(new TextNode(NLS.str("tree.loading")));
    } else {
        for (JavaClass javaClass : cls.getInnerClasses()) {
            JClass innerCls = new JClass(javaClass, this);
            add(innerCls);
            innerCls.update();
        }
        for (JavaField f : cls.getFields()) {
            add(new JField(f, this));
        }
        for (JavaMethod m : cls.getMethods()) {
            add(new JMethod(m, this));
        }
    }
}
Also used : JavaField(jadx.api.JavaField) JavaClass(jadx.api.JavaClass) JavaMethod(jadx.api.JavaMethod)

Example 3 with JavaMethod

use of jadx.api.JavaMethod in project jadx by skylot.

the class QuarkReportPanel method resolveMethod.

public MutableTreeNode resolveMethod(String descr) {
    try {
        String[] parts = removeQuotes(descr).split(" ", 3);
        String cls = Utils.cleanObjectName(parts[0].replace('$', '.'));
        String mth = parts[1] + parts[2].replace(" ", "");
        MainWindow mainWindow = getTabbedPane().getMainWindow();
        JadxWrapper wrapper = mainWindow.getWrapper();
        JavaClass javaClass = wrapper.searchJavaClassByRawName(cls);
        if (javaClass == null) {
            return new TextTreeNode(cls + "." + mth);
        }
        JavaMethod javaMethod = javaClass.searchMethodByShortId(mth);
        if (javaMethod == null) {
            return new TextTreeNode(javaClass.getFullName() + "." + mth);
        }
        return new MethodTreeNode(javaMethod);
    } catch (Exception e) {
        LOG.error("Failed to parse method descriptor string", e);
        return new TextTreeNode(descr);
    }
}
Also used : JadxWrapper(jadx.gui.JadxWrapper) JavaClass(jadx.api.JavaClass) MainWindow(jadx.gui.ui.MainWindow) JavaMethod(jadx.api.JavaMethod)

Example 4 with JavaMethod

use of jadx.api.JavaMethod in project jadx by skylot.

the class CommentsIndex method getRefNode.

@Nullable
private JNode getRefNode(ICodeComment comment) {
    IJavaNodeRef nodeRef = comment.getNodeRef();
    JavaClass javaClass = wrapper.searchJavaClassByOrigClassName(nodeRef.getDeclaringClass());
    if (javaClass == null) {
        return null;
    }
    JNodeCache nodeCache = cacheObject.getNodeCache();
    switch(nodeRef.getType()) {
        case CLASS:
            return nodeCache.makeFrom(javaClass);
        case FIELD:
            for (JavaField field : javaClass.getFields()) {
                if (field.getFieldNode().getFieldInfo().getShortId().equals(nodeRef.getShortId())) {
                    return nodeCache.makeFrom(field);
                }
            }
            break;
        case METHOD:
            for (JavaMethod mth : javaClass.getMethods()) {
                if (mth.getMethodNode().getMethodInfo().getShortId().equals(nodeRef.getShortId())) {
                    return nodeCache.makeFrom(mth);
                }
            }
            break;
    }
    return null;
}
Also used : IJavaNodeRef(jadx.api.data.IJavaNodeRef) JavaField(jadx.api.JavaField) JavaClass(jadx.api.JavaClass) JavaMethod(jadx.api.JavaMethod) JNodeCache(jadx.gui.utils.JNodeCache) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with JavaMethod

use of jadx.api.JavaMethod in project jadx by skylot.

the class JNodeCache method convert.

private JNode convert(JavaNode node) {
    if (node == null) {
        return null;
    }
    if (node instanceof JavaClass) {
        return convert(((JavaClass) node));
    }
    if (node instanceof JavaMethod) {
        return new JMethod((JavaMethod) node, makeFrom(node.getDeclaringClass()));
    }
    if (node instanceof JavaField) {
        return new JField((JavaField) node, makeFrom(node.getDeclaringClass()));
    }
    if (node instanceof JavaVariable) {
        JavaVariable javaVar = (JavaVariable) node;
        JMethod jMth = (JMethod) makeFrom(javaVar.getMth());
        return new JVariable(jMth, javaVar);
    }
    throw new JadxRuntimeException("Unknown type for JavaNode: " + node.getClass());
}
Also used : JVariable(jadx.gui.treemodel.JVariable) JField(jadx.gui.treemodel.JField) JavaField(jadx.api.JavaField) JavaClass(jadx.api.JavaClass) JavaVariable(jadx.api.JavaVariable) JavaMethod(jadx.api.JavaMethod) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException) JMethod(jadx.gui.treemodel.JMethod)

Aggregations

JavaMethod (jadx.api.JavaMethod)11 JavaClass (jadx.api.JavaClass)9 JavaField (jadx.api.JavaField)6 JadxRuntimeException (jadx.core.utils.exceptions.JadxRuntimeException)4 JMethod (jadx.gui.treemodel.JMethod)4 Nullable (org.jetbrains.annotations.Nullable)4 JClass (jadx.gui.treemodel.JClass)3 JField (jadx.gui.treemodel.JField)3 JNode (jadx.gui.treemodel.JNode)3 JavaVariable (jadx.api.JavaVariable)2 ArgType (jadx.core.dex.instructions.args.ArgType)2 MethodNode (jadx.core.dex.nodes.MethodNode)2 JVariable (jadx.gui.treemodel.JVariable)2 NLS (jadx.gui.utils.NLS)2 UiUtils (jadx.gui.utils.UiUtils)2 ActionEvent (java.awt.event.ActionEvent)2 KeyEvent (java.awt.event.KeyEvent)2 Collectors (java.util.stream.Collectors)2 KeyStroke.getKeyStroke (javax.swing.KeyStroke.getKeyStroke)2 Logger (org.slf4j.Logger)2