diff options
| author | 2015-03-09 12:53:11 -0400 | |
|---|---|---|
| committer | 2015-03-09 12:53:11 -0400 | |
| commit | d6b2a223a7973941e5e4fb45c8ceec4885891496 (patch) | |
| tree | 5728ab513d0b4ed85a720da7eb48c6591dd3f8b0 /src/cuchaz/enigma/convert | |
| parent | add tracking for mismatched fields/methods (diff) | |
| download | enigma-fork-d6b2a223a7973941e5e4fb45c8ceec4885891496.tar.gz enigma-fork-d6b2a223a7973941e5e4fb45c8ceec4885891496.tar.xz enigma-fork-d6b2a223a7973941e5e4fb45c8ceec4885891496.zip | |
starting on field matching gui
Diffstat (limited to 'src/cuchaz/enigma/convert')
| -rw-r--r-- | src/cuchaz/enigma/convert/ClassMatches.java (renamed from src/cuchaz/enigma/convert/Matches.java) | 6 | ||||
| -rw-r--r-- | src/cuchaz/enigma/convert/FieldMatches.java | 35 | ||||
| -rw-r--r-- | src/cuchaz/enigma/convert/MappingsConverter.java | 8 | ||||
| -rw-r--r-- | src/cuchaz/enigma/convert/MatchesReader.java | 8 | ||||
| -rw-r--r-- | src/cuchaz/enigma/convert/MatchesWriter.java | 6 |
5 files changed, 49 insertions, 14 deletions
diff --git a/src/cuchaz/enigma/convert/Matches.java b/src/cuchaz/enigma/convert/ClassMatches.java index 19bb155..f8b2afd 100644 --- a/src/cuchaz/enigma/convert/Matches.java +++ b/src/cuchaz/enigma/convert/ClassMatches.java | |||
| @@ -14,7 +14,7 @@ import com.google.common.collect.Sets; | |||
| 14 | import cuchaz.enigma.mapping.ClassEntry; | 14 | import cuchaz.enigma.mapping.ClassEntry; |
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | public class Matches implements Iterable<ClassMatch> { | 17 | public class ClassMatches implements Iterable<ClassMatch> { |
| 18 | 18 | ||
| 19 | Collection<ClassMatch> m_matches; | 19 | Collection<ClassMatch> m_matches; |
| 20 | Map<ClassEntry,ClassMatch> m_matchesBySource; | 20 | Map<ClassEntry,ClassMatch> m_matchesBySource; |
| @@ -25,11 +25,11 @@ public class Matches implements Iterable<ClassMatch> { | |||
| 25 | Set<ClassEntry> m_unmatchedSourceClasses; | 25 | Set<ClassEntry> m_unmatchedSourceClasses; |
| 26 | Set<ClassEntry> m_unmatchedDestClasses; | 26 | Set<ClassEntry> m_unmatchedDestClasses; |
| 27 | 27 | ||
| 28 | public Matches() { | 28 | public ClassMatches() { |
| 29 | this(new ArrayList<ClassMatch>()); | 29 | this(new ArrayList<ClassMatch>()); |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | public Matches(Collection<ClassMatch> matches) { | 32 | public ClassMatches(Collection<ClassMatch> matches) { |
| 33 | m_matches = matches; | 33 | m_matches = matches; |
| 34 | m_matchesBySource = Maps.newHashMap(); | 34 | m_matchesBySource = Maps.newHashMap(); |
| 35 | m_matchesByDest = Maps.newHashMap(); | 35 | m_matchesByDest = Maps.newHashMap(); |
diff --git a/src/cuchaz/enigma/convert/FieldMatches.java b/src/cuchaz/enigma/convert/FieldMatches.java new file mode 100644 index 0000000..f78a8f5 --- /dev/null +++ b/src/cuchaz/enigma/convert/FieldMatches.java | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | package cuchaz.enigma.convert; | ||
| 2 | |||
| 3 | import java.util.Collection; | ||
| 4 | import java.util.Set; | ||
| 5 | |||
| 6 | import com.google.common.collect.BiMap; | ||
| 7 | import com.google.common.collect.HashBiMap; | ||
| 8 | import com.google.common.collect.Sets; | ||
| 9 | |||
| 10 | import cuchaz.enigma.mapping.ClassEntry; | ||
| 11 | import cuchaz.enigma.mapping.FieldEntry; | ||
| 12 | |||
| 13 | |||
| 14 | public class FieldMatches { | ||
| 15 | |||
| 16 | private BiMap<FieldEntry,FieldEntry> m_matches; | ||
| 17 | private Set<FieldEntry> m_unmatchedSourceFields; | ||
| 18 | |||
| 19 | public FieldMatches() { | ||
| 20 | m_matches = HashBiMap.create(); | ||
| 21 | m_unmatchedSourceFields = Sets.newHashSet(); | ||
| 22 | } | ||
| 23 | |||
| 24 | public void addUnmatchedSourceFields(Set<FieldEntry> fieldEntries) { | ||
| 25 | m_unmatchedSourceFields.addAll(fieldEntries); | ||
| 26 | } | ||
| 27 | |||
| 28 | public Collection<ClassEntry> getSourceClassesWithUnmatchedFields() { | ||
| 29 | Set<ClassEntry> classEntries = Sets.newHashSet(); | ||
| 30 | for (FieldEntry fieldEntry : m_unmatchedSourceFields) { | ||
| 31 | classEntries.add(fieldEntry.getClassEntry()); | ||
| 32 | } | ||
| 33 | return classEntries; | ||
| 34 | } | ||
| 35 | } | ||
diff --git a/src/cuchaz/enigma/convert/MappingsConverter.java b/src/cuchaz/enigma/convert/MappingsConverter.java index 5883878..667ee9d 100644 --- a/src/cuchaz/enigma/convert/MappingsConverter.java +++ b/src/cuchaz/enigma/convert/MappingsConverter.java | |||
| @@ -37,7 +37,7 @@ import cuchaz.enigma.mapping.MethodMapping; | |||
| 37 | 37 | ||
| 38 | public class MappingsConverter { | 38 | public class MappingsConverter { |
| 39 | 39 | ||
| 40 | public static Matches computeMatches(JarFile sourceJar, JarFile destJar, Mappings mappings) { | 40 | public static ClassMatches computeMatches(JarFile sourceJar, JarFile destJar, Mappings mappings) { |
| 41 | 41 | ||
| 42 | // index jars | 42 | // index jars |
| 43 | System.out.println("Indexing source jar..."); | 43 | System.out.println("Indexing source jar..."); |
| @@ -49,7 +49,7 @@ public class MappingsConverter { | |||
| 49 | 49 | ||
| 50 | // compute the matching | 50 | // compute the matching |
| 51 | ClassMatching matching = computeMatching(sourceJar, sourceIndex, destJar, destIndex, null); | 51 | ClassMatching matching = computeMatching(sourceJar, sourceIndex, destJar, destIndex, null); |
| 52 | return new Matches(matching.matches()); | 52 | return new ClassMatches(matching.matches()); |
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | public static ClassMatching computeMatching(JarFile sourceJar, JarIndex sourceIndex, JarFile destJar, JarIndex destIndex, BiMap<ClassEntry,ClassEntry> knownMatches) { | 55 | public static ClassMatching computeMatching(JarFile sourceJar, JarIndex sourceIndex, JarFile destJar, JarIndex destIndex, BiMap<ClassEntry,ClassEntry> knownMatches) { |
| @@ -115,7 +115,7 @@ public class MappingsConverter { | |||
| 115 | return lastMatching; | 115 | return lastMatching; |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | public static Mappings newMappings(Matches matches, Mappings oldMappings, Deobfuscator sourceDeobfuscator, Deobfuscator destDeobfuscator) { | 118 | public static Mappings newMappings(ClassMatches matches, Mappings oldMappings, Deobfuscator sourceDeobfuscator, Deobfuscator destDeobfuscator) { |
| 119 | 119 | ||
| 120 | // sort the unique matches by size of inner class chain | 120 | // sort the unique matches by size of inner class chain |
| 121 | Multimap<Integer,Entry<ClassEntry,ClassEntry>> matchesByDestChainSize = HashMultimap.create(); | 121 | Multimap<Integer,Entry<ClassEntry,ClassEntry>> matchesByDestChainSize = HashMultimap.create(); |
| @@ -172,7 +172,7 @@ public class MappingsConverter { | |||
| 172 | return newMappings; | 172 | return newMappings; |
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | private static ClassMapping migrateClassMapping(ClassEntry newObfClass, ClassMapping mapping, final Matches matches, boolean useSimpleName) { | 175 | private static ClassMapping migrateClassMapping(ClassEntry newObfClass, ClassMapping mapping, final ClassMatches matches, boolean useSimpleName) { |
| 176 | 176 | ||
| 177 | ClassNameReplacer replacer = new ClassNameReplacer() { | 177 | ClassNameReplacer replacer = new ClassNameReplacer() { |
| 178 | @Override | 178 | @Override |
diff --git a/src/cuchaz/enigma/convert/MatchesReader.java b/src/cuchaz/enigma/convert/MatchesReader.java index 808f8d0..b43535c 100644 --- a/src/cuchaz/enigma/convert/MatchesReader.java +++ b/src/cuchaz/enigma/convert/MatchesReader.java | |||
| @@ -14,19 +14,19 @@ import cuchaz.enigma.mapping.ClassEntry; | |||
| 14 | 14 | ||
| 15 | public class MatchesReader { | 15 | public class MatchesReader { |
| 16 | 16 | ||
| 17 | public static Matches read(File file) | 17 | public static ClassMatches readClasses(File file) |
| 18 | throws IOException { | 18 | throws IOException { |
| 19 | try (BufferedReader in = new BufferedReader(new FileReader(file))) { | 19 | try (BufferedReader in = new BufferedReader(new FileReader(file))) { |
| 20 | Matches matches = new Matches(); | 20 | ClassMatches matches = new ClassMatches(); |
| 21 | String line = null; | 21 | String line = null; |
| 22 | while ((line = in.readLine()) != null) { | 22 | while ((line = in.readLine()) != null) { |
| 23 | matches.add(readMatch(line)); | 23 | matches.add(readClassMatch(line)); |
| 24 | } | 24 | } |
| 25 | return matches; | 25 | return matches; |
| 26 | } | 26 | } |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | private static ClassMatch readMatch(String line) | 29 | private static ClassMatch readClassMatch(String line) |
| 30 | throws IOException { | 30 | throws IOException { |
| 31 | String[] sides = line.split(":", 2); | 31 | String[] sides = line.split(":", 2); |
| 32 | return new ClassMatch(readClasses(sides[0]), readClasses(sides[1])); | 32 | return new ClassMatch(readClasses(sides[0]), readClasses(sides[1])); |
diff --git a/src/cuchaz/enigma/convert/MatchesWriter.java b/src/cuchaz/enigma/convert/MatchesWriter.java index 49ffb6d..6658e2a 100644 --- a/src/cuchaz/enigma/convert/MatchesWriter.java +++ b/src/cuchaz/enigma/convert/MatchesWriter.java | |||
| @@ -9,16 +9,16 @@ import cuchaz.enigma.mapping.ClassEntry; | |||
| 9 | 9 | ||
| 10 | public class MatchesWriter { | 10 | public class MatchesWriter { |
| 11 | 11 | ||
| 12 | public static void write(Matches matches, File file) | 12 | public static void writeClasses(ClassMatches matches, File file) |
| 13 | throws IOException { | 13 | throws IOException { |
| 14 | try (FileWriter out = new FileWriter(file)) { | 14 | try (FileWriter out = new FileWriter(file)) { |
| 15 | for (ClassMatch match : matches) { | 15 | for (ClassMatch match : matches) { |
| 16 | writeMatch(out, match); | 16 | writeClassMatch(out, match); |
| 17 | } | 17 | } |
| 18 | } | 18 | } |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | private static void writeMatch(FileWriter out, ClassMatch match) | 21 | private static void writeClassMatch(FileWriter out, ClassMatch match) |
| 22 | throws IOException { | 22 | throws IOException { |
| 23 | writeClasses(out, match.sourceClasses); | 23 | writeClasses(out, match.sourceClasses); |
| 24 | out.write(":"); | 24 | out.write(":"); |