summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adrian Siekierka2018-12-09 12:38:11 +0100
committerGravatar Adrian Siekierka2018-12-09 12:38:11 +0100
commitef8bdf506c48d7c9d2bd1f97030d123015c3ae44 (patch)
treeb31761481283b260b4b9e7e2f4f831bcffed91c9
parentfix SourceIndex remap bugs (diff)
downloadenigma-ef8bdf506c48d7c9d2bd1f97030d123015c3ae44.tar.gz
enigma-ef8bdf506c48d7c9d2bd1f97030d123015c3ae44.tar.xz
enigma-ef8bdf506c48d7c9d2bd1f97030d123015c3ae44.zip
add option to view calls to a method in general, not just the specific instance of the method
-rw-r--r--src/main/java/cuchaz/enigma/analysis/JarIndex.java16
-rw-r--r--src/main/java/cuchaz/enigma/analysis/MethodReferenceTreeNode.java7
-rw-r--r--src/main/java/cuchaz/enigma/gui/Gui.java5
-rw-r--r--src/main/java/cuchaz/enigma/gui/GuiController.java4
-rw-r--r--src/main/java/cuchaz/enigma/gui/elements/PopupMenuBar.java12
5 files changed, 37 insertions, 7 deletions
diff --git a/src/main/java/cuchaz/enigma/analysis/JarIndex.java b/src/main/java/cuchaz/enigma/analysis/JarIndex.java
index 820ecbbf..361c8e73 100644
--- a/src/main/java/cuchaz/enigma/analysis/JarIndex.java
+++ b/src/main/java/cuchaz/enigma/analysis/JarIndex.java
@@ -447,8 +447,22 @@ public class JarIndex {
447 return this.methodsReferencingClasses.get(classEntry); 447 return this.methodsReferencingClasses.get(classEntry);
448 } 448 }
449 449
450 @Deprecated
450 public Collection<EntryReference<MethodEntry, MethodDefEntry>> getMethodsReferencing(MethodEntry methodEntry) { 451 public Collection<EntryReference<MethodEntry, MethodDefEntry>> getMethodsReferencing(MethodEntry methodEntry) {
451 return this.methodsReferencing.get(methodEntry); 452 return getMethodsReferencing(methodEntry, false);
453 }
454
455 public Collection<EntryReference<MethodEntry, MethodDefEntry>> getMethodsReferencing(MethodEntry methodEntry, boolean recurse) {
456 if (!recurse) {
457 return this.methodsReferencing.get(methodEntry);
458 }
459
460 List<EntryReference<MethodEntry, MethodDefEntry>> references = new ArrayList<>();
461 Set<MethodEntry> methodEntries = getRelatedMethodImplementations(methodEntry);
462 for (MethodEntry entry : methodEntries) {
463 references.addAll(getMethodsReferencing(entry, false));
464 }
465 return references;
452 } 466 }
453 467
454 public Collection<MethodEntry> getReferencedMethods(MethodDefEntry methodEntry) { 468 public Collection<MethodEntry> getReferencedMethods(MethodDefEntry methodEntry) {
diff --git a/src/main/java/cuchaz/enigma/analysis/MethodReferenceTreeNode.java b/src/main/java/cuchaz/enigma/analysis/MethodReferenceTreeNode.java
index 0eae5cc4..ac05acdc 100644
--- a/src/main/java/cuchaz/enigma/analysis/MethodReferenceTreeNode.java
+++ b/src/main/java/cuchaz/enigma/analysis/MethodReferenceTreeNode.java
@@ -63,9 +63,14 @@ public class MethodReferenceTreeNode extends DefaultMutableTreeNode
63 return this.deobfuscatingTranslator.getTranslatedMethod(this.entry).getName(); 63 return this.deobfuscatingTranslator.getTranslatedMethod(this.entry).getName();
64 } 64 }
65 65
66 @Deprecated
66 public void load(JarIndex index, boolean recurse) { 67 public void load(JarIndex index, boolean recurse) {
68 load(index, recurse, false);
69 }
70
71 public void load(JarIndex index, boolean recurse, boolean recurseMethod) {
67 // get all the child nodes 72 // get all the child nodes
68 for (EntryReference<MethodEntry, MethodDefEntry> reference : index.getMethodsReferencing(this.entry)) { 73 for (EntryReference<MethodEntry, MethodDefEntry> reference : index.getMethodsReferencing(this.entry, recurseMethod)) {
69 add(new MethodReferenceTreeNode(this.deobfuscatingTranslator, reference, index.getAccessFlags(this.entry))); 74 add(new MethodReferenceTreeNode(this.deobfuscatingTranslator, reference, index.getAccessFlags(this.entry)));
70 } 75 }
71 76
diff --git a/src/main/java/cuchaz/enigma/gui/Gui.java b/src/main/java/cuchaz/enigma/gui/Gui.java
index 8ec58f9e..53500aa4 100644
--- a/src/main/java/cuchaz/enigma/gui/Gui.java
+++ b/src/main/java/cuchaz/enigma/gui/Gui.java
@@ -537,6 +537,7 @@ public class Gui {
537 this.popupMenu.showInheritanceMenu.setEnabled(isClassEntry || isMethodEntry || isConstructorEntry); 537 this.popupMenu.showInheritanceMenu.setEnabled(isClassEntry || isMethodEntry || isConstructorEntry);
538 this.popupMenu.showImplementationsMenu.setEnabled(isClassEntry || isMethodEntry); 538 this.popupMenu.showImplementationsMenu.setEnabled(isClassEntry || isMethodEntry);
539 this.popupMenu.showCallsMenu.setEnabled(isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry); 539 this.popupMenu.showCallsMenu.setEnabled(isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry);
540 this.popupMenu.showCallsSpecificMenu.setEnabled(isMethodEntry);
540 this.popupMenu.openEntryMenu.setEnabled(isInJar && (isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry)); 541 this.popupMenu.openEntryMenu.setEnabled(isInJar && (isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry));
541 this.popupMenu.openPreviousMenu.setEnabled(this.controller.hasPreviousLocation()); 542 this.popupMenu.openPreviousMenu.setEnabled(this.controller.hasPreviousLocation());
542 this.popupMenu.toggleMappingMenu.setEnabled(isRenameable); 543 this.popupMenu.toggleMappingMenu.setEnabled(isRenameable);
@@ -694,7 +695,7 @@ public class Gui {
694 redraw(); 695 redraw();
695 } 696 }
696 697
697 public void showCalls() { 698 public void showCalls(boolean recurse) {
698 if (reference == null) { 699 if (reference == null) {
699 return; 700 return;
700 } 701 }
@@ -706,7 +707,7 @@ public class Gui {
706 FieldReferenceTreeNode node = this.controller.getFieldReferences((FieldEntry) reference.entry); 707 FieldReferenceTreeNode node = this.controller.getFieldReferences((FieldEntry) reference.entry);
707 callsTree.setModel(new DefaultTreeModel(node)); 708 callsTree.setModel(new DefaultTreeModel(node));
708 } else if (reference.entry instanceof MethodEntry) { 709 } else if (reference.entry instanceof MethodEntry) {
709 MethodReferenceTreeNode node = this.controller.getMethodReferences((MethodEntry) reference.entry); 710 MethodReferenceTreeNode node = this.controller.getMethodReferences((MethodEntry) reference.entry, recurse);
710 callsTree.setModel(new DefaultTreeModel(node)); 711 callsTree.setModel(new DefaultTreeModel(node));
711 } 712 }
712 713
diff --git a/src/main/java/cuchaz/enigma/gui/GuiController.java b/src/main/java/cuchaz/enigma/gui/GuiController.java
index acb0ebbb..69aefe58 100644
--- a/src/main/java/cuchaz/enigma/gui/GuiController.java
+++ b/src/main/java/cuchaz/enigma/gui/GuiController.java
@@ -209,10 +209,10 @@ public class GuiController {
209 return rootNode; 209 return rootNode;
210 } 210 }
211 211
212 public MethodReferenceTreeNode getMethodReferences(MethodEntry deobfMethodEntry) { 212 public MethodReferenceTreeNode getMethodReferences(MethodEntry deobfMethodEntry, boolean recursive) {
213 MethodEntry obfMethodEntry = this.deobfuscator.obfuscateEntry(deobfMethodEntry); 213 MethodEntry obfMethodEntry = this.deobfuscator.obfuscateEntry(deobfMethodEntry);
214 MethodReferenceTreeNode rootNode = new MethodReferenceTreeNode(this.deobfuscator.getTranslator(TranslationDirection.DEOBFUSCATING), obfMethodEntry); 214 MethodReferenceTreeNode rootNode = new MethodReferenceTreeNode(this.deobfuscator.getTranslator(TranslationDirection.DEOBFUSCATING), obfMethodEntry);
215 rootNode.load(this.deobfuscator.getJarIndex(), true); 215 rootNode.load(this.deobfuscator.getJarIndex(), true, recursive);
216 return rootNode; 216 return rootNode;
217 } 217 }
218 218
diff --git a/src/main/java/cuchaz/enigma/gui/elements/PopupMenuBar.java b/src/main/java/cuchaz/enigma/gui/elements/PopupMenuBar.java
index 2f6d96c4..32f91729 100644
--- a/src/main/java/cuchaz/enigma/gui/elements/PopupMenuBar.java
+++ b/src/main/java/cuchaz/enigma/gui/elements/PopupMenuBar.java
@@ -3,6 +3,7 @@ package cuchaz.enigma.gui.elements;
3import cuchaz.enigma.gui.Gui; 3import cuchaz.enigma.gui.Gui;
4 4
5import javax.swing.*; 5import javax.swing.*;
6import java.awt.event.InputEvent;
6import java.awt.event.KeyEvent; 7import java.awt.event.KeyEvent;
7 8
8public class PopupMenuBar extends JPopupMenu { 9public class PopupMenuBar extends JPopupMenu {
@@ -11,6 +12,7 @@ public class PopupMenuBar extends JPopupMenu {
11 public final JMenuItem showInheritanceMenu; 12 public final JMenuItem showInheritanceMenu;
12 public final JMenuItem showImplementationsMenu; 13 public final JMenuItem showImplementationsMenu;
13 public final JMenuItem showCallsMenu; 14 public final JMenuItem showCallsMenu;
15 public final JMenuItem showCallsSpecificMenu;
14 public final JMenuItem openEntryMenu; 16 public final JMenuItem openEntryMenu;
15 public final JMenuItem openPreviousMenu; 17 public final JMenuItem openPreviousMenu;
16 public final JMenuItem toggleMappingMenu; 18 public final JMenuItem toggleMappingMenu;
@@ -42,13 +44,21 @@ public class PopupMenuBar extends JPopupMenu {
42 } 44 }
43 { 45 {
44 JMenuItem menu = new JMenuItem("Show Calls"); 46 JMenuItem menu = new JMenuItem("Show Calls");
45 menu.addActionListener(event -> gui.showCalls()); 47 menu.addActionListener(event -> gui.showCalls(true));
46 menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, 0)); 48 menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, 0));
47 menu.setEnabled(false); 49 menu.setEnabled(false);
48 this.add(menu); 50 this.add(menu);
49 this.showCallsMenu = menu; 51 this.showCallsMenu = menu;
50 } 52 }
51 { 53 {
54 JMenuItem menu = new JMenuItem("Show Calls (Specific)");
55 menu.addActionListener(event -> gui.showCalls(false));
56 menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.SHIFT_DOWN_MASK));
57 menu.setEnabled(false);
58 this.add(menu);
59 this.showCallsSpecificMenu = menu;
60 }
61 {
52 JMenuItem menu = new JMenuItem("Go to Declaration"); 62 JMenuItem menu = new JMenuItem("Go to Declaration");
53 menu.addActionListener(event -> gui.navigateTo(gui.reference.entry)); 63 menu.addActionListener(event -> gui.navigateTo(gui.reference.entry));
54 menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, 0)); 64 menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, 0));