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 --- .../cuchaz/enigma/mapping/MappingsSRGWriter.java | 80 ---------------------- 1 file changed, 80 deletions(-) delete mode 100644 src/main/java/cuchaz/enigma/mapping/MappingsSRGWriter.java (limited to 'src/main/java/cuchaz/enigma/mapping/MappingsSRGWriter.java') diff --git a/src/main/java/cuchaz/enigma/mapping/MappingsSRGWriter.java b/src/main/java/cuchaz/enigma/mapping/MappingsSRGWriter.java deleted file mode 100644 index 32f0ee9..0000000 --- a/src/main/java/cuchaz/enigma/mapping/MappingsSRGWriter.java +++ /dev/null @@ -1,80 +0,0 @@ -package cuchaz.enigma.mapping; - -import com.google.common.base.Charsets; -import cuchaz.enigma.analysis.TranslationIndex; -import cuchaz.enigma.mapping.entry.ReferencedEntryPool; - -import java.io.*; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * Created by Mark on 11/08/2016. - */ -public class MappingsSRGWriter { - - public void write(File file, Mappings mappings) throws IOException { - if (file.exists()) { - file.delete(); - } - file.createNewFile(); - - TranslationIndex index = new TranslationIndex(new ReferencedEntryPool()); - - PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), Charsets.UTF_8)); - List fieldMappings = new ArrayList<>(); - List methodMappings = new ArrayList<>(); - for (ClassMapping classMapping : sorted(mappings.classes())) { - if (classMapping.getDeobfName() == null || classMapping.getObfSimpleName() == null || classMapping.getDeobfName() == null) { - continue; - } - writer.write("CL: " + classMapping.getObfSimpleName() + " " + classMapping.getDeobfName()); - writer.write(System.lineSeparator()); - for (ClassMapping innerClassMapping : sorted(classMapping.innerClasses())) { - if (innerClassMapping.getDeobfName() == null || innerClassMapping.getObfSimpleName() == null || innerClassMapping.getDeobfName() == null) { - continue; - } - String innerClassName = classMapping.getObfSimpleName() + "$" + innerClassMapping.getObfSimpleName(); - String innerDeobfClassName = classMapping.getDeobfName() + "$" + innerClassMapping.getDeobfName(); - writer.write("CL: " + innerClassName + " " + classMapping.getDeobfName() + "$" + innerClassMapping.getDeobfName()); - writer.write(System.lineSeparator()); - for (FieldMapping fieldMapping : sorted(innerClassMapping.fields())) { - fieldMappings.add("FD: " + innerClassName + "/" + fieldMapping.getObfName() + " " + innerDeobfClassName + "/" + fieldMapping.getDeobfName()); - } - - for (MethodMapping methodMapping : sorted(innerClassMapping.methods())) { - methodMappings.add("MD: " + innerClassName + "/" + methodMapping.getObfName() + " " + methodMapping.getObfDesc() + " " + innerDeobfClassName + "/" + methodMapping.getDeobfName() + " " + mappings.getTranslator(TranslationDirection.DEOBFUSCATING, index).getTranslatedMethodDesc(methodMapping.getObfDesc())); - } - } - - for (FieldMapping fieldMapping : sorted(classMapping.fields())) { - fieldMappings.add("FD: " + classMapping.getObfFullName() + "/" + fieldMapping.getObfName() + " " + classMapping.getDeobfName() + "/" + fieldMapping.getDeobfName()); - } - - for (MethodMapping methodMapping : sorted(classMapping.methods())) { - methodMappings.add("MD: " + classMapping.getObfFullName() + "/" + methodMapping.getObfName() + " " + methodMapping.getObfDesc() + " " + classMapping.getDeobfName() + "/" + methodMapping.getDeobfName() + " " + mappings.getTranslator(TranslationDirection.DEOBFUSCATING, index).getTranslatedMethodDesc(methodMapping.getObfDesc())); - } - } - for (String fd : fieldMappings) { - writer.write(fd); - writer.write(System.lineSeparator()); - } - - for (String md : methodMappings) { - writer.write(md); - writer.write(System.lineSeparator()); - } - - writer.close(); - } - - private > List sorted(Iterable classes) { - List out = new ArrayList<>(); - for (T t : classes) { - out.add(t); - } - Collections.sort(out); - return out; - } -} -- cgit v1.2.3