Search in sources :

Example 1 with JNodeCache

use of jadx.gui.utils.JNodeCache in project jadx by skylot.

the class MouseHoverHighlighter method updateToolTip.

private void updateToolTip(JavaNode node) {
    if (node == null) {
        codeArea.setToolTipText(null);
        return;
    }
    JNodeCache nodeCache = codeArea.getMainWindow().getCacheObject().getNodeCache();
    JNode jNode = nodeCache.makeFrom(node);
    codeArea.setToolTipText(jNode.makeLongString());
}
Also used : JNodeCache(jadx.gui.utils.JNodeCache) JNode(jadx.gui.treemodel.JNode)

Example 2 with JNodeCache

use of jadx.gui.utils.JNodeCache in project jadx by skylot.

the class RenameDialog method refreshState.

private void refreshState() {
    RootNode rootNode = mainWindow.getWrapper().getDecompiler().getRoot();
    new RenameVisitor().init(rootNode);
    JNodeCache nodeCache = cache.getNodeCache();
    JavaNode javaNode = node.getJavaNode();
    List<JavaNode> toUpdate = new ArrayList<>();
    if (source != null && source != node) {
        toUpdate.add(source.getJavaNode());
    }
    if (javaNode != null) {
        toUpdate.add(javaNode);
        toUpdate.addAll(javaNode.getUseIn());
        if (node instanceof JMethod) {
            toUpdate.addAll(((JMethod) node).getJavaMethod().getOverrideRelatedMethods());
        }
    } else if (node instanceof JPackage) {
        processPackage(toUpdate);
    } else {
        throw new JadxRuntimeException("Unexpected node type: " + node);
    }
    Set<JClass> updatedTopClasses = toUpdate.stream().map(JavaNode::getTopParentClass).map(nodeCache::makeFrom).filter(Objects::nonNull).collect(Collectors.toSet());
    LOG.debug("Classes to update: {}", updatedTopClasses);
    refreshTabs(mainWindow.getTabbedPane(), updatedTopClasses);
    if (!updatedTopClasses.isEmpty()) {
        mainWindow.getBackgroundExecutor().execute("Refreshing", () -> refreshClasses(updatedTopClasses), (status) -> {
            if (status == TaskStatus.CANCEL_BY_MEMORY) {
                mainWindow.showHeapUsageBar();
                UiUtils.errorMessage(this, NLS.str("message.memoryLow"));
            }
            if (node instanceof JPackage) {
                mainWindow.getTreeRoot().update();
            }
            mainWindow.reloadTree();
        });
    }
}
Also used : RootNode(jadx.core.dex.nodes.RootNode) JClass(jadx.gui.treemodel.JClass) ArrayList(java.util.ArrayList) JPackage(jadx.gui.treemodel.JPackage) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException) RenameVisitor(jadx.core.dex.visitors.rename.RenameVisitor) JNodeCache(jadx.gui.utils.JNodeCache) JMethod(jadx.gui.treemodel.JMethod) JavaNode(jadx.api.JavaNode)

Example 3 with JNodeCache

use of jadx.gui.utils.JNodeCache 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 4 with JNodeCache

use of jadx.gui.utils.JNodeCache in project jadx by skylot.

the class IndexJob method runJob.

protected void runJob() {
    JNodeCache nodeCache = cache.getNodeCache();
    final TextSearchIndex index = new TextSearchIndex(nodeCache);
    final CodeUsageInfo usageInfo = new CodeUsageInfo(nodeCache);
    cache.setTextIndex(index);
    cache.setUsageInfo(usageInfo);
    for (final JavaClass cls : wrapper.getClasses()) {
        addTask(new Runnable() {

            @Override
            public void run() {
                try {
                    index.indexNames(cls);
                    CodeLinesInfo linesInfo = new CodeLinesInfo(cls);
                    List<StringRef> lines = splitLines(cls);
                    usageInfo.processClass(cls, linesInfo, lines);
                    if (Utils.isFreeMemoryAvailable()) {
                        index.indexCode(cls, linesInfo, lines);
                    } else {
                        index.classCodeIndexSkipped(cls);
                    }
                } catch (Exception e) {
                    LOG.error("Index error in class: {}", cls.getFullName(), e);
                }
            }
        });
    }
}
Also used : CodeUsageInfo(jadx.gui.utils.CodeUsageInfo) JavaClass(jadx.api.JavaClass) List(java.util.List) JNodeCache(jadx.gui.utils.JNodeCache) TextSearchIndex(jadx.gui.utils.search.TextSearchIndex) CodeLinesInfo(jadx.gui.utils.CodeLinesInfo)

Aggregations

JNodeCache (jadx.gui.utils.JNodeCache)4 JavaClass (jadx.api.JavaClass)2 JavaField (jadx.api.JavaField)1 JavaMethod (jadx.api.JavaMethod)1 JavaNode (jadx.api.JavaNode)1 IJavaNodeRef (jadx.api.data.IJavaNodeRef)1 RootNode (jadx.core.dex.nodes.RootNode)1 RenameVisitor (jadx.core.dex.visitors.rename.RenameVisitor)1 JadxRuntimeException (jadx.core.utils.exceptions.JadxRuntimeException)1 JClass (jadx.gui.treemodel.JClass)1 JMethod (jadx.gui.treemodel.JMethod)1 JNode (jadx.gui.treemodel.JNode)1 JPackage (jadx.gui.treemodel.JPackage)1 CodeLinesInfo (jadx.gui.utils.CodeLinesInfo)1 CodeUsageInfo (jadx.gui.utils.CodeUsageInfo)1 TextSearchIndex (jadx.gui.utils.search.TextSearchIndex)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Nullable (org.jetbrains.annotations.Nullable)1