use of jadx.gui.utils.JNodeCache in project jadx by skylot.
the class MouseHoverHighlighter method updateToolTip.
private void updateToolTip(JavaNode node) {
if (node == null) {
codeArea.setToolTipText(null);
return;
}
JNodeCache nodeCache = codeArea.getMainWindow().getCacheObject().getNodeCache();
JNode jNode = nodeCache.makeFrom(node);
codeArea.setToolTipText(jNode.makeLongString());
}
use of jadx.gui.utils.JNodeCache in project jadx by skylot.
the class RenameDialog method refreshState.
private void refreshState() {
RootNode rootNode = mainWindow.getWrapper().getDecompiler().getRoot();
new RenameVisitor().init(rootNode);
JNodeCache nodeCache = cache.getNodeCache();
JavaNode javaNode = node.getJavaNode();
List<JavaNode> toUpdate = new ArrayList<>();
if (source != null && source != node) {
toUpdate.add(source.getJavaNode());
}
if (javaNode != null) {
toUpdate.add(javaNode);
toUpdate.addAll(javaNode.getUseIn());
if (node instanceof JMethod) {
toUpdate.addAll(((JMethod) node).getJavaMethod().getOverrideRelatedMethods());
}
} else if (node instanceof JPackage) {
processPackage(toUpdate);
} else {
throw new JadxRuntimeException("Unexpected node type: " + node);
}
Set<JClass> updatedTopClasses = toUpdate.stream().map(JavaNode::getTopParentClass).map(nodeCache::makeFrom).filter(Objects::nonNull).collect(Collectors.toSet());
LOG.debug("Classes to update: {}", updatedTopClasses);
refreshTabs(mainWindow.getTabbedPane(), updatedTopClasses);
if (!updatedTopClasses.isEmpty()) {
mainWindow.getBackgroundExecutor().execute("Refreshing", () -> refreshClasses(updatedTopClasses), (status) -> {
if (status == TaskStatus.CANCEL_BY_MEMORY) {
mainWindow.showHeapUsageBar();
UiUtils.errorMessage(this, NLS.str("message.memoryLow"));
}
if (node instanceof JPackage) {
mainWindow.getTreeRoot().update();
}
mainWindow.reloadTree();
});
}
}
use of jadx.gui.utils.JNodeCache in project jadx by skylot.
the class CommentsIndex method getRefNode.
@Nullable
private JNode getRefNode(ICodeComment comment) {
IJavaNodeRef nodeRef = comment.getNodeRef();
JavaClass javaClass = wrapper.searchJavaClassByOrigClassName(nodeRef.getDeclaringClass());
if (javaClass == null) {
return null;
}
JNodeCache nodeCache = cacheObject.getNodeCache();
switch(nodeRef.getType()) {
case CLASS:
return nodeCache.makeFrom(javaClass);
case FIELD:
for (JavaField field : javaClass.getFields()) {
if (field.getFieldNode().getFieldInfo().getShortId().equals(nodeRef.getShortId())) {
return nodeCache.makeFrom(field);
}
}
break;
case METHOD:
for (JavaMethod mth : javaClass.getMethods()) {
if (mth.getMethodNode().getMethodInfo().getShortId().equals(nodeRef.getShortId())) {
return nodeCache.makeFrom(mth);
}
}
break;
}
return null;
}
use of jadx.gui.utils.JNodeCache in project jadx by skylot.
the class IndexJob method runJob.
protected void runJob() {
JNodeCache nodeCache = cache.getNodeCache();
final TextSearchIndex index = new TextSearchIndex(nodeCache);
final CodeUsageInfo usageInfo = new CodeUsageInfo(nodeCache);
cache.setTextIndex(index);
cache.setUsageInfo(usageInfo);
for (final JavaClass cls : wrapper.getClasses()) {
addTask(new Runnable() {
@Override
public void run() {
try {
index.indexNames(cls);
CodeLinesInfo linesInfo = new CodeLinesInfo(cls);
List<StringRef> lines = splitLines(cls);
usageInfo.processClass(cls, linesInfo, lines);
if (Utils.isFreeMemoryAvailable()) {
index.indexCode(cls, linesInfo, lines);
} else {
index.classCodeIndexSkipped(cls);
}
} catch (Exception e) {
LOG.error("Index error in class: {}", cls.getFullName(), e);
}
}
});
}
}
Aggregations