Search in sources :

Example 1 with IJavaNodeRef

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

Aggregations

JavaClass (jadx.api.JavaClass)1 JavaField (jadx.api.JavaField)1 JavaMethod (jadx.api.JavaMethod)1 IJavaNodeRef (jadx.api.data.IJavaNodeRef)1 JNodeCache (jadx.gui.utils.JNodeCache)1 Nullable (org.jetbrains.annotations.Nullable)1