Search in sources :

Example 1 with CodeNode

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

the class TextSearchIndex method searchNext.

private int searchNext(List<CodeNode> list, String text, JavaNode javaClass, String code, int startPos) {
    int pos = code.indexOf(text, startPos);
    if (pos == -1) {
        return -1;
    }
    int lineStart = 1 + code.lastIndexOf(CodeWriter.NL, pos);
    int lineEnd = code.indexOf(CodeWriter.NL, pos + text.length());
    StringRef line = StringRef.subString(code, lineStart, lineEnd == -1 ? code.length() : lineEnd);
    list.add(new CodeNode(nodeCache.makeFrom(javaClass), -pos, line.trim()));
    return lineEnd;
}
Also used : CodeNode(jadx.gui.treemodel.CodeNode)

Example 2 with CodeNode

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

the class CodeUsageInfo method addUsage.

private void addUsage(JNode jNode, JavaClass javaClass, CodeLinesInfo linesInfo, CodePosition codePosition, List<StringRef> lines) {
    UsageInfo usageInfo = usageMap.get(jNode);
    if (usageInfo == null) {
        usageInfo = new UsageInfo();
        usageMap.put(jNode, usageInfo);
    }
    int line = codePosition.getLine();
    JavaNode javaNodeByLine = linesInfo.getJavaNodeByLine(line);
    StringRef codeLine = lines.get(line - 1);
    JNode node = nodeCache.makeFrom(javaNodeByLine == null ? javaClass : javaNodeByLine);
    CodeNode codeNode = new CodeNode(node, line, codeLine);
    usageInfo.getUsageList().add(codeNode);
}
Also used : CodeNode(jadx.gui.treemodel.CodeNode) StringRef(jadx.gui.utils.search.StringRef) JNode(jadx.gui.treemodel.JNode) JavaNode(jadx.api.JavaNode)

Example 3 with CodeNode

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

the class TextSearchIndex method indexCode.

public void indexCode(JavaClass cls, CodeLinesInfo linesInfo, List<StringRef> lines) {
    try {
        boolean strRefSupported = codeIndex.isStringRefSupported();
        int count = lines.size();
        for (int i = 0; i < count; i++) {
            StringRef line = lines.get(i);
            if (line.length() != 0 && line.charAt(0) != '}') {
                int lineNum = i + 1;
                JavaNode node = linesInfo.getJavaNodeByLine(lineNum);
                CodeNode codeNode = new CodeNode(nodeCache.makeFrom(node == null ? cls : node), lineNum, line);
                if (strRefSupported) {
                    codeIndex.put(line, codeNode);
                } else {
                    codeIndex.put(line.toString(), codeNode);
                }
            }
        }
    } catch (Exception e) {
        LOG.warn("Failed to index class: {}", cls, e);
    }
}
Also used : CodeNode(jadx.gui.treemodel.CodeNode) JavaNode(jadx.api.JavaNode)

Aggregations

CodeNode (jadx.gui.treemodel.CodeNode)3 JavaNode (jadx.api.JavaNode)2 JNode (jadx.gui.treemodel.JNode)1 StringRef (jadx.gui.utils.search.StringRef)1