@@ -10,6 +10,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.swing.JTabbedPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
@@ -18,6 +19,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.ICodeNodeRef;
|
||||
import jadx.api.metadata.annotations.NodeDeclareRef;
|
||||
import jadx.core.utils.exceptions.JadxRuntimeException;
|
||||
import jadx.gui.treemodel.JClass;
|
||||
import jadx.gui.treemodel.JNode;
|
||||
@@ -199,6 +204,34 @@ public class TabbedPane extends JTabbedPane {
|
||||
* Jump to node definition
|
||||
*/
|
||||
public void codeJump(JNode node) {
|
||||
JClass parentCls = node.getJParent();
|
||||
if (parentCls != null) {
|
||||
JavaClass cls = node.getJParent().getCls();
|
||||
JavaClass origTopCls = cls.getOriginalTopParentClass();
|
||||
JavaClass codeParent = cls.getTopParentClass();
|
||||
if (!Objects.equals(codeParent, origTopCls)) {
|
||||
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) {
|
||||
ICodeNodeRef declNode = ((NodeDeclareRef) ann).getNode();
|
||||
if (declNode.equals(node.getJavaNode().getCodeNodeRef())) {
|
||||
codeJump(new JumpPosition(jumpCls, pos));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Not an inline node, jump normally
|
||||
if (node.getPos() != 0 || node.getRootClass() == null) {
|
||||
codeJump(new JumpPosition(node));
|
||||
return;
|
||||
|
||||
@@ -17,7 +17,6 @@ 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;
|
||||
@@ -47,11 +46,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import ch.qos.logback.classic.Level;
|
||||
|
||||
import jadx.api.JavaClass;
|
||||
import jadx.api.metadata.ICodeAnnotation;
|
||||
import jadx.api.metadata.annotations.NodeDeclareRef;
|
||||
import jadx.gui.logs.LogOptions;
|
||||
import jadx.gui.treemodel.JClass;
|
||||
import jadx.gui.treemodel.JNode;
|
||||
import jadx.gui.treemodel.JResSearchNode;
|
||||
import jadx.gui.ui.MainWindow;
|
||||
@@ -151,45 +146,13 @@ public abstract class CommonSearchDialog extends JFrame {
|
||||
JumpPosition jmpPos = new JumpPosition(((JResSearchNode) node).getResNode(), node.getPos());
|
||||
tabbedPane.codeJump(jmpPos);
|
||||
} else {
|
||||
if (!checkForRedirects(node)) {
|
||||
tabbedPane.codeJump(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 {
|
||||
|
||||
Reference in New Issue
Block a user