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