From e16f81dba9edadb3fc02492bfeff06266890e754 Mon Sep 17 00:00:00 2001 From: Yanis48 Date: Mon, 14 Dec 2020 21:15:53 +0100 Subject: Structure panel! --- .../src/main/java/cuchaz/enigma/gui/Gui.java | 56 +++++++++-- .../main/java/cuchaz/enigma/gui/GuiController.java | 12 ++- .../cuchaz/enigma/gui/panels/StructurePanel.java | 102 +++++++++++++++++++ .../main/java/cuchaz/enigma/gui/util/GuiUtil.java | 31 ++++-- enigma-swing/src/main/resources/icons/class.png | Bin 0 -> 408 bytes enigma-swing/src/main/resources/icons/field.png | Bin 0 -> 392 bytes enigma-swing/src/main/resources/icons/method.png | Bin 0 -> 618 bytes .../cuchaz/enigma/analysis/StructureTreeNode.java | 109 +++++++++++++++++++++ .../cuchaz/enigma/analysis/index/JarIndex.java | 24 ++++- .../translation/representation/TypeDescriptor.java | 27 +++-- .../representation/entry/ClassEntry.java | 3 + .../translation/representation/entry/Entry.java | 7 ++ enigma/src/main/resources/lang/en_us.json | 2 + enigma/src/main/resources/lang/fr_fr.json | 2 + 14 files changed, 338 insertions(+), 37 deletions(-) create mode 100644 enigma-swing/src/main/java/cuchaz/enigma/gui/panels/StructurePanel.java create mode 100644 enigma-swing/src/main/resources/icons/class.png create mode 100644 enigma-swing/src/main/resources/icons/field.png create mode 100644 enigma-swing/src/main/resources/icons/method.png create mode 100644 enigma/src/main/java/cuchaz/enigma/analysis/StructureTreeNode.java diff --git a/enigma-swing/src/main/java/cuchaz/enigma/gui/Gui.java b/enigma-swing/src/main/java/cuchaz/enigma/gui/Gui.java index c56731dc..a3a438ee 100644 --- a/enigma-swing/src/main/java/cuchaz/enigma/gui/Gui.java +++ b/enigma-swing/src/main/java/cuchaz/enigma/gui/Gui.java @@ -51,10 +51,7 @@ import cuchaz.enigma.network.packet.RemoveMappingC2SPacket; import cuchaz.enigma.network.packet.RenameC2SPacket; import cuchaz.enigma.source.Token; import cuchaz.enigma.translation.mapping.EntryRemapper; -import cuchaz.enigma.translation.representation.entry.ClassEntry; -import cuchaz.enigma.translation.representation.entry.Entry; -import cuchaz.enigma.translation.representation.entry.FieldEntry; -import cuchaz.enigma.translation.representation.entry.MethodEntry; +import cuchaz.enigma.translation.representation.entry.*; import cuchaz.enigma.utils.I18n; import cuchaz.enigma.utils.validation.ParameterizedMessage; import cuchaz.enigma.utils.validation.ValidationContext; @@ -82,6 +79,7 @@ public class Gui implements LanguageChangeListener { private JPanel classesPanel; private JSplitPane splitClasses; private IdentifierPanel infoPanel; + private StructurePanel structurePanel; private JTree inheritanceTree; private JTree implementationsTree; private JTree callsTree; @@ -163,6 +161,9 @@ public class Gui implements LanguageChangeListener { // init info panel infoPanel = new IdentifierPanel(this); + // init structure panel + this.structurePanel = new StructurePanel(this); + // init inheritance panel inheritanceTree = new JTree(); inheritanceTree.setModel(null); @@ -287,6 +288,8 @@ public class Gui implements LanguageChangeListener { editorTabPopupMenu.show(openFiles, e.getX(), e.getY(), EditorPanel.byUi(openFiles.getComponentAt(i))); } } + + showStructure(getActiveEditor()); } }); @@ -311,6 +314,7 @@ public class Gui implements LanguageChangeListener { centerPanel.add(openFiles, BorderLayout.CENTER); tabs = new JTabbedPane(); tabs.setPreferredSize(ScaleUtil.getDimension(250, 0)); + tabs.addTab(I18n.translate("info_panel.tree.structure"), structurePanel); tabs.addTab(I18n.translate("info_panel.tree.inheritance"), inheritancePanel); tabs.addTab(I18n.translate("info_panel.tree.implementations"), implementationsPanel); tabs.addTab(I18n.translate("info_panel.tree.calls"), callPanel); @@ -482,11 +486,14 @@ public class Gui implements LanguageChangeListener { } }); + showStructure(ed); + return ed; }); if (editorPanel != null) { openFiles.setSelectedComponent(editors.get(entry).getUi()); } + return editorPanel; } @@ -506,6 +513,7 @@ public class Gui implements LanguageChangeListener { public void closeEditor(EditorPanel ed) { openFiles.remove(ed.getUi()); editors.inverse().remove(ed); + showStructure(getActiveEditor()); ed.destroy(); } @@ -595,6 +603,32 @@ public class Gui implements LanguageChangeListener { infoPanel.startRenaming(); } + public void showStructure(EditorPanel editor) { + JTree structureTree = this.structurePanel.getStructureTree(); + structureTree.setModel(null); + + if (editor == null) { + this.structurePanel.getSortingPanel().setVisible(false); + return; + } + + ClassEntry classEntry = editor.getClassHandle().getRef(); + if (classEntry == null) return; + + this.structurePanel.getSortingPanel().setVisible(true); + + // get the class structure + StructureTreeNode node = this.controller.getClassStructure(classEntry, this.structurePanel.shouldHideDeobfuscated()); + + // show the tree at the root + TreePath path = getPathToRoot(node); + structureTree.setModel(new DefaultTreeModel((TreeNode) path.getPathComponent(0))); + structureTree.expandPath(path); + structureTree.setSelectionRow(structureTree.getRowForPath(path)); + + redraw(); + } + public void showInheritance(EditorPanel editor) { EntryReference, Entry> cursorReference = editor.getCursorReference(); if (cursorReference == null) return; @@ -621,7 +655,7 @@ public class Gui implements LanguageChangeListener { inheritanceTree.setSelectionRow(inheritanceTree.getRowForPath(path)); } - tabs.setSelectedIndex(0); + tabs.setSelectedIndex(1); redraw(); } @@ -649,7 +683,7 @@ public class Gui implements LanguageChangeListener { implementationsTree.setSelectionRow(implementationsTree.getRowForPath(path)); } - tabs.setSelectedIndex(1); + tabs.setSelectedIndex(2); redraw(); } @@ -669,7 +703,7 @@ public class Gui implements LanguageChangeListener { callsTree.setModel(new DefaultTreeModel(node)); } - tabs.setSelectedIndex(2); + tabs.setSelectedIndex(3); redraw(); } @@ -893,9 +927,10 @@ public class Gui implements LanguageChangeListener { public void retranslateUi() { this.jarFileChooser.setTitle(I18n.translate("menu.file.jar.open")); this.exportJarFileChooser.setTitle(I18n.translate("menu.file.export.jar")); - this.tabs.setTitleAt(0, I18n.translate("info_panel.tree.inheritance")); - this.tabs.setTitleAt(1, I18n.translate("info_panel.tree.implementations")); - this.tabs.setTitleAt(2, I18n.translate("info_panel.tree.calls")); + this.tabs.setTitleAt(0, I18n.translate("info_panel.tree.structure")); + this.tabs.setTitleAt(1, I18n.translate("info_panel.tree.inheritance")); + this.tabs.setTitleAt(2, I18n.translate("info_panel.tree.implementations")); + this.tabs.setTitleAt(3, I18n.translate("info_panel.tree.calls")); this.logTabs.setTitleAt(0, I18n.translate("log_panel.users")); this.logTabs.setTitleAt(1, I18n.translate("log_panel.messages")); this.connectionStatusLabel.setText(I18n.translate(connectionState == ConnectionState.NOT_CONNECTED ? "status.disconnected" : "status.connected")); @@ -907,6 +942,7 @@ public class Gui implements LanguageChangeListener { this.deobfPanel.retranslateUi(); this.deobfPanelPopupMenu.retranslateUi(); this.infoPanel.retranslateUi(); + this.structurePanel.retranslateUi(); this.editors.values().forEach(EditorPanel::retranslateUi); } diff --git a/enigma-swing/src/main/java/cuchaz/enigma/gui/GuiController.java b/enigma-swing/src/main/java/cuchaz/enigma/gui/GuiController.java index 4f7819e4..4e964dae 100644 --- a/enigma-swing/src/main/java/cuchaz/enigma/gui/GuiController.java +++ b/enigma-swing/src/main/java/cuchaz/enigma/gui/GuiController.java @@ -57,10 +57,7 @@ import cuchaz.enigma.translation.mapping.serde.MappingParseException; import cuchaz.enigma.translation.mapping.serde.MappingSaveParameters; import cuchaz.enigma.translation.mapping.tree.EntryTree; import cuchaz.enigma.translation.mapping.tree.HashEntryTree; -import cuchaz.enigma.translation.representation.entry.ClassEntry; -import cuchaz.enigma.translation.representation.entry.Entry; -import cuchaz.enigma.translation.representation.entry.FieldEntry; -import cuchaz.enigma.translation.representation.entry.MethodEntry; +import cuchaz.enigma.translation.representation.entry.*; import cuchaz.enigma.utils.I18n; import cuchaz.enigma.utils.Utils; import cuchaz.enigma.utils.validation.ValidationContext; @@ -395,6 +392,13 @@ public class GuiController implements ClientPacketHandler { chp.invalidateMapped(); } + public StructureTreeNode getClassStructure(ClassEntry entry, boolean hideDeobfuscated) { + Translator translator = this.project.getMapper().getDeobfuscator(); + StructureTreeNode rootNode = new StructureTreeNode(translator, entry, entry); + rootNode.load(this.project.getJarIndex(), hideDeobfuscated); + return rootNode; + } + public ClassInheritanceTreeNode getClassInheritance(ClassEntry entry) { Translator translator = project.getMapper().getDeobfuscator(); ClassInheritanceTreeNode rootNode = indexTreeBuilder.buildClassInheritance(translator, entry); diff --git a/enigma-swing/src/main/java/cuchaz/enigma/gui/panels/StructurePanel.java b/enigma-swing/src/main/java/cuchaz/enigma/gui/panels/StructurePanel.java new file mode 100644 index 00000000..32f803f8 --- /dev/null +++ b/enigma-swing/src/main/java/cuchaz/enigma/gui/panels/StructurePanel.java @@ -0,0 +1,102 @@ +package cuchaz.enigma.gui.panels; + +import cuchaz.enigma.analysis.StructureTreeNode; +import cuchaz.enigma.gui.Gui; +import cuchaz.enigma.gui.util.GuiUtil; +import cuchaz.enigma.translation.representation.entry.ClassEntry; +import cuchaz.enigma.translation.representation.entry.FieldEntry; +import cuchaz.enigma.translation.representation.entry.MethodEntry; +import cuchaz.enigma.translation.representation.entry.ParentedEntry; +import cuchaz.enigma.utils.I18n; + +import javax.swing.*; +import javax.swing.tree.TreeCellRenderer; +import javax.swing.tree.TreePath; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +public class StructurePanel extends JPanel { + private final Gui gui; + + private JPanel sortingPanel; + private JCheckBox hideDeobfuscated; + + private JTree structureTree; + + public StructurePanel(Gui gui) { + this.gui = gui; + + this.sortingPanel = new JPanel(); + this.hideDeobfuscated = new JCheckBox(I18n.translate("info_panel.tree.structure.hide_deobfuscated")); + this.hideDeobfuscated.addActionListener(event -> gui.showStructure(gui.getActiveEditor())); + this.sortingPanel.add(this.hideDeobfuscated); + this.sortingPanel.setVisible(false); + + this.structureTree = new JTree(); + this.structureTree.setModel(null); + this.structureTree.setCellRenderer(new StructureTreeCellRenderer()); + this.structureTree.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent event) { + if (event.getClickCount() >= 2) { + // get the selected node + TreePath path = structureTree.getSelectionPath(); + if (path == null) { + return; + } + + Object node = path.getLastPathComponent(); + if (node instanceof StructureTreeNode) { + gui.getController().navigateTo(((StructureTreeNode) node).getEntry()); + } + } + } + }); + + this.setLayout(new BorderLayout()); + this.add(this.sortingPanel, BorderLayout.NORTH); + this.add(new JScrollPane(this.structureTree)); + } + + public JPanel getSortingPanel() { + return this.sortingPanel; + } + + public boolean shouldHideDeobfuscated() { + return this.hideDeobfuscated.isSelected(); + } + + public JTree getStructureTree() { + return this.structureTree; + } + + public void retranslateUi() { + this.hideDeobfuscated.setText(I18n.translate("info_panel.tree.structure.hide_deobfuscated")); + } + + class StructureTreeCellRenderer implements TreeCellRenderer { + private JLabel label; + + public StructureTreeCellRenderer() { + this.label = new JLabel(); + } + + @Override + public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { + ParentedEntry entry = ((StructureTreeNode) value).getEntry(); + + if (entry instanceof ClassEntry) { + this.label.setIcon(GuiUtil.CLASS_ICON); + } else if (entry instanceof MethodEntry) { + this.label.setIcon(GuiUtil.METHOD_ICON); + } else if (entry instanceof FieldEntry) { + this.label.setIcon(GuiUtil.FIELD_ICON); + } + + this.label.setText(value.toString()); + + return this.label; + } + } +} diff --git a/enigma-swing/src/main/java/cuchaz/enigma/gui/util/GuiUtil.java b/enigma-swing/src/main/java/cuchaz/enigma/gui/util/GuiUtil.java index 7fe942d0..666fc0aa 100644 --- a/enigma-swing/src/main/java/cuchaz/enigma/gui/util/GuiUtil.java +++ b/enigma-swing/src/main/java/cuchaz/enigma/gui/util/GuiUtil.java @@ -1,24 +1,24 @@ package cuchaz.enigma.gui.util; -import java.awt.Color; -import java.awt.Cursor; -import java.awt.Desktop; -import java.awt.Font; +import cuchaz.enigma.utils.Os; + +import javax.imageio.ImageIO; +import javax.swing.*; +import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.font.TextAttribute; import java.io.IOException; +import java.io.InputStream; import java.net.URI; import java.net.URISyntaxException; import java.util.Map; -import javax.swing.JComponent; -import javax.swing.JLabel; -import javax.swing.ToolTipManager; - -import cuchaz.enigma.utils.Os; - public class GuiUtil { + public static final Icon CLASS_ICON = loadIcon("class"); + public static final Icon METHOD_ICON = loadIcon("method"); + public static final Icon FIELD_ICON = loadIcon("field"); + public static void openUrl(String url) { try { switch (Os.getOs()) { @@ -70,4 +70,15 @@ public class GuiUtil { return link; } + public static Icon loadIcon(String name) { + try { + InputStream inputStream = GuiUtil.class.getResourceAsStream("/icons/" + name + ".png"); + Image image = ImageIO.read(inputStream).getScaledInstance(ScaleUtil.scale(16), ScaleUtil.scale(16), Image.SCALE_DEFAULT); + return new ImageIcon(image); + } catch (IOException e) { + e.printStackTrace(); + } + + return null; + } } diff --git a/enigma-swing/src/main/resources/icons/class.png b/enigma-swing/src/main/resources/icons/class.png new file mode 100644 index 00000000..4f7d0f42 Binary files /dev/null and b/enigma-swing/src/main/resources/icons/class.png differ diff --git a/enigma-swing/src/main/resources/icons/field.png b/enigma-swing/src/main/resources/icons/field.png new file mode 100644 index 00000000..b124dcf5 Binary files /dev/null and b/enigma-swing/src/main/resources/icons/field.png differ diff --git a/enigma-swing/src/main/resources/icons/method.png b/enigma-swing/src/main/resources/icons/method.png new file mode 100644 index 00000000..4ed0ccc1 Binary files /dev/null and b/enigma-swing/src/main/resources/icons/method.png differ diff --git a/enigma/src/main/java/cuchaz/enigma/analysis/StructureTreeNode.java b/enigma/src/main/java/cuchaz/enigma/analysis/StructureTreeNode.java new file mode 100644 index 00000000..13f277c7 --- /dev/null +++ b/enigma/src/main/java/cuchaz/enigma/analysis/StructureTreeNode.java @@ -0,0 +1,109 @@ +package cuchaz.enigma.analysis; + +import cuchaz.enigma.analysis.index.JarIndex; +import cuchaz.enigma.translation.Translator; +import cuchaz.enigma.translation.representation.TypeDescriptor; +import cuchaz.enigma.translation.representation.entry.*; + +import javax.swing.tree.DefaultMutableTreeNode; +import java.util.List; + +public class StructureTreeNode extends DefaultMutableTreeNode { + private final Translator translator; + private final ClassEntry parentEntry; + private final ParentedEntry entry; + + public StructureTreeNode(Translator translator, ClassEntry parentEntry, ParentedEntry entry) { + this.translator = translator; + this.parentEntry = parentEntry; + this.entry = entry; + } + + /** + * Returns the parented entry corresponding to this tree node. + */ + public ParentedEntry getEntry() { + return this.entry; + } + + public void load(JarIndex jarIndex, boolean hideDeobfuscated) { + List children = jarIndex.getChildrenByClass().get(this.parentEntry); + + for (ParentedEntry child : children) { + StructureTreeNode childNode = new StructureTreeNode(this.translator, this.parentEntry, child); + + if (child instanceof ClassEntry) { + childNode = new StructureTreeNode(this.translator, (ClassEntry) child, child); + childNode.load(jarIndex, hideDeobfuscated); + } + + // don't add deobfuscated members if hideDeobfuscated is true, unless it's an inner class + if (hideDeobfuscated && this.translator.extendedTranslate(child).isDeobfuscated() && !(child instanceof ClassEntry)) { + continue; + } + + // don't add constructor methods if hideDeobfuscated is true + if (hideDeobfuscated && (child instanceof MethodEntry) && ((MethodEntry) child).isConstructor()) { + continue; + } + + this.add(childNode); + } + } + + @Override + public String toString() { + ParentedEntry translatedEntry = this.translator.extendedTranslate(this.entry).getValue(); + String result = translatedEntry.getName(); + + if (this.entry instanceof FieldDefEntry) { + FieldDefEntry field = (FieldDefEntry) translatedEntry; + String returnType = this.parseDesc(field.getDesc()); + + result = result + ": " + returnType; + } else if (this.entry instanceof MethodDefEntry) { + MethodDefEntry method = (MethodDefEntry) translatedEntry; + String args = this.parseArgs(method.getDesc().getArgumentDescs()); + String returnType = this.parseDesc(method.getDesc().getReturnDesc()); + + if (method.isConstructor()) { + result = method.getParent().getSimpleName() + args; + } else { + result = result + args + ": " + returnType; + } + } + + return result; + } + + private String parseArgs(List args) { + if (args.size() > 0) { + String result = "("; + + for (int i = 0; i < args.size(); i++) { + if (i > 0) { + result += ", "; + } + + result += this.parseDesc(args.get(i)); + } + + return result + ")"; + } + + return "()"; + } + + private String parseDesc(TypeDescriptor desc) { + if (desc.isVoid()) return "void"; + if (desc.isPrimitive()) return desc.getPrimitive().getKeyword(); + if (desc.isType()) return desc.getTypeEntry().getSimpleName(); + + if (desc.isArray()) { + if (desc.getArrayType().isPrimitive()) return desc.getArrayType().getPrimitive().getKeyword() + "[]"; + if (desc.getArrayType().isType()) return desc.getArrayType().getTypeEntry().getSimpleName() + "[]"; + } + + return null; + } +} diff --git a/enigma/src/main/java/cuchaz/enigma/analysis/index/JarIndex.java b/enigma/src/main/java/cuchaz/enigma/analysis/index/JarIndex.java index b5ad91a8..d41731fb 100644 --- a/enigma/src/main/java/cuchaz/enigma/analysis/index/JarIndex.java +++ b/enigma/src/main/java/cuchaz/enigma/analysis/index/JarIndex.java @@ -23,10 +23,7 @@ import cuchaz.enigma.translation.representation.Lambda; import cuchaz.enigma.translation.representation.entry.*; import cuchaz.enigma.utils.I18n; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; +import java.util.*; public class JarIndex implements JarIndexer { private final Set indexedClasses = new HashSet<>(); @@ -40,6 +37,7 @@ public class JarIndex implements JarIndexer { private final Collection indexers; private final Multimap methodImplementations = HashMultimap.create(); + private final Map> childrenByClass; public JarIndex(EntryIndex entryIndex, InheritanceIndex inheritanceIndex, ReferenceIndex referenceIndex, BridgeMethodIndex bridgeMethodIndex, PackageVisibilityIndex packageVisibilityIndex) { this.entryIndex = entryIndex; @@ -49,6 +47,7 @@ public class JarIndex implements JarIndexer { this.packageVisibilityIndex = packageVisibilityIndex; this.indexers = Arrays.asList(entryIndex, inheritanceIndex, referenceIndex, bridgeMethodIndex, packageVisibilityIndex); this.entryResolver = new IndexEntryResolver(this); + this.childrenByClass = new HashMap<>(); } public static JarIndex empty() { @@ -101,6 +100,11 @@ public class JarIndex implements JarIndexer { } indexers.forEach(indexer -> indexer.indexClass(classEntry)); + childrenByClass.putIfAbsent(classEntry, new ArrayList<>()); + if (classEntry.isInnerClass() && !classEntry.getAccess().isSynthetic()) { + childrenByClass.putIfAbsent(classEntry.getParent(), new ArrayList<>()); + childrenByClass.get(classEntry.getParent()).add(classEntry); + } } @Override @@ -110,6 +114,10 @@ public class JarIndex implements JarIndexer { } indexers.forEach(indexer -> indexer.indexField(fieldEntry)); + if (!fieldEntry.getAccess().isSynthetic()) { + childrenByClass.putIfAbsent(fieldEntry.getParent(), new ArrayList<>()); + childrenByClass.get(fieldEntry.getParent()).add(fieldEntry); + } } @Override @@ -119,6 +127,10 @@ public class JarIndex implements JarIndexer { } indexers.forEach(indexer -> indexer.indexMethod(methodEntry)); + if (!methodEntry.getAccess().isSynthetic() && !methodEntry.getName().equals("")) { + childrenByClass.putIfAbsent(methodEntry.getParent(), new ArrayList<>()); + childrenByClass.get(methodEntry.getParent()).add(methodEntry); + } if (!methodEntry.isConstructor()) { methodImplementations.put(methodEntry.getParent().getFullName(), methodEntry); @@ -176,6 +188,10 @@ public class JarIndex implements JarIndexer { return entryResolver; } + public Map> getChildrenByClass() { + return this.childrenByClass; + } + public boolean isIndexed(String internalName) { return indexedClasses.contains(internalName); } diff --git a/enigma/src/main/java/cuchaz/enigma/translation/representation/TypeDescriptor.java b/enigma/src/main/java/cuchaz/enigma/translation/representation/TypeDescriptor.java index a7dccfcf..6a1b82f0 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/representation/TypeDescriptor.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/representation/TypeDescriptor.java @@ -235,14 +235,14 @@ public class TypeDescriptor implements Translatable { } public enum Primitive { - BYTE('B'), - CHARACTER('C'), - SHORT('S'), - INTEGER('I'), - LONG('J'), - FLOAT('F'), - DOUBLE('D'), - BOOLEAN('Z'); + BYTE('B', "byte"), + CHARACTER('C', "char"), + SHORT('S', "short"), + INTEGER('I', "int"), + LONG('J', "long"), + FLOAT('F', "float"), + DOUBLE('D', "double"), + BOOLEAN('Z', "boolean"); private static final Map lookup; @@ -254,9 +254,11 @@ public class TypeDescriptor implements Translatable { } private char code; + private String keyword; - Primitive(char code) { + Primitive(char code, String keyword) { this.code = code; + this.keyword = keyword; } public static Primitive get(char code) { @@ -266,5 +268,12 @@ public class TypeDescriptor implements Translatable { public char getCode() { return this.code; } + + /** + * Returns the Java keyword corresponding to this primitive. + */ + public String getKeyword() { + return this.keyword; + } } } diff --git a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/ClassEntry.java b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/ClassEntry.java index 4a50021c..b4a22f1e 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/ClassEntry.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/ClassEntry.java @@ -134,6 +134,9 @@ public class ClassEntry extends ParentedEntry implements Comparable< return name; } + /** + * Returns whether this class entry has a parent, and therefore is an inner class. + */ public boolean isInnerClass() { return parent != null; } diff --git a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/Entry.java b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/Entry.java index ff392fee..6fd412a0 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/Entry.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/Entry.java @@ -29,6 +29,13 @@ public interface Entry

> extends Translatable { return getName(); } + /** + * Returns the parent entry of this entry. + * + *

The parent entry should be a {@linkplain MethodEntry method} for local variables, + * a {@linkplain ClassEntry class} for methods, fields and inner classes, and {@code null} + * for other classes.

+ */ @Nullable P getParent(); diff --git a/enigma/src/main/resources/lang/en_us.json b/enigma/src/main/resources/lang/en_us.json index 9db4e1fc..8195bb1f 100644 --- a/enigma/src/main/resources/lang/en_us.json +++ b/enigma/src/main/resources/lang/en_us.json @@ -101,6 +101,8 @@ "info_panel.identifier.index": "Index", "info_panel.editor.class.decompiling": "(decompiling...)", "info_panel.editor.class.not_found": "Unable to find class:", + "info_panel.tree.structure": "Structure", + "info_panel.tree.structure.hide_deobfuscated": "Hide deobfuscated members", "info_panel.tree.inheritance": "Inheritance", "info_panel.tree.implementations": "Implementations", "info_panel.tree.calls": "Call Graph", diff --git a/enigma/src/main/resources/lang/fr_fr.json b/enigma/src/main/resources/lang/fr_fr.json index 127b9c88..43bea4de 100644 --- a/enigma/src/main/resources/lang/fr_fr.json +++ b/enigma/src/main/resources/lang/fr_fr.json @@ -101,6 +101,8 @@ "info_panel.identifier.index": "Index", "info_panel.editor.class.decompiling": "(décompilation...)", "info_panel.editor.class.not_found": "Impossible de trouver la classe :", + "info_panel.tree.structure": "Structure", + "info_panel.tree.structure.hide_deobfuscated": "Masquer les membres déobfusqués", "info_panel.tree.inheritance": "Héritage", "info_panel.tree.implementations": "Implémentations", "info_panel.tree.calls": "Graphique des appels", -- cgit v1.2.3