diff options
| author | 2023-06-24 01:13:34 -0600 | |
|---|---|---|
| committer | 2023-06-24 08:13:34 +0100 | |
| commit | 6e86f8eb5e45a1cab51a7ce5be16a2c5097a6067 (patch) | |
| tree | 15015a76f8af9b35288bb28d85659524e1cc48dc /enigma | |
| parent | Fix ghost entries caused by packages becoming empty (#517) (diff) | |
| download | enigma-fork-6e86f8eb5e45a1cab51a7ce5be16a2c5097a6067.tar.gz enigma-fork-6e86f8eb5e45a1cab51a7ce5be16a2c5097a6067.tar.xz enigma-fork-6e86f8eb5e45a1cab51a7ce5be16a2c5097a6067.zip | |
Fix double clicking an entry in the "implementations" window not navigating to the respective class/method (#516)
* fix double clicking an entry in the implementations window not navigating to the class/method
* fix styling
Diffstat (limited to 'enigma')
6 files changed, 75 insertions, 67 deletions
diff --git a/enigma/src/main/java/cuchaz/enigma/analysis/ClassImplementationsTreeNode.java b/enigma/src/main/java/cuchaz/enigma/analysis/ClassImplementationsTreeNode.java index 8ef28d9..306451a 100644 --- a/enigma/src/main/java/cuchaz/enigma/analysis/ClassImplementationsTreeNode.java +++ b/enigma/src/main/java/cuchaz/enigma/analysis/ClassImplementationsTreeNode.java | |||
| @@ -14,8 +14,6 @@ package cuchaz.enigma.analysis; | |||
| 14 | import java.util.Collection; | 14 | import java.util.Collection; |
| 15 | import java.util.List; | 15 | import java.util.List; |
| 16 | 16 | ||
| 17 | import javax.swing.tree.DefaultMutableTreeNode; | ||
| 18 | |||
| 19 | import com.google.common.collect.Lists; | 17 | import com.google.common.collect.Lists; |
| 20 | 18 | ||
| 21 | import cuchaz.enigma.analysis.index.InheritanceIndex; | 19 | import cuchaz.enigma.analysis.index.InheritanceIndex; |
| @@ -24,18 +22,14 @@ import cuchaz.enigma.translation.Translator; | |||
| 24 | import cuchaz.enigma.translation.representation.entry.ClassEntry; | 22 | import cuchaz.enigma.translation.representation.entry.ClassEntry; |
| 25 | import cuchaz.enigma.translation.representation.entry.MethodEntry; | 23 | import cuchaz.enigma.translation.representation.entry.MethodEntry; |
| 26 | 24 | ||
| 27 | public class ClassImplementationsTreeNode extends DefaultMutableTreeNode { | 25 | public class ClassImplementationsTreeNode extends ClassTreeNode { |
| 28 | private final Translator translator; | ||
| 29 | private final ClassEntry entry; | ||
| 30 | |||
| 31 | public ClassImplementationsTreeNode(Translator translator, ClassEntry entry) { | 26 | public ClassImplementationsTreeNode(Translator translator, ClassEntry entry) { |
| 32 | this.translator = translator; | 27 | super(translator, entry); |
| 33 | this.entry = entry; | ||
| 34 | } | 28 | } |
| 35 | 29 | ||
| 36 | public static ClassImplementationsTreeNode findNode(ClassImplementationsTreeNode node, MethodEntry entry) { | 30 | public static ClassImplementationsTreeNode findNode(ClassImplementationsTreeNode node, MethodEntry entry) { |
| 37 | // is this the node? | 31 | // is this the node? |
| 38 | if (node.entry.equals(entry.getParent())) { | 32 | if (node.getClassEntry().equals(entry.getParent())) { |
| 39 | return node; | 33 | return node; |
| 40 | } | 34 | } |
| 41 | 35 | ||
| @@ -51,13 +45,9 @@ public class ClassImplementationsTreeNode extends DefaultMutableTreeNode { | |||
| 51 | return null; | 45 | return null; |
| 52 | } | 46 | } |
| 53 | 47 | ||
| 54 | public ClassEntry getClassEntry() { | ||
| 55 | return this.entry; | ||
| 56 | } | ||
| 57 | |||
| 58 | @Override | 48 | @Override |
| 59 | public String toString() { | 49 | public String toString() { |
| 60 | return translator.translate(entry).toString(); | 50 | return translator.translate(this.getClassEntry()).toString(); |
| 61 | } | 51 | } |
| 62 | 52 | ||
| 63 | public void load(JarIndex index) { | 53 | public void load(JarIndex index) { |
| @@ -65,7 +55,7 @@ public class ClassImplementationsTreeNode extends DefaultMutableTreeNode { | |||
| 65 | List<ClassImplementationsTreeNode> nodes = Lists.newArrayList(); | 55 | List<ClassImplementationsTreeNode> nodes = Lists.newArrayList(); |
| 66 | InheritanceIndex inheritanceIndex = index.getInheritanceIndex(); | 56 | InheritanceIndex inheritanceIndex = index.getInheritanceIndex(); |
| 67 | 57 | ||
| 68 | Collection<ClassEntry> inheritors = inheritanceIndex.getChildren(entry); | 58 | Collection<ClassEntry> inheritors = inheritanceIndex.getChildren(this.getClassEntry()); |
| 69 | 59 | ||
| 70 | for (ClassEntry inheritor : inheritors) { | 60 | for (ClassEntry inheritor : inheritors) { |
| 71 | nodes.add(new ClassImplementationsTreeNode(translator, inheritor)); | 61 | nodes.add(new ClassImplementationsTreeNode(translator, inheritor)); |
diff --git a/enigma/src/main/java/cuchaz/enigma/analysis/ClassInheritanceTreeNode.java b/enigma/src/main/java/cuchaz/enigma/analysis/ClassInheritanceTreeNode.java index 24da23c..dfb2af8 100644 --- a/enigma/src/main/java/cuchaz/enigma/analysis/ClassInheritanceTreeNode.java +++ b/enigma/src/main/java/cuchaz/enigma/analysis/ClassInheritanceTreeNode.java | |||
| @@ -13,21 +13,15 @@ package cuchaz.enigma.analysis; | |||
| 13 | 13 | ||
| 14 | import java.util.List; | 14 | import java.util.List; |
| 15 | 15 | ||
| 16 | import javax.swing.tree.DefaultMutableTreeNode; | ||
| 17 | |||
| 18 | import com.google.common.collect.Lists; | 16 | import com.google.common.collect.Lists; |
| 19 | 17 | ||
| 20 | import cuchaz.enigma.analysis.index.InheritanceIndex; | 18 | import cuchaz.enigma.analysis.index.InheritanceIndex; |
| 21 | import cuchaz.enigma.translation.Translator; | 19 | import cuchaz.enigma.translation.Translator; |
| 22 | import cuchaz.enigma.translation.representation.entry.ClassEntry; | 20 | import cuchaz.enigma.translation.representation.entry.ClassEntry; |
| 23 | 21 | ||
| 24 | public class ClassInheritanceTreeNode extends DefaultMutableTreeNode { | 22 | public class ClassInheritanceTreeNode extends ClassTreeNode { |
| 25 | private final Translator translator; | ||
| 26 | private final ClassEntry obfClassEntry; | ||
| 27 | |||
| 28 | public ClassInheritanceTreeNode(Translator translator, String obfClassName) { | 23 | public ClassInheritanceTreeNode(Translator translator, String obfClassName) { |
| 29 | this.translator = translator; | 24 | super(translator, new ClassEntry(obfClassName)); |
| 30 | this.obfClassEntry = new ClassEntry(obfClassName); | ||
| 31 | } | 25 | } |
| 32 | 26 | ||
| 33 | public static ClassInheritanceTreeNode findNode(ClassInheritanceTreeNode node, ClassEntry entry) { | 27 | public static ClassInheritanceTreeNode findNode(ClassInheritanceTreeNode node, ClassEntry entry) { |
| @@ -48,27 +42,20 @@ public class ClassInheritanceTreeNode extends DefaultMutableTreeNode { | |||
| 48 | return null; | 42 | return null; |
| 49 | } | 43 | } |
| 50 | 44 | ||
| 51 | /** | ||
| 52 | * Returns the class entry represented by this tree node. | ||
| 53 | */ | ||
| 54 | public ClassEntry getClassEntry() { | ||
| 55 | return this.obfClassEntry; | ||
| 56 | } | ||
| 57 | |||
| 58 | public String getObfClassName() { | 45 | public String getObfClassName() { |
| 59 | return this.obfClassEntry.getFullName(); | 46 | return this.getClassEntry().getFullName(); |
| 60 | } | 47 | } |
| 61 | 48 | ||
| 62 | @Override | 49 | @Override |
| 63 | public String toString() { | 50 | public String toString() { |
| 64 | return translator.translate(obfClassEntry).getFullName(); | 51 | return this.translator.translate(this.getClassEntry()).getFullName(); |
| 65 | } | 52 | } |
| 66 | 53 | ||
| 67 | public void load(InheritanceIndex ancestries, boolean recurse) { | 54 | public void load(InheritanceIndex ancestries, boolean recurse) { |
| 68 | // get all the child nodes | 55 | // get all the child nodes |
| 69 | List<ClassInheritanceTreeNode> nodes = Lists.newArrayList(); | 56 | List<ClassInheritanceTreeNode> nodes = Lists.newArrayList(); |
| 70 | 57 | ||
| 71 | for (ClassEntry inheritor : ancestries.getChildren(this.obfClassEntry)) { | 58 | for (ClassEntry inheritor : ancestries.getChildren(this.getClassEntry())) { |
| 72 | nodes.add(new ClassInheritanceTreeNode(translator, inheritor.getFullName())); | 59 | nodes.add(new ClassInheritanceTreeNode(translator, inheritor.getFullName())); |
| 73 | } | 60 | } |
| 74 | 61 | ||
diff --git a/enigma/src/main/java/cuchaz/enigma/analysis/ClassTreeNode.java b/enigma/src/main/java/cuchaz/enigma/analysis/ClassTreeNode.java new file mode 100644 index 0000000..90dc458 --- /dev/null +++ b/enigma/src/main/java/cuchaz/enigma/analysis/ClassTreeNode.java | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | package cuchaz.enigma.analysis; | ||
| 2 | |||
| 3 | import javax.swing.tree.DefaultMutableTreeNode; | ||
| 4 | |||
| 5 | import cuchaz.enigma.translation.Translator; | ||
| 6 | import cuchaz.enigma.translation.representation.entry.ClassEntry; | ||
| 7 | |||
| 8 | public abstract class ClassTreeNode extends DefaultMutableTreeNode { | ||
| 9 | protected final Translator translator; | ||
| 10 | private final ClassEntry entry; | ||
| 11 | |||
| 12 | public ClassTreeNode(Translator translator, ClassEntry entry) { | ||
| 13 | this.translator = translator; | ||
| 14 | this.entry = entry; | ||
| 15 | } | ||
| 16 | |||
| 17 | /** | ||
| 18 | * Returns the class entry represented by this tree node. | ||
| 19 | */ | ||
| 20 | public ClassEntry getClassEntry() { | ||
| 21 | return this.entry; | ||
| 22 | } | ||
| 23 | |||
| 24 | @Override | ||
| 25 | public String toString() { | ||
| 26 | return translator.translate(this.entry).getFullName(); | ||
| 27 | } | ||
| 28 | } | ||
diff --git a/enigma/src/main/java/cuchaz/enigma/analysis/MethodImplementationsTreeNode.java b/enigma/src/main/java/cuchaz/enigma/analysis/MethodImplementationsTreeNode.java index 83275da..d5a34cd 100644 --- a/enigma/src/main/java/cuchaz/enigma/analysis/MethodImplementationsTreeNode.java +++ b/enigma/src/main/java/cuchaz/enigma/analysis/MethodImplementationsTreeNode.java | |||
| @@ -14,8 +14,6 @@ package cuchaz.enigma.analysis; | |||
| 14 | import java.util.Collection; | 14 | import java.util.Collection; |
| 15 | import java.util.List; | 15 | import java.util.List; |
| 16 | 16 | ||
| 17 | import javax.swing.tree.DefaultMutableTreeNode; | ||
| 18 | |||
| 19 | import com.google.common.collect.Lists; | 17 | import com.google.common.collect.Lists; |
| 20 | 18 | ||
| 21 | import cuchaz.enigma.analysis.index.EntryIndex; | 19 | import cuchaz.enigma.analysis.index.EntryIndex; |
| @@ -25,18 +23,13 @@ import cuchaz.enigma.translation.Translator; | |||
| 25 | import cuchaz.enigma.translation.representation.entry.ClassEntry; | 23 | import cuchaz.enigma.translation.representation.entry.ClassEntry; |
| 26 | import cuchaz.enigma.translation.representation.entry.MethodEntry; | 24 | import cuchaz.enigma.translation.representation.entry.MethodEntry; |
| 27 | 25 | ||
| 28 | public class MethodImplementationsTreeNode extends DefaultMutableTreeNode { | 26 | public class MethodImplementationsTreeNode extends MethodTreeNode { |
| 29 | private final Translator translator; | ||
| 30 | private MethodEntry entry; | ||
| 31 | |||
| 32 | public MethodImplementationsTreeNode(Translator translator, MethodEntry entry) { | 27 | public MethodImplementationsTreeNode(Translator translator, MethodEntry entry) { |
| 33 | this.translator = translator; | 28 | super(translator, entry); |
| 34 | 29 | ||
| 35 | if (entry == null) { | 30 | if (entry == null) { |
| 36 | throw new IllegalArgumentException("Entry cannot be null!"); | 31 | throw new IllegalArgumentException("Entry cannot be null!"); |
| 37 | } | 32 | } |
| 38 | |||
| 39 | this.entry = entry; | ||
| 40 | } | 33 | } |
| 41 | 34 | ||
| 42 | public static MethodImplementationsTreeNode findNode(MethodImplementationsTreeNode node, MethodEntry entry) { | 35 | public static MethodImplementationsTreeNode findNode(MethodImplementationsTreeNode node, MethodEntry entry) { |
| @@ -57,13 +50,10 @@ public class MethodImplementationsTreeNode extends DefaultMutableTreeNode { | |||
| 57 | return null; | 50 | return null; |
| 58 | } | 51 | } |
| 59 | 52 | ||
| 60 | public MethodEntry getMethodEntry() { | ||
| 61 | return this.entry; | ||
| 62 | } | ||
| 63 | |||
| 64 | @Override | 53 | @Override |
| 65 | public String toString() { | 54 | public String toString() { |
| 66 | MethodEntry translatedEntry = translator.translate(entry); | 55 | MethodEntry translatedEntry = translator.translate(this.getMethodEntry()); |
| 56 | assert translatedEntry != null; | ||
| 67 | return translatedEntry.getFullName() + "()"; | 57 | return translatedEntry.getFullName() + "()"; |
| 68 | } | 58 | } |
| 69 | 59 | ||
| @@ -73,10 +63,10 @@ public class MethodImplementationsTreeNode extends DefaultMutableTreeNode { | |||
| 73 | EntryIndex entryIndex = index.getEntryIndex(); | 63 | EntryIndex entryIndex = index.getEntryIndex(); |
| 74 | InheritanceIndex inheritanceIndex = index.getInheritanceIndex(); | 64 | InheritanceIndex inheritanceIndex = index.getInheritanceIndex(); |
| 75 | 65 | ||
| 76 | Collection<ClassEntry> descendants = inheritanceIndex.getDescendants(entry.getParent()); | 66 | Collection<ClassEntry> descendants = inheritanceIndex.getDescendants(this.getMethodEntry().getParent()); |
| 77 | 67 | ||
| 78 | for (ClassEntry inheritor : descendants) { | 68 | for (ClassEntry inheritor : descendants) { |
| 79 | MethodEntry methodEntry = entry.withParent(inheritor); | 69 | MethodEntry methodEntry = this.getMethodEntry().withParent(inheritor); |
| 80 | 70 | ||
| 81 | if (entryIndex.hasMethod(methodEntry)) { | 71 | if (entryIndex.hasMethod(methodEntry)) { |
| 82 | nodes.add(new MethodImplementationsTreeNode(translator, methodEntry)); | 72 | nodes.add(new MethodImplementationsTreeNode(translator, methodEntry)); |
diff --git a/enigma/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java b/enigma/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java index 2afeed9..5d73e73 100644 --- a/enigma/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java +++ b/enigma/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java | |||
| @@ -11,8 +11,6 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma.analysis; | 12 | package cuchaz.enigma.analysis; |
| 13 | 13 | ||
| 14 | import javax.swing.tree.DefaultMutableTreeNode; | ||
| 15 | |||
| 16 | import cuchaz.enigma.analysis.index.EntryIndex; | 14 | import cuchaz.enigma.analysis.index.EntryIndex; |
| 17 | import cuchaz.enigma.analysis.index.InheritanceIndex; | 15 | import cuchaz.enigma.analysis.index.InheritanceIndex; |
| 18 | import cuchaz.enigma.analysis.index.JarIndex; | 16 | import cuchaz.enigma.analysis.index.JarIndex; |
| @@ -20,14 +18,11 @@ import cuchaz.enigma.translation.Translator; | |||
| 20 | import cuchaz.enigma.translation.representation.entry.ClassEntry; | 18 | import cuchaz.enigma.translation.representation.entry.ClassEntry; |
| 21 | import cuchaz.enigma.translation.representation.entry.MethodEntry; | 19 | import cuchaz.enigma.translation.representation.entry.MethodEntry; |
| 22 | 20 | ||
| 23 | public class MethodInheritanceTreeNode extends DefaultMutableTreeNode { | 21 | public class MethodInheritanceTreeNode extends MethodTreeNode { |
| 24 | private final Translator translator; | 22 | private final boolean implemented; |
| 25 | private MethodEntry entry; | ||
| 26 | private boolean implemented; | ||
| 27 | 23 | ||
| 28 | public MethodInheritanceTreeNode(Translator translator, MethodEntry entry, boolean implemented) { | 24 | public MethodInheritanceTreeNode(Translator translator, MethodEntry entry, boolean implemented) { |
| 29 | this.translator = translator; | 25 | super(translator, entry); |
| 30 | this.entry = entry; | ||
| 31 | this.implemented = implemented; | 26 | this.implemented = implemented; |
| 32 | } | 27 | } |
| 33 | 28 | ||
| @@ -49,22 +44,17 @@ public class MethodInheritanceTreeNode extends DefaultMutableTreeNode { | |||
| 49 | return null; | 44 | return null; |
| 50 | } | 45 | } |
| 51 | 46 | ||
| 52 | /** | ||
| 53 | * Returns the method entry represented by this tree node. | ||
| 54 | */ | ||
| 55 | public MethodEntry getMethodEntry() { | ||
| 56 | return this.entry; | ||
| 57 | } | ||
| 58 | |||
| 59 | public boolean isImplemented() { | 47 | public boolean isImplemented() { |
| 60 | return this.implemented; | 48 | return this.implemented; |
| 61 | } | 49 | } |
| 62 | 50 | ||
| 63 | @Override | 51 | @Override |
| 64 | public String toString() { | 52 | public String toString() { |
| 65 | MethodEntry translatedEntry = translator.translate(entry); | 53 | MethodEntry translatedEntry = translator.translate(this.getMethodEntry()); |
| 54 | assert translatedEntry != null; | ||
| 66 | 55 | ||
| 67 | if (!this.implemented) { | 56 | if (!this.implemented) { |
| 57 | assert translatedEntry.getParent() != null; | ||
| 68 | return translatedEntry.getParent().getFullName(); | 58 | return translatedEntry.getParent().getFullName(); |
| 69 | } else { | 59 | } else { |
| 70 | return translatedEntry.getFullName() + "()"; | 60 | return translatedEntry.getFullName() + "()"; |
| @@ -81,8 +71,8 @@ public class MethodInheritanceTreeNode extends DefaultMutableTreeNode { | |||
| 81 | 71 | ||
| 82 | boolean ret = false; | 72 | boolean ret = false; |
| 83 | 73 | ||
| 84 | for (ClassEntry inheritorEntry : inheritanceIndex.getChildren(this.entry.getParent())) { | 74 | for (ClassEntry inheritorEntry : inheritanceIndex.getChildren(this.getMethodEntry().getParent())) { |
| 85 | MethodEntry methodEntry = new MethodEntry(inheritorEntry, this.entry.getName(), this.entry.getDesc()); | 75 | MethodEntry methodEntry = new MethodEntry(inheritorEntry, this.getMethodEntry().getName(), this.getMethodEntry().getDesc()); |
| 86 | 76 | ||
| 87 | MethodInheritanceTreeNode node = new MethodInheritanceTreeNode(translator, methodEntry, entryIndex.hasMethod(methodEntry)); | 77 | MethodInheritanceTreeNode node = new MethodInheritanceTreeNode(translator, methodEntry, entryIndex.hasMethod(methodEntry)); |
| 88 | boolean childOverride = node.load(index); | 78 | boolean childOverride = node.load(index); |
diff --git a/enigma/src/main/java/cuchaz/enigma/analysis/MethodTreeNode.java b/enigma/src/main/java/cuchaz/enigma/analysis/MethodTreeNode.java new file mode 100644 index 0000000..d50a559 --- /dev/null +++ b/enigma/src/main/java/cuchaz/enigma/analysis/MethodTreeNode.java | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | package cuchaz.enigma.analysis; | ||
| 2 | |||
| 3 | import javax.swing.tree.DefaultMutableTreeNode; | ||
| 4 | |||
| 5 | import cuchaz.enigma.translation.Translator; | ||
| 6 | import cuchaz.enigma.translation.representation.entry.MethodEntry; | ||
| 7 | |||
| 8 | public class MethodTreeNode extends DefaultMutableTreeNode { | ||
| 9 | protected final Translator translator; | ||
| 10 | private final MethodEntry entry; | ||
| 11 | |||
| 12 | public MethodTreeNode(Translator translator, MethodEntry entry) { | ||
| 13 | this.translator = translator; | ||
| 14 | this.entry = entry; | ||
| 15 | } | ||
| 16 | |||
| 17 | /** | ||
| 18 | * Returns the method entry represented by this tree node. | ||
| 19 | */ | ||
| 20 | public MethodEntry getMethodEntry() { | ||
| 21 | return this.entry; | ||
| 22 | } | ||
| 23 | } | ||