From 00fcd0550fcdda621c2e4662f6ddd55ce673b931 Mon Sep 17 00:00:00 2001 From: Gegy Date: Thu, 24 Jan 2019 14:48:32 +0200 Subject: [WIP] Mapping rework (#91) * Move packages * Mapping & entry refactor: first pass * Fix deobf -> obf tree remapping * Resolve various issues * Give all entries the potential for parents and treat inner classes as children * Deobf UI tree elements * Tests pass * Sort mapping output * Fix delta tracking * Index separation and first pass for #97 * Keep track of remapped jar index * Fix child entries not being remapped * Drop non-root entries * Track dropped mappings * Fix enigma mapping ordering * EntryTreeNode interface * Small tweaks * Naive full index remap on rename * Entries can resolve to more than one root entry * Support alternative resolution strategies * Bridge method resolution * Tests pass * Fix mappings being used where there are none * Fix methods with different descriptors being considered unique. closes #89 --- src/main/java/cuchaz/enigma/gui/CodeReader.java | 57 ++----------------------- 1 file changed, 4 insertions(+), 53 deletions(-) (limited to 'src/main/java/cuchaz/enigma/gui/CodeReader.java') diff --git a/src/main/java/cuchaz/enigma/gui/CodeReader.java b/src/main/java/cuchaz/enigma/gui/CodeReader.java index 137c730..0810043 100644 --- a/src/main/java/cuchaz/enigma/gui/CodeReader.java +++ b/src/main/java/cuchaz/enigma/gui/CodeReader.java @@ -16,9 +16,8 @@ import cuchaz.enigma.Deobfuscator; import cuchaz.enigma.analysis.EntryReference; import cuchaz.enigma.analysis.SourceIndex; import cuchaz.enigma.analysis.Token; -import cuchaz.enigma.gui.highlight.SelectionHighlightPainter; -import cuchaz.enigma.mapping.entry.ClassEntry; -import cuchaz.enigma.mapping.entry.Entry; +import cuchaz.enigma.translation.representation.entry.ClassEntry; +import cuchaz.enigma.translation.representation.entry.Entry; import de.sciss.syntaxpane.DefaultSyntaxKit; import javax.swing.*; @@ -33,7 +32,6 @@ public class CodeReader extends JEditorPane { private static final long serialVersionUID = 3673180950485748810L; private static final Object lock = new Object(); - private SelectionHighlightPainter selectionHighlightPainter; private SourceIndex sourceIndex; private SelectionListener selectionListener; @@ -58,8 +56,6 @@ public class CodeReader extends JEditorPane { } } }); - - selectionHighlightPainter = new SelectionHighlightPainter(); } // HACKHACK: someday we can update the main GUI to use this code reader @@ -144,7 +140,7 @@ public class CodeReader extends JEditorPane { // decompile it - CompilationUnit sourceTree = deobfuscator.getSourceTree(classEntry.getOutermostClassName()); + CompilationUnit sourceTree = deobfuscator.getSourceTree(classEntry.getName()); String source = deobfuscator.getSource(sourceTree); setCode(source); sourceIndex = deobfuscator.getSourceIndex(sourceTree, source, ignoreBadTokens); @@ -155,52 +151,7 @@ public class CodeReader extends JEditorPane { }).start(); } - public void navigateToClassDeclaration(ClassEntry classEntry) { - - // navigate to the class declaration - Token token = sourceIndex.getDeclarationToken(classEntry); - if (token == null) { - // couldn't find the class declaration token, might be an anonymous class - // look for any declaration in that class instead - for (Entry entry : sourceIndex.declarations()) { - if (entry.getOwnerClassEntry().equals(classEntry)) { - token = sourceIndex.getDeclarationToken(entry); - break; - } - } - } - - if (token != null) { - navigateToToken(token); - } else { - // couldn't find anything =( - System.out.println("Unable to find declaration in source for " + classEntry); - } - } - - public void navigateToToken(final Token token) { - navigateToToken(this, token, selectionHighlightPainter); - } - - public void setHighlightedTokens(Iterable tokens, HighlightPainter painter) { - for (Token token : tokens) { - setHighlightedToken(token, painter); - } - } - - public void setHighlightedToken(Token token, HighlightPainter painter) { - try { - getHighlighter().addHighlight(token.start, token.end, painter); - } catch (BadLocationException ex) { - throw new IllegalArgumentException(ex); - } - } - - public void clearHighlights() { - getHighlighter().removeAllHighlights(); - } - public interface SelectionListener { - void onSelect(EntryReference reference); + void onSelect(EntryReference, Entry> reference); } } -- cgit v1.2.3