use of jadx.gui.utils.search.StringRef in project jadx by skylot.
the class IndexService method indexCls.
/**
* Warning! Not ready for parallel execution. Use only in a single thread.
*/
public boolean indexCls(JavaClass cls) {
try {
TextSearchIndex index = cache.getTextIndex();
if (index == null) {
return false;
}
// get code from cache to avoid decompilation here
String code = getCodeFromCache(cls);
if (code == null) {
return cls.isNoCode();
}
List<StringRef> lines = splitLines(code);
CodeLinesInfo linesInfo = new CodeLinesInfo(cls);
index.indexCode(cls, linesInfo, lines);
index.indexNames(cls);
indexSet.add(cls);
return true;
} catch (Exception e) {
LOG.error("Index error in class: {}", cls.getFullName(), e);
return false;
}
}
use of jadx.gui.utils.search.StringRef in project jadx by skylot.
the class UsageDialog method processUsageClass.
private void processUsageClass(JavaNode usageNode) {
JavaClass cls = usageNode.getTopParentClass();
String code = cls.getCodeInfo().getCodeStr();
CodeLinesInfo linesInfo = new CodeLinesInfo(cls);
List<? extends JavaNode> targetNodes = getMethodWithOverride();
for (JavaNode javaNode : targetNodes) {
List<CodePosition> usage = cls.getUsageFor(javaNode);
for (CodePosition pos : usage) {
if (javaNode.getTopParentClass().equals(cls) && pos.getPos() == javaNode.getDefPos()) {
// skip declaration
continue;
}
StringRef line = getLineStrAt(code, pos.getPos());
if (line.startsWith("import ")) {
continue;
}
JavaNode javaNodeByLine = linesInfo.getJavaNodeByLine(pos.getLine());
JNode useAtNode = javaNodeByLine == null ? node : getNodeCache().makeFrom(javaNodeByLine);
usageList.add(new CodeNode(useAtNode, line, pos.getLine(), pos.getPos()));
}
}
}
use of jadx.gui.utils.search.StringRef 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);
}
Aggregations