未验证 提交 444a04e2 编写于 作者: S Skylot

fix(gui): redirect jump from search for inlined classes

上级 157e702f
......@@ -17,6 +17,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import java.util.Objects;
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
......@@ -44,6 +45,10 @@ import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jadx.api.JavaClass;
import jadx.api.metadata.ICodeAnnotation;
import jadx.api.metadata.annotations.NodeDeclareRef;
import jadx.gui.treemodel.JClass;
import jadx.gui.treemodel.JNode;
import jadx.gui.treemodel.JResSearchNode;
import jadx.gui.ui.MainWindow;
......@@ -142,13 +147,45 @@ public abstract class CommonSearchDialog extends JFrame {
JumpPosition jmpPos = new JumpPosition(((JResSearchNode) node).getResNode(), node.getPos());
tabbedPane.codeJump(jmpPos);
} else {
tabbedPane.codeJump(node);
if (!checkForRedirects(node)) {
tabbedPane.codeJump(node);
}
}
if (!mainWindow.getSettings().getKeepCommonDialogOpen()) {
dispose();
}
}
// TODO: temp solution, move implementation into corresponding nodes
private boolean checkForRedirects(JNode node) {
if (node instanceof JClass) {
JavaClass cls = ((JClass) node).getCls();
JavaClass origTopCls = cls.getOriginalTopParentClass();
JavaClass codeParent = cls.getTopParentClass();
if (Objects.equals(codeParent, origTopCls)) {
return false;
}
JClass jumpCls = mainWindow.getCacheObject().getNodeCache().makeFrom(codeParent);
mainWindow.getBackgroundExecutor().execute(
NLS.str("progress.load"),
jumpCls::loadNode, // load code in background
status -> {
// search original node in jump class
codeParent.getCodeInfo().getCodeMetadata().searchDown(0, (pos, ann) -> {
if (ann.getAnnType() == ICodeAnnotation.AnnType.DECLARATION) {
if (((NodeDeclareRef) ann).getNode().equals(cls.getClassNode())) {
tabbedPane.codeJump(new JumpPosition(jumpCls, pos));
return true;
}
}
return null;
});
});
return true;
}
return false;
}
@Nullable
private JNode getSelectedNode() {
try {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册