Search in sources :

Example 1 with JavaNode

use of jadx.api.JavaNode in project jadx by skylot.

the class CodeUsageInfo method processClass.

public void processClass(JavaClass javaClass, CodeLinesInfo linesInfo, List<StringRef> lines) {
    Map<CodePosition, JavaNode> usage = javaClass.getUsageMap();
    for (Map.Entry<CodePosition, JavaNode> entry : usage.entrySet()) {
        CodePosition codePosition = entry.getKey();
        JavaNode javaNode = entry.getValue();
        addUsage(nodeCache.makeFrom(javaNode), javaClass, linesInfo, codePosition, lines);
    }
}
Also used : CodePosition(jadx.api.CodePosition) Map(java.util.Map) HashMap(java.util.HashMap) JavaNode(jadx.api.JavaNode)

Example 2 with JavaNode

use of jadx.api.JavaNode in project jadx by skylot.

the class CodeArea method getDefPosition.

static Position getDefPosition(JClass jCls, RSyntaxTextArea textArea, int offset) {
    JavaNode node = getJavaNodeAtOffset(jCls, textArea, offset);
    if (node == null) {
        return null;
    }
    CodePosition pos = jCls.getCls().getDefinitionPosition(node);
    if (pos == null) {
        return null;
    }
    return new Position(pos);
}
Also used : CodePosition(jadx.api.CodePosition) CodePosition(jadx.api.CodePosition) Position(jadx.gui.utils.Position) JavaNode(jadx.api.JavaNode)

Example 3 with JavaNode

use of jadx.api.JavaNode 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 4 with JavaNode

use of jadx.api.JavaNode 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

JavaNode (jadx.api.JavaNode)4 CodePosition (jadx.api.CodePosition)2 CodeNode (jadx.gui.treemodel.CodeNode)2 JNode (jadx.gui.treemodel.JNode)1 Position (jadx.gui.utils.Position)1 StringRef (jadx.gui.utils.search.StringRef)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1