Search in sources :

Example 1 with JResSearchNode

use of jadx.gui.treemodel.JResSearchNode in project jadx by skylot.

the class CommonSearchDialog method openSelectedItem.

protected void openSelectedItem() {
    JNode node = getSelectedNode();
    if (node == null) {
        return;
    }
    JumpPosition jmpPos;
    if (node instanceof JResSearchNode) {
        jmpPos = new JumpPosition(((JResSearchNode) node).getResNode(), node.getLine(), node.getPos());
    } else {
        jmpPos = new JumpPosition(node.getRootClass(), node.getLine(), node.getPos());
    }
    tabbedPane.codeJump(jmpPos);
    if (!mainWindow.getSettings().getKeepCommonDialogOpen()) {
        dispose();
    }
}
Also used : JumpPosition(jadx.gui.utils.JumpPosition) JNode(jadx.gui.treemodel.JNode) JResSearchNode(jadx.gui.treemodel.JResSearchNode)

Example 2 with JResSearchNode

use of jadx.gui.treemodel.JResSearchNode in project jadx by skylot.

the class ResourceIndex method search.

private void search(final JResource resNode, FlowableEmitter<JResSearchNode> emitter, SearchSettings searchSettings) {
    int line = 0;
    int lastPos = 0;
    int lastLineOccurred = -1;
    JResSearchNode lastNode = null;
    int searchStrLen = searchSettings.getSearchString().length();
    String content;
    try {
        content = resNode.getContent();
    } catch (Exception e) {
        LOG.error("Error load resource node content", e);
        return;
    }
    do {
        searchSettings.setStartPos(lastPos);
        int pos = searchSettings.find(content);
        if (pos > -1) {
            line += countLinesByPos(content, pos, lastPos);
            lastPos = pos + searchStrLen;
            String lineText = getLine(content, pos, lastPos);
            if (lastLineOccurred != line) {
                lastLineOccurred = line;
                if (lastNode != null) {
                    emitter.onNext(lastNode);
                }
                lastNode = new JResSearchNode(resNode, lineText.trim(), line + 1, pos);
            }
        } else {
            if (lastNode != null) {
                // commit the final result node.
                emitter.onNext(lastNode);
            }
            break;
        }
    } while (!emitter.isCancelled() && lastPos < content.length());
}
Also used : JResSearchNode(jadx.gui.treemodel.JResSearchNode) IOException(java.io.IOException)

Aggregations

JResSearchNode (jadx.gui.treemodel.JResSearchNode)2 JNode (jadx.gui.treemodel.JNode)1 JumpPosition (jadx.gui.utils.JumpPosition)1 IOException (java.io.IOException)1