Search in sources :

Example 6 with JumpPosition

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

the class TextSearchIndex method buildSearch.

public Flowable<JNode> buildSearch(String text, Set<SearchDialog.SearchOptions> options) throws SearchSettings.InvalidSearchTermException {
    boolean ignoreCase = options.contains(IGNORE_CASE);
    boolean useRegex = options.contains(USE_REGEX);
    LOG.debug("Building search, ignoreCase: {}, useRegex: {}", ignoreCase, useRegex);
    Flowable<JNode> result = Flowable.empty();
    SearchSettings searchSettings = new SearchSettings(text, options.contains(IGNORE_CASE), options.contains(USE_REGEX));
    if (options.contains(ACTIVE_TAB)) {
        JumpPosition activeNode = mainWindow.getTabbedPane().getCurrentPosition();
        if (activeNode != null) {
            searchSettings.setActiveCls(activeNode.getNode().getRootClass());
        }
        if (searchSettings.getActiveCls() == null) {
            return result;
        }
    }
    if (!searchSettings.preCompile()) {
        return result;
    }
    if (options.contains(COMMENT)) {
        CommentsIndex commentsIndex = cache.getCommentsIndex();
        result = Flowable.concat(result, commentsIndex.search(searchSettings));
        if (text.isEmpty()) {
            // other searches don't support empty string, so return immediately
            return result;
        }
    }
    if (options.contains(CLASS)) {
        result = Flowable.concat(result, clsNamesIndex.search(searchSettings));
    }
    if (options.contains(METHOD)) {
        result = Flowable.concat(result, mthSignaturesIndex.search(searchSettings));
    }
    if (options.contains(FIELD)) {
        result = Flowable.concat(result, fldSignaturesIndex.search(searchSettings));
    }
    if (options.contains(CODE)) {
        if (codeIndex.size() > 0) {
            result = Flowable.concat(result, codeIndex.search(searchSettings));
        }
        if (!skippedClasses.isEmpty()) {
            result = Flowable.concat(result, searchInSkippedClasses(searchSettings));
        }
    }
    if (options.contains(RESOURCE)) {
        result = Flowable.concat(result, resIndex.search(searchSettings));
    }
    return result;
}
Also used : JumpPosition(jadx.gui.utils.JumpPosition) JNode(jadx.gui.treemodel.JNode)

Example 7 with JumpPosition

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

the class MainWindow method nodeClickAction.

private boolean nodeClickAction(@Nullable Object obj) {
    if (obj == null) {
        return false;
    }
    try {
        if (obj instanceof JResource) {
            JResource res = (JResource) obj;
            ResourceFile resFile = res.getResFile();
            if (resFile != null && JResource.isSupportedForView(resFile.getType())) {
                return tabbedPane.showNode(res);
            }
        } else if (obj instanceof JNode) {
            JNode node = (JNode) obj;
            if (node.getRootClass() != null) {
                tabbedPane.codeJump(new JumpPosition(node));
                return true;
            }
            return tabbedPane.showNode(node);
        }
    } catch (Exception e) {
        LOG.error("Content loading error", e);
    }
    return false;
}
Also used : ResourceFile(jadx.api.ResourceFile) JumpPosition(jadx.gui.utils.JumpPosition) JResource(jadx.gui.treemodel.JResource) JNode(jadx.gui.treemodel.JNode) HeadlessException(java.awt.HeadlessException)

Example 8 with JumpPosition

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

the class CodeArea method getDefPosForNodeAtOffset.

/**
 * Search node by offset in {@code jCls} code and return its definition position
 * (useful for jumps from usage)
 */
@Nullable
public JumpPosition getDefPosForNodeAtOffset(int offset) {
    if (offset == -1) {
        return null;
    }
    JavaNode foundNode = getJavaNodeAtOffset(offset);
    if (foundNode == null) {
        return null;
    }
    CodePosition pos = getDecompiler().getDefinitionPosition(foundNode);
    if (pos == null) {
        return null;
    }
    JNode jNode = convertJavaNode(foundNode);
    return new JumpPosition(jNode.getRootClass(), pos);
}
Also used : CodePosition(jadx.api.CodePosition) JumpPosition(jadx.gui.utils.JumpPosition) JNode(jadx.gui.treemodel.JNode) JavaNode(jadx.api.JavaNode) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

JumpPosition (jadx.gui.utils.JumpPosition)8 JNode (jadx.gui.treemodel.JNode)4 CodePosition (jadx.api.CodePosition)1 JavaNode (jadx.api.JavaNode)1 ResourceFile (jadx.api.ResourceFile)1 JadxRuntimeException (jadx.core.utils.exceptions.JadxRuntimeException)1 JResSearchNode (jadx.gui.treemodel.JResSearchNode)1 JResource (jadx.gui.treemodel.JResource)1 AbstractCodeContentPanel (jadx.gui.ui.codearea.AbstractCodeContentPanel)1 ClassCodeContentPanel (jadx.gui.ui.codearea.ClassCodeContentPanel)1 SmaliArea (jadx.gui.ui.codearea.SmaliArea)1 ContentPanel (jadx.gui.ui.panel.ContentPanel)1 HeadlessException (java.awt.HeadlessException)1 Point (java.awt.Point)1 HyperlinkEvent (javax.swing.event.HyperlinkEvent)1 BadLocationException (javax.swing.text.BadLocationException)1 LinkGeneratorResult (org.fife.ui.rsyntaxtextarea.LinkGeneratorResult)1 Nullable (org.jetbrains.annotations.Nullable)1