Search in sources :

Example 1 with JavaField

use of jadx.api.JavaField 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 2 with JavaField

use of jadx.api.JavaField 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 3 with JavaField

use of jadx.api.JavaField 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)

Example 4 with JavaField

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

the class TextSearchIndex method indexNames.

public void indexNames(JavaClass cls) {
    clsNamesIndex.put(cls.getFullName(), nodeCache.makeFrom(cls));
    for (JavaMethod mth : cls.getMethods()) {
        JNode mthNode = nodeCache.makeFrom(mth);
        mthSignaturesIndex.put(mthNode.makeDescString(), mthNode);
    }
    for (JavaField fld : cls.getFields()) {
        JNode fldNode = nodeCache.makeFrom(fld);
        fldSignaturesIndex.put(fldNode.makeDescString(), fldNode);
    }
    for (JavaClass innerCls : cls.getInnerClasses()) {
        indexNames(innerCls);
    }
}
Also used : JavaField(jadx.api.JavaField) JavaClass(jadx.api.JavaClass) JavaMethod(jadx.api.JavaMethod) JNode(jadx.gui.treemodel.JNode)

Example 5 with JavaField

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

the class FridaAction method generateFieldSnippet.

private String generateFieldSnippet(JField jf) {
    JavaField javaField = jf.getJavaField();
    String rawFieldName = javaField.getRawName();
    String fieldName = javaField.getName();
    List<MethodNode> methodNodes = javaField.getFieldNode().getParentClass().getMethods();
    for (MethodNode methodNode : methodNodes) {
        if (methodNode.getName().equals(rawFieldName)) {
            rawFieldName = "_" + rawFieldName;
            break;
        }
    }
    JClass jc = jf.getRootClass();
    String classSnippet = generateClassSnippet(jc);
    return String.format("%s\n%s = %s.%s.value;", classSnippet, fieldName, jc.getName(), rawFieldName);
}
Also used : JavaField(jadx.api.JavaField) MethodNode(jadx.core.dex.nodes.MethodNode) JClass(jadx.gui.treemodel.JClass)

Aggregations

JavaField (jadx.api.JavaField)6 JavaClass (jadx.api.JavaClass)5 JavaMethod (jadx.api.JavaMethod)5 JavaVariable (jadx.api.JavaVariable)1 IJavaNodeRef (jadx.api.data.IJavaNodeRef)1 MethodNode (jadx.core.dex.nodes.MethodNode)1 JadxRuntimeException (jadx.core.utils.exceptions.JadxRuntimeException)1 JClass (jadx.gui.treemodel.JClass)1 JField (jadx.gui.treemodel.JField)1 JMethod (jadx.gui.treemodel.JMethod)1 JNode (jadx.gui.treemodel.JNode)1 JVariable (jadx.gui.treemodel.JVariable)1 JNodeCache (jadx.gui.utils.JNodeCache)1 Nullable (org.jetbrains.annotations.Nullable)1