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;
}
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);
}
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);
}
}