diff options
| author | 2016-09-06 12:11:50 +0200 | |
|---|---|---|
| committer | 2016-09-06 12:11:50 +0200 | |
| commit | e0e3141619cecd54c087d964654e6c35511c48f9 (patch) | |
| tree | 9d7750f6abe26b4ca08cc9ffb516222569ebfd0b /src/main/java/cuchaz | |
| parent | Avoid Engima converter detecting <init> and <clinit> as matchable token (diff) | |
| download | enigma-e0e3141619cecd54c087d964654e6c35511c48f9.tar.gz enigma-e0e3141619cecd54c087d964654e6c35511c48f9.tar.xz enigma-e0e3141619cecd54c087d964654e6c35511c48f9.zip | |
A little bit of clean up
Diffstat (limited to 'src/main/java/cuchaz')
20 files changed, 61 insertions, 212 deletions
diff --git a/src/main/java/cuchaz/enigma/Main.java b/src/main/java/cuchaz/enigma/Main.java index a1007cfe..14c9fc62 100644 --- a/src/main/java/cuchaz/enigma/Main.java +++ b/src/main/java/cuchaz/enigma/Main.java | |||
| @@ -16,7 +16,6 @@ import java.util.jar.JarFile; | |||
| 16 | import javax.swing.UIManager; | 16 | import javax.swing.UIManager; |
| 17 | 17 | ||
| 18 | import cuchaz.enigma.gui.Gui; | 18 | import cuchaz.enigma.gui.Gui; |
| 19 | import cuchaz.enigma.mapping.ClassEntry; | ||
| 20 | 19 | ||
| 21 | public class Main { | 20 | public class Main { |
| 22 | 21 | ||
diff --git a/src/main/java/cuchaz/enigma/Util.java b/src/main/java/cuchaz/enigma/Util.java deleted file mode 100644 index 1bcdb9ea..00000000 --- a/src/main/java/cuchaz/enigma/Util.java +++ /dev/null | |||
| @@ -1,99 +0,0 @@ | |||
| 1 | /******************************************************************************* | ||
| 2 | * Copyright (c) 2015 Jeff Martin. | ||
| 3 | * All rights reserved. This program and the accompanying materials | ||
| 4 | * are made available under the terms of the GNU Lesser General Public | ||
| 5 | * License v3.0 which accompanies this distribution, and is available at | ||
| 6 | * http://www.gnu.org/licenses/lgpl.html | ||
| 7 | * <p> | ||
| 8 | * Contributors: | ||
| 9 | * Jeff Martin - initial API and implementation | ||
| 10 | ******************************************************************************/ | ||
| 11 | package cuchaz.enigma; | ||
| 12 | |||
| 13 | import com.google.common.io.CharStreams; | ||
| 14 | |||
| 15 | import java.awt.Desktop; | ||
| 16 | import java.io.*; | ||
| 17 | import java.net.URI; | ||
| 18 | import java.net.URISyntaxException; | ||
| 19 | import java.util.Arrays; | ||
| 20 | import java.util.jar.JarFile; | ||
| 21 | |||
| 22 | import javassist.CannotCompileException; | ||
| 23 | import javassist.CtClass; | ||
| 24 | import javassist.bytecode.Descriptor; | ||
| 25 | |||
| 26 | public class Util { | ||
| 27 | |||
| 28 | public static int combineHashesOrdered(Object... objs) { | ||
| 29 | return combineHashesOrdered(Arrays.asList(objs)); | ||
| 30 | } | ||
| 31 | |||
| 32 | public static int combineHashesOrdered(Iterable<Object> objs) { | ||
| 33 | final int prime = 67; | ||
| 34 | int result = 1; | ||
| 35 | for (Object obj : objs) { | ||
| 36 | result *= prime; | ||
| 37 | if (obj != null) { | ||
| 38 | result += obj.hashCode(); | ||
| 39 | } | ||
| 40 | } | ||
| 41 | return result; | ||
| 42 | } | ||
| 43 | |||
| 44 | public static void closeQuietly(Closeable closeable) { | ||
| 45 | if (closeable != null) { | ||
| 46 | try { | ||
| 47 | closeable.close(); | ||
| 48 | } catch (IOException ex) { | ||
| 49 | // just ignore any further exceptions | ||
| 50 | } | ||
| 51 | } | ||
| 52 | } | ||
| 53 | |||
| 54 | public static void closeQuietly(JarFile jarFile) { | ||
| 55 | // silly library should implement Closeable... | ||
| 56 | if (jarFile != null) { | ||
| 57 | try { | ||
| 58 | jarFile.close(); | ||
| 59 | } catch (IOException ex) { | ||
| 60 | // just ignore any further exceptions | ||
| 61 | } | ||
| 62 | } | ||
| 63 | } | ||
| 64 | |||
| 65 | public static String readStreamToString(InputStream in) throws IOException { | ||
| 66 | return CharStreams.toString(new InputStreamReader(in, "UTF-8")); | ||
| 67 | } | ||
| 68 | |||
| 69 | public static String readResourceToString(String path) throws IOException { | ||
| 70 | InputStream in = Util.class.getResourceAsStream(path); | ||
| 71 | if (in == null) { | ||
| 72 | throw new IllegalArgumentException("Resource not found! " + path); | ||
| 73 | } | ||
| 74 | return readStreamToString(in); | ||
| 75 | } | ||
| 76 | |||
| 77 | public static void openUrl(String url) { | ||
| 78 | if (Desktop.isDesktopSupported()) { | ||
| 79 | Desktop desktop = Desktop.getDesktop(); | ||
| 80 | try { | ||
| 81 | desktop.browse(new URI(url)); | ||
| 82 | } catch (IOException ex) { | ||
| 83 | throw new Error(ex); | ||
| 84 | } catch (URISyntaxException ex) { | ||
| 85 | throw new IllegalArgumentException(ex); | ||
| 86 | } | ||
| 87 | } | ||
| 88 | } | ||
| 89 | |||
| 90 | public static void writeClass(CtClass c) { | ||
| 91 | String name = Descriptor.toJavaName(c.getName()); | ||
| 92 | File file = new File(name + ".class"); | ||
| 93 | try (FileOutputStream out = new FileOutputStream(file)) { | ||
| 94 | out.write(c.toBytecode()); | ||
| 95 | } catch (IOException | CannotCompileException ex) { | ||
| 96 | throw new Error(ex); | ||
| 97 | } | ||
| 98 | } | ||
| 99 | } | ||
diff --git a/src/main/java/cuchaz/enigma/analysis/JarIndex.java b/src/main/java/cuchaz/enigma/analysis/JarIndex.java index b274a7d3..851f3faa 100644 --- a/src/main/java/cuchaz/enigma/analysis/JarIndex.java +++ b/src/main/java/cuchaz/enigma/analysis/JarIndex.java | |||
| @@ -123,10 +123,10 @@ public class JarIndex { | |||
| 123 | 123 | ||
| 124 | // DEBUG | 124 | // DEBUG |
| 125 | //System.out.println("ANONYMOUS: " + outerClassEntry.getName() + "$" + innerClassEntry.getSimpleName()); | 125 | //System.out.println("ANONYMOUS: " + outerClassEntry.getName() + "$" + innerClassEntry.getSimpleName()); |
| 126 | } else { | 126 | }/* else { |
| 127 | // DEBUG | 127 | // DEBUG |
| 128 | //System.out.println("INNER: " + outerClassEntry.getName() + "$" + innerClassEntry.getSimpleName()); | 128 | //System.out.println("INNER: " + outerClassEntry.getName() + "$" + innerClassEntry.getSimpleName()); |
| 129 | } | 129 | }*/ |
| 130 | } | 130 | } |
| 131 | } | 131 | } |
| 132 | 132 | ||
diff --git a/src/main/java/cuchaz/enigma/bytecode/ClassRenamer.java b/src/main/java/cuchaz/enigma/bytecode/ClassRenamer.java index c13aae4a..eb7e9a17 100644 --- a/src/main/java/cuchaz/enigma/bytecode/ClassRenamer.java +++ b/src/main/java/cuchaz/enigma/bytecode/ClassRenamer.java | |||
| @@ -278,9 +278,8 @@ public class ClassRenamer { | |||
| 278 | } | 278 | } |
| 279 | } | 279 | } |
| 280 | 280 | ||
| 281 | private static ClassSignature renameType(ClassSignature type, ReplacerClassMap map) { | 281 | private static TypeParameter[] renameTypeParameter(TypeParameter[] typeParamTypes, ReplacerClassMap map) |
| 282 | 282 | { | |
| 283 | TypeParameter[] typeParamTypes = type.getParameters(); | ||
| 284 | if (typeParamTypes != null) { | 283 | if (typeParamTypes != null) { |
| 285 | typeParamTypes = Arrays.copyOf(typeParamTypes, typeParamTypes.length); | 284 | typeParamTypes = Arrays.copyOf(typeParamTypes, typeParamTypes.length); |
| 286 | for (int i = 0; i < typeParamTypes.length; i++) { | 285 | for (int i = 0; i < typeParamTypes.length; i++) { |
| @@ -290,6 +289,12 @@ public class ClassRenamer { | |||
| 290 | } | 289 | } |
| 291 | } | 290 | } |
| 292 | } | 291 | } |
| 292 | return typeParamTypes; | ||
| 293 | } | ||
| 294 | |||
| 295 | private static ClassSignature renameType(ClassSignature type, ReplacerClassMap map) { | ||
| 296 | |||
| 297 | TypeParameter[] typeParamTypes = renameTypeParameter(type.getParameters(), map); | ||
| 293 | 298 | ||
| 294 | ClassType superclassType = type.getSuperClass(); | 299 | ClassType superclassType = type.getSuperClass(); |
| 295 | if (superclassType != ClassType.OBJECT) { | 300 | if (superclassType != ClassType.OBJECT) { |
| @@ -315,16 +320,7 @@ public class ClassRenamer { | |||
| 315 | 320 | ||
| 316 | private static MethodSignature renameType(MethodSignature type, ReplacerClassMap map) { | 321 | private static MethodSignature renameType(MethodSignature type, ReplacerClassMap map) { |
| 317 | 322 | ||
| 318 | TypeParameter[] typeParamTypes = type.getTypeParameters(); | 323 | TypeParameter[] typeParamTypes = renameTypeParameter(type.getTypeParameters(), map); |
| 319 | if (typeParamTypes != null) { | ||
| 320 | typeParamTypes = Arrays.copyOf(typeParamTypes, typeParamTypes.length); | ||
| 321 | for (int i = 0; i < typeParamTypes.length; i++) { | ||
| 322 | TypeParameter newParamType = renameType(typeParamTypes[i], map); | ||
| 323 | if (newParamType != null) { | ||
| 324 | typeParamTypes[i] = newParamType; | ||
| 325 | } | ||
| 326 | } | ||
| 327 | } | ||
| 328 | 324 | ||
| 329 | Type[] paramTypes = type.getParameterTypes(); | 325 | Type[] paramTypes = type.getParameterTypes(); |
| 330 | if (paramTypes != null) { | 326 | if (paramTypes != null) { |
diff --git a/src/main/java/cuchaz/enigma/bytecode/accessors/ConstInfoAccessor.java b/src/main/java/cuchaz/enigma/bytecode/accessors/ConstInfoAccessor.java index bc7af870..aa363d2a 100644 --- a/src/main/java/cuchaz/enigma/bytecode/accessors/ConstInfoAccessor.java +++ b/src/main/java/cuchaz/enigma/bytecode/accessors/ConstInfoAccessor.java | |||
| @@ -14,7 +14,6 @@ import java.io.ByteArrayInputStream; | |||
| 14 | import java.io.ByteArrayOutputStream; | 14 | import java.io.ByteArrayOutputStream; |
| 15 | import java.io.DataInputStream; | 15 | import java.io.DataInputStream; |
| 16 | import java.io.DataOutputStream; | 16 | import java.io.DataOutputStream; |
| 17 | import java.io.FileOutputStream; | ||
| 18 | import java.io.IOException; | 17 | import java.io.IOException; |
| 19 | import java.io.OutputStreamWriter; | 18 | import java.io.OutputStreamWriter; |
| 20 | import java.io.PrintWriter; | 19 | import java.io.PrintWriter; |
diff --git a/src/main/java/cuchaz/enigma/convert/ClassIdentifier.java b/src/main/java/cuchaz/enigma/convert/ClassIdentifier.java index f5454377..557e6083 100644 --- a/src/main/java/cuchaz/enigma/convert/ClassIdentifier.java +++ b/src/main/java/cuchaz/enigma/convert/ClassIdentifier.java | |||
| @@ -19,7 +19,6 @@ import cuchaz.enigma.TranslatingTypeLoader; | |||
| 19 | import cuchaz.enigma.analysis.JarIndex; | 19 | import cuchaz.enigma.analysis.JarIndex; |
| 20 | import cuchaz.enigma.convert.ClassNamer.SidedClassNamer; | 20 | import cuchaz.enigma.convert.ClassNamer.SidedClassNamer; |
| 21 | import cuchaz.enigma.mapping.ClassEntry; | 21 | import cuchaz.enigma.mapping.ClassEntry; |
| 22 | import cuchaz.enigma.mapping.TranslationDirection; | ||
| 23 | import cuchaz.enigma.mapping.Translator; | 22 | import cuchaz.enigma.mapping.Translator; |
| 24 | import javassist.CtClass; | 23 | import javassist.CtClass; |
| 25 | 24 | ||
diff --git a/src/main/java/cuchaz/enigma/convert/ClassIdentity.java b/src/main/java/cuchaz/enigma/convert/ClassIdentity.java index 606c1df1..57cbc06a 100644 --- a/src/main/java/cuchaz/enigma/convert/ClassIdentity.java +++ b/src/main/java/cuchaz/enigma/convert/ClassIdentity.java | |||
| @@ -21,7 +21,6 @@ import java.util.Map; | |||
| 21 | import java.util.Set; | 21 | import java.util.Set; |
| 22 | 22 | ||
| 23 | import cuchaz.enigma.Constants; | 23 | import cuchaz.enigma.Constants; |
| 24 | import cuchaz.enigma.Util; | ||
| 25 | import cuchaz.enigma.analysis.ClassImplementationsTreeNode; | 24 | import cuchaz.enigma.analysis.ClassImplementationsTreeNode; |
| 26 | import cuchaz.enigma.analysis.EntryReference; | 25 | import cuchaz.enigma.analysis.EntryReference; |
| 27 | import cuchaz.enigma.analysis.JarIndex; | 26 | import cuchaz.enigma.analysis.JarIndex; |
| @@ -30,6 +29,7 @@ import cuchaz.enigma.bytecode.InfoType; | |||
| 30 | import cuchaz.enigma.bytecode.accessors.ConstInfoAccessor; | 29 | import cuchaz.enigma.bytecode.accessors.ConstInfoAccessor; |
| 31 | import cuchaz.enigma.convert.ClassNamer.SidedClassNamer; | 30 | import cuchaz.enigma.convert.ClassNamer.SidedClassNamer; |
| 32 | import cuchaz.enigma.mapping.*; | 31 | import cuchaz.enigma.mapping.*; |
| 32 | import cuchaz.enigma.utils.Utils; | ||
| 33 | import javassist.*; | 33 | import javassist.*; |
| 34 | import javassist.bytecode.*; | 34 | import javassist.bytecode.*; |
| 35 | import javassist.expr.*; | 35 | import javassist.expr.*; |
| @@ -386,7 +386,7 @@ public class ClassIdentity { | |||
| 386 | objs.addAll(this.implementz); | 386 | objs.addAll(this.implementz); |
| 387 | objs.addAll(this.implementations); | 387 | objs.addAll(this.implementations); |
| 388 | objs.addAll(this.references); | 388 | objs.addAll(this.references); |
| 389 | return Util.combineHashesOrdered(objs); | 389 | return Utils.combineHashesOrdered(objs); |
| 390 | } | 390 | } |
| 391 | 391 | ||
| 392 | public int getMatchScore(ClassIdentity other) { | 392 | public int getMatchScore(ClassIdentity other) { |
diff --git a/src/main/java/cuchaz/enigma/convert/ClassMatch.java b/src/main/java/cuchaz/enigma/convert/ClassMatch.java index 422529ec..9fa35f03 100644 --- a/src/main/java/cuchaz/enigma/convert/ClassMatch.java +++ b/src/main/java/cuchaz/enigma/convert/ClassMatch.java | |||
| @@ -15,9 +15,8 @@ import com.google.common.collect.Sets; | |||
| 15 | import java.util.Collection; | 15 | import java.util.Collection; |
| 16 | import java.util.Set; | 16 | import java.util.Set; |
| 17 | 17 | ||
| 18 | import cuchaz.enigma.Util; | ||
| 19 | import cuchaz.enigma.mapping.ClassEntry; | 18 | import cuchaz.enigma.mapping.ClassEntry; |
| 20 | 19 | import cuchaz.enigma.utils.Utils; | |
| 21 | 20 | ||
| 22 | public class ClassMatch { | 21 | public class ClassMatch { |
| 23 | 22 | ||
| @@ -70,7 +69,7 @@ public class ClassMatch { | |||
| 70 | 69 | ||
| 71 | @Override | 70 | @Override |
| 72 | public int hashCode() { | 71 | public int hashCode() { |
| 73 | return Util.combineHashesOrdered(sourceClasses, destClasses); | 72 | return Utils.combineHashesOrdered(sourceClasses, destClasses); |
| 74 | } | 73 | } |
| 75 | 74 | ||
| 76 | @Override | 75 | @Override |
diff --git a/src/main/java/cuchaz/enigma/convert/ClassMatching.java b/src/main/java/cuchaz/enigma/convert/ClassMatching.java index 9350ea7f..af9ae015 100644 --- a/src/main/java/cuchaz/enigma/convert/ClassMatching.java +++ b/src/main/java/cuchaz/enigma/convert/ClassMatching.java | |||
| @@ -144,12 +144,11 @@ public class ClassMatching { | |||
| 144 | numAmbiguousDest += match.destClasses.size(); | 144 | numAmbiguousDest += match.destClasses.size(); |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | StringBuilder buf = new StringBuilder(); | 147 | String buf = String.format("%20s%8s%8s\n", "", "Source", "Dest") + String |
| 148 | buf.append(String.format("%20s%8s%8s\n", "", "Source", "Dest")); | 148 | .format("%20s%8d%8d\n", "Classes", sourceClasses().size(), destClasses().size()) + String |
| 149 | buf.append(String.format("%20s%8d%8d\n", "Classes", sourceClasses().size(), destClasses().size())); | 149 | .format("%20s%8d%8d\n", "Uniquely matched", uniqueMatches().size(), uniqueMatches().size()) + String |
| 150 | buf.append(String.format("%20s%8d%8d\n", "Uniquely matched", uniqueMatches().size(), uniqueMatches().size())); | 150 | .format("%20s%8d%8d\n", "Ambiguously matched", numAmbiguousSource, numAmbiguousDest) + String |
| 151 | buf.append(String.format("%20s%8d%8d\n", "Ambiguously matched", numAmbiguousSource, numAmbiguousDest)); | 151 | .format("%20s%8d%8d\n", "Unmatched", unmatchedSourceClasses().size(), unmatchedDestClasses().size()); |
| 152 | buf.append(String.format("%20s%8d%8d\n", "Unmatched", unmatchedSourceClasses().size(), unmatchedDestClasses().size())); | 152 | return buf; |
| 153 | return buf.toString(); | ||
| 154 | } | 153 | } |
| 155 | } | 154 | } |
diff --git a/src/main/java/cuchaz/enigma/convert/MappingsConverter.java b/src/main/java/cuchaz/enigma/convert/MappingsConverter.java index abb1bea0..a80d9ce1 100644 --- a/src/main/java/cuchaz/enigma/convert/MappingsConverter.java +++ b/src/main/java/cuchaz/enigma/convert/MappingsConverter.java | |||
| @@ -11,10 +11,6 @@ | |||
| 11 | package cuchaz.enigma.convert; | 11 | package cuchaz.enigma.convert; |
| 12 | 12 | ||
| 13 | import com.google.common.collect.*; | 13 | import com.google.common.collect.*; |
| 14 | |||
| 15 | import java.util.*; | ||
| 16 | import java.util.jar.JarFile; | ||
| 17 | |||
| 18 | import cuchaz.enigma.Constants; | 14 | import cuchaz.enigma.Constants; |
| 19 | import cuchaz.enigma.Deobfuscator; | 15 | import cuchaz.enigma.Deobfuscator; |
| 20 | import cuchaz.enigma.analysis.JarIndex; | 16 | import cuchaz.enigma.analysis.JarIndex; |
| @@ -22,6 +18,9 @@ import cuchaz.enigma.convert.ClassNamer.SidedClassNamer; | |||
| 22 | import cuchaz.enigma.mapping.*; | 18 | import cuchaz.enigma.mapping.*; |
| 23 | import cuchaz.enigma.throwables.MappingConflict; | 19 | import cuchaz.enigma.throwables.MappingConflict; |
| 24 | 20 | ||
| 21 | import java.util.*; | ||
| 22 | import java.util.jar.JarFile; | ||
| 23 | |||
| 25 | public class MappingsConverter { | 24 | public class MappingsConverter { |
| 26 | 25 | ||
| 27 | public static ClassMatches computeClassMatches(JarFile sourceJar, JarFile destJar, Mappings mappings) { | 26 | public static ClassMatches computeClassMatches(JarFile sourceJar, JarFile destJar, Mappings mappings) { |
| @@ -365,14 +364,12 @@ public class MappingsConverter { | |||
| 365 | public Set<BehaviorEntry> filterEntries(Collection<BehaviorEntry> obfDestFields, BehaviorEntry obfSourceField, ClassMatches classMatches) { | 364 | public Set<BehaviorEntry> filterEntries(Collection<BehaviorEntry> obfDestFields, BehaviorEntry obfSourceField, ClassMatches classMatches) { |
| 366 | Set<BehaviorEntry> out = Sets.newHashSet(); | 365 | Set<BehaviorEntry> out = Sets.newHashSet(); |
| 367 | for (BehaviorEntry obfDestField : obfDestFields) { | 366 | for (BehaviorEntry obfDestField : obfDestFields) { |
| 368 | Signature translatedDestSignature = translate(obfDestField.getSignature(), classMatches.getUniqueMatches().inverse()); | 367 | Signature translatedDestSignature = translate(obfDestField.getSignature(), |
| 369 | if (translatedDestSignature == null && obfSourceField.getSignature() == null) { | 368 | classMatches.getUniqueMatches().inverse()); |
| 369 | if ((translatedDestSignature == null && obfSourceField.getSignature() == null) | ||
| 370 | || translatedDestSignature != null && obfSourceField.getSignature() != null | ||
| 371 | && translatedDestSignature.equals(obfSourceField.getSignature())) | ||
| 370 | out.add(obfDestField); | 372 | out.add(obfDestField); |
| 371 | } else if (translatedDestSignature == null || obfSourceField.getSignature() == null) { | ||
| 372 | // skip it | ||
| 373 | } else if (translatedDestSignature.equals(obfSourceField.getSignature())) { | ||
| 374 | out.add(obfDestField); | ||
| 375 | } | ||
| 376 | } | 373 | } |
| 377 | return out; | 374 | return out; |
| 378 | } | 375 | } |
diff --git a/src/main/java/cuchaz/enigma/convert/MatchesReader.java b/src/main/java/cuchaz/enigma/convert/MatchesReader.java index 773566df..ee5e4828 100644 --- a/src/main/java/cuchaz/enigma/convert/MatchesReader.java +++ b/src/main/java/cuchaz/enigma/convert/MatchesReader.java | |||
| @@ -28,7 +28,7 @@ public class MatchesReader { | |||
| 28 | throws IOException { | 28 | throws IOException { |
| 29 | try (BufferedReader in = new BufferedReader(new FileReader(file))) { | 29 | try (BufferedReader in = new BufferedReader(new FileReader(file))) { |
| 30 | ClassMatches matches = new ClassMatches(); | 30 | ClassMatches matches = new ClassMatches(); |
| 31 | String line = null; | 31 | String line; |
| 32 | while ((line = in.readLine()) != null) { | 32 | while ((line = in.readLine()) != null) { |
| 33 | matches.add(readClassMatch(line)); | 33 | matches.add(readClassMatch(line)); |
| 34 | } | 34 | } |
| @@ -57,7 +57,7 @@ public class MatchesReader { | |||
| 57 | throws IOException { | 57 | throws IOException { |
| 58 | try (BufferedReader in = new BufferedReader(new FileReader(file))) { | 58 | try (BufferedReader in = new BufferedReader(new FileReader(file))) { |
| 59 | MemberMatches<T> matches = new MemberMatches<T>(); | 59 | MemberMatches<T> matches = new MemberMatches<T>(); |
| 60 | String line = null; | 60 | String line; |
| 61 | while ((line = in.readLine()) != null) { | 61 | while ((line = in.readLine()) != null) { |
| 62 | readMemberMatch(matches, line); | 62 | readMemberMatch(matches, line); |
| 63 | } | 63 | } |
diff --git a/src/main/java/cuchaz/enigma/gui/ClassSelector.java b/src/main/java/cuchaz/enigma/gui/ClassSelector.java index 98880cd6..92fcaba0 100644 --- a/src/main/java/cuchaz/enigma/gui/ClassSelector.java +++ b/src/main/java/cuchaz/enigma/gui/ClassSelector.java | |||
| @@ -22,8 +22,6 @@ import cuchaz.enigma.throwables.IllegalNameException; | |||
| 22 | import javax.swing.*; | 22 | import javax.swing.*; |
| 23 | import javax.swing.event.CellEditorListener; | 23 | import javax.swing.event.CellEditorListener; |
| 24 | import javax.swing.event.ChangeEvent; | 24 | import javax.swing.event.ChangeEvent; |
| 25 | import javax.swing.event.TreeModelEvent; | ||
| 26 | import javax.swing.event.TreeModelListener; | ||
| 27 | import javax.swing.tree.*; | 25 | import javax.swing.tree.*; |
| 28 | import java.awt.event.MouseAdapter; | 26 | import java.awt.event.MouseAdapter; |
| 29 | import java.awt.event.MouseEvent; | 27 | import java.awt.event.MouseEvent; |
| @@ -278,7 +276,7 @@ public class ClassSelector extends JTree { | |||
| 278 | TreePath path = tree.getPathForRow(i); | 276 | TreePath path = tree.getPathForRow(i); |
| 279 | if (i == row || isDescendant(path, rowPath)) { | 277 | if (i == row || isDescendant(path, rowPath)) { |
| 280 | if (tree.isExpanded(path)) { | 278 | if (tree.isExpanded(path)) { |
| 281 | buf.append("," + String.valueOf(i - row)); | 279 | buf.append(",").append(String.valueOf(i - row)); |
| 282 | } | 280 | } |
| 283 | } else { | 281 | } else { |
| 284 | break; | 282 | break; |
diff --git a/src/main/java/cuchaz/enigma/gui/Gui.java b/src/main/java/cuchaz/enigma/gui/Gui.java index 46d3b5cc..b5238596 100644 --- a/src/main/java/cuchaz/enigma/gui/Gui.java +++ b/src/main/java/cuchaz/enigma/gui/Gui.java | |||
| @@ -639,26 +639,21 @@ public class Gui { | |||
| 639 | 639 | ||
| 640 | m_implementationsTree.setModel(null); | 640 | m_implementationsTree.setModel(null); |
| 641 | 641 | ||
| 642 | if (m_reference.entry instanceof ClassEntry) { | 642 | DefaultMutableTreeNode node = null; |
| 643 | // get the class implementations | 643 | |
| 644 | ClassImplementationsTreeNode node = this.controller.getClassImplementations((ClassEntry) m_reference.entry); | 644 | // get the class implementations |
| 645 | if (node != null) { | 645 | if (m_reference.entry instanceof ClassEntry) |
| 646 | // show the tree at the root | 646 | node = this.controller.getClassImplementations((ClassEntry) m_reference.entry); |
| 647 | TreePath path = getPathToRoot(node); | 647 | else // get the method implementations |
| 648 | m_implementationsTree.setModel(new DefaultTreeModel((TreeNode) path.getPathComponent(0))); | 648 | if (m_reference.entry instanceof MethodEntry) |
| 649 | m_implementationsTree.expandPath(path); | 649 | node = this.controller.getMethodImplementations((MethodEntry) m_reference.entry); |
| 650 | m_implementationsTree.setSelectionRow(m_implementationsTree.getRowForPath(path)); | 650 | |
| 651 | } | 651 | if (node != null) { |
| 652 | } else if (m_reference.entry instanceof MethodEntry) { | 652 | // show the tree at the root |
| 653 | // get the method implementations | 653 | TreePath path = getPathToRoot(node); |
| 654 | MethodImplementationsTreeNode node = this.controller.getMethodImplementations((MethodEntry) m_reference.entry); | 654 | m_implementationsTree.setModel(new DefaultTreeModel((TreeNode) path.getPathComponent(0))); |
| 655 | if (node != null) { | 655 | m_implementationsTree.expandPath(path); |
| 656 | // show the tree at the root | 656 | m_implementationsTree.setSelectionRow(m_implementationsTree.getRowForPath(path)); |
| 657 | TreePath path = getPathToRoot(node); | ||
| 658 | m_implementationsTree.setModel(new DefaultTreeModel((TreeNode) path.getPathComponent(0))); | ||
| 659 | m_implementationsTree.expandPath(path); | ||
| 660 | m_implementationsTree.setSelectionRow(m_implementationsTree.getRowForPath(path)); | ||
| 661 | } | ||
| 662 | } | 657 | } |
| 663 | 658 | ||
| 664 | m_tabs.setSelectedIndex(1); | 659 | m_tabs.setSelectedIndex(1); |
diff --git a/src/main/java/cuchaz/enigma/gui/GuiTricks.java b/src/main/java/cuchaz/enigma/gui/GuiTricks.java index da2ec74f..85b65b0a 100644 --- a/src/main/java/cuchaz/enigma/gui/GuiTricks.java +++ b/src/main/java/cuchaz/enigma/gui/GuiTricks.java | |||
| @@ -10,16 +10,11 @@ | |||
| 10 | ******************************************************************************/ | 10 | ******************************************************************************/ |
| 11 | package cuchaz.enigma.gui; | 11 | package cuchaz.enigma.gui; |
| 12 | 12 | ||
| 13 | import java.awt.Font; | 13 | import javax.swing.*; |
| 14 | import java.awt.*; | ||
| 14 | import java.awt.event.ActionListener; | 15 | import java.awt.event.ActionListener; |
| 15 | import java.awt.event.MouseEvent; | ||
| 16 | import java.util.Arrays; | 16 | import java.util.Arrays; |
| 17 | 17 | ||
| 18 | import javax.swing.JButton; | ||
| 19 | import javax.swing.JComponent; | ||
| 20 | import javax.swing.JLabel; | ||
| 21 | import javax.swing.ToolTipManager; | ||
| 22 | |||
| 23 | public class GuiTricks { | 18 | public class GuiTricks { |
| 24 | 19 | ||
| 25 | public static JLabel unboldLabel(JLabel label) { | 20 | public static JLabel unboldLabel(JLabel label) { |
| @@ -28,15 +23,6 @@ public class GuiTricks { | |||
| 28 | return label; | 23 | return label; |
| 29 | } | 24 | } |
| 30 | 25 | ||
| 31 | public static void showToolTipNow(JComponent component) { | ||
| 32 | // HACKHACK: trick the tooltip manager into showing the tooltip right now | ||
| 33 | ToolTipManager manager = ToolTipManager.sharedInstance(); | ||
| 34 | int oldDelay = manager.getInitialDelay(); | ||
| 35 | manager.setInitialDelay(0); | ||
| 36 | manager.mouseMoved(new MouseEvent(component, MouseEvent.MOUSE_MOVED, System.currentTimeMillis(), 0, 0, 0, 0, false)); | ||
| 37 | manager.setInitialDelay(oldDelay); | ||
| 38 | } | ||
| 39 | |||
| 40 | public static void deactivateButton(JButton button) { | 26 | public static void deactivateButton(JButton button) { |
| 41 | button.setEnabled(false); | 27 | button.setEnabled(false); |
| 42 | button.setText(""); | 28 | button.setText(""); |
diff --git a/src/main/java/cuchaz/enigma/gui/MemberMatchingGui.java b/src/main/java/cuchaz/enigma/gui/MemberMatchingGui.java index 9e90dae4..4383465c 100644 --- a/src/main/java/cuchaz/enigma/gui/MemberMatchingGui.java +++ b/src/main/java/cuchaz/enigma/gui/MemberMatchingGui.java | |||
| @@ -287,23 +287,20 @@ public class MemberMatchingGui<T extends Entry> { | |||
| 287 | 287 | ||
| 288 | private void highlightEntries(CodeReader reader, Deobfuscator deobfuscator, Collection<T> obfMatchedEntries, Collection<T> obfUnmatchedEntries) { | 288 | private void highlightEntries(CodeReader reader, Deobfuscator deobfuscator, Collection<T> obfMatchedEntries, Collection<T> obfUnmatchedEntries) { |
| 289 | reader.clearHighlights(); | 289 | reader.clearHighlights(); |
| 290 | SourceIndex index = reader.getSourceIndex(); | ||
| 291 | |||
| 292 | // matched fields | 290 | // matched fields |
| 293 | for (T obfT : obfMatchedEntries) { | 291 | updateHighlighted(obfMatchedEntries, deobfuscator, reader, m_matchedHighlightPainter); |
| 294 | T deobfT = deobfuscator.deobfuscateEntry(obfT); | ||
| 295 | Token token = index.getDeclarationToken(deobfT); | ||
| 296 | if (token != null) { | ||
| 297 | reader.setHighlightedToken(token, m_matchedHighlightPainter); | ||
| 298 | } | ||
| 299 | } | ||
| 300 | |||
| 301 | // unmatched fields | 292 | // unmatched fields |
| 302 | for (T obfT : obfUnmatchedEntries) { | 293 | updateHighlighted(obfUnmatchedEntries, deobfuscator, reader, m_unmatchedHighlightPainter); |
| 294 | } | ||
| 295 | |||
| 296 | private void updateHighlighted(Collection<T> entries, Deobfuscator deobfuscator, CodeReader reader, HighlightPainter painter) | ||
| 297 | { | ||
| 298 | SourceIndex index = reader.getSourceIndex(); | ||
| 299 | for (T obfT : entries) { | ||
| 303 | T deobfT = deobfuscator.deobfuscateEntry(obfT); | 300 | T deobfT = deobfuscator.deobfuscateEntry(obfT); |
| 304 | Token token = index.getDeclarationToken(deobfT); | 301 | Token token = index.getDeclarationToken(deobfT); |
| 305 | if (token != null) { | 302 | if (token != null) { |
| 306 | reader.setHighlightedToken(token, m_unmatchedHighlightPainter); | 303 | reader.setHighlightedToken(token, painter); |
| 307 | } | 304 | } |
| 308 | } | 305 | } |
| 309 | } | 306 | } |
diff --git a/src/main/java/cuchaz/enigma/mapping/MappingsSRGWriter.java b/src/main/java/cuchaz/enigma/mapping/MappingsSRGWriter.java index cede1c2e..229bf464 100644 --- a/src/main/java/cuchaz/enigma/mapping/MappingsSRGWriter.java +++ b/src/main/java/cuchaz/enigma/mapping/MappingsSRGWriter.java | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | package cuchaz.enigma.mapping; | 1 | package cuchaz.enigma.mapping; |
| 2 | 2 | ||
| 3 | import com.google.common.base.Charsets; | 3 | import com.google.common.base.Charsets; |
| 4 | import cuchaz.enigma.Deobfuscator; | ||
| 5 | import cuchaz.enigma.analysis.TranslationIndex; | 4 | import cuchaz.enigma.analysis.TranslationIndex; |
| 6 | 5 | ||
| 7 | import java.io.*; | 6 | import java.io.*; |
diff --git a/src/main/java/cuchaz/enigma/mapping/ProcyonEntryFactory.java b/src/main/java/cuchaz/enigma/mapping/ProcyonEntryFactory.java index dca1e5ef..949d88f4 100644 --- a/src/main/java/cuchaz/enigma/mapping/ProcyonEntryFactory.java +++ b/src/main/java/cuchaz/enigma/mapping/ProcyonEntryFactory.java | |||
| @@ -11,7 +11,6 @@ | |||
| 11 | package cuchaz.enigma.mapping; | 11 | package cuchaz.enigma.mapping; |
| 12 | 12 | ||
| 13 | import com.strobel.assembler.metadata.FieldDefinition; | 13 | import com.strobel.assembler.metadata.FieldDefinition; |
| 14 | import com.strobel.assembler.metadata.IMethodSignature; | ||
| 15 | import com.strobel.assembler.metadata.MemberReference; | 14 | import com.strobel.assembler.metadata.MemberReference; |
| 16 | import com.strobel.assembler.metadata.MethodDefinition; | 15 | import com.strobel.assembler.metadata.MethodDefinition; |
| 17 | 16 | ||
diff --git a/src/main/java/cuchaz/enigma/mapping/Type.java b/src/main/java/cuchaz/enigma/mapping/Type.java index 34ddc059..8136e13b 100644 --- a/src/main/java/cuchaz/enigma/mapping/Type.java +++ b/src/main/java/cuchaz/enigma/mapping/Type.java | |||
| @@ -207,8 +207,8 @@ public class Type { | |||
| 207 | 207 | ||
| 208 | private static int countArrayDimension(String in) { | 208 | private static int countArrayDimension(String in) { |
| 209 | int i = 0; | 209 | int i = 0; |
| 210 | for (; i < in.length() && in.charAt(i) == '['; i++) { | 210 | while (i < in.length() && in.charAt(i) == '[') |
| 211 | } | 211 | i++; |
| 212 | return i; | 212 | return i; |
| 213 | } | 213 | } |
| 214 | 214 | ||
diff --git a/src/main/java/cuchaz/enigma/utils/ReadableToken.java b/src/main/java/cuchaz/enigma/utils/ReadableToken.java index 81193935..008e28cf 100644 --- a/src/main/java/cuchaz/enigma/utils/ReadableToken.java +++ b/src/main/java/cuchaz/enigma/utils/ReadableToken.java | |||
| @@ -24,13 +24,6 @@ public class ReadableToken { | |||
| 24 | 24 | ||
| 25 | @Override | 25 | @Override |
| 26 | public String toString() { | 26 | public String toString() { |
| 27 | StringBuilder buf = new StringBuilder(); | 27 | return "line " + line + " columns " + startColumn + "-" + endColumn; |
| 28 | buf.append("line "); | ||
| 29 | buf.append(line); | ||
| 30 | buf.append(" columns "); | ||
| 31 | buf.append(startColumn); | ||
| 32 | buf.append("-"); | ||
| 33 | buf.append(endColumn); | ||
| 34 | return buf.toString(); | ||
| 35 | } | 28 | } |
| 36 | } | 29 | } |
diff --git a/src/main/java/cuchaz/enigma/utils/Utils.java b/src/main/java/cuchaz/enigma/utils/Utils.java index 73c2bc7e..ebc110aa 100644 --- a/src/main/java/cuchaz/enigma/utils/Utils.java +++ b/src/main/java/cuchaz/enigma/utils/Utils.java | |||
| @@ -14,9 +14,6 @@ import com.google.common.io.CharStreams; | |||
| 14 | 14 | ||
| 15 | import java.awt.Desktop; | 15 | import java.awt.Desktop; |
| 16 | import java.awt.Font; | 16 | import java.awt.Font; |
| 17 | import java.awt.Rectangle; | ||
| 18 | import java.awt.event.ActionEvent; | ||
| 19 | import java.awt.event.ActionListener; | ||
| 20 | import java.awt.event.MouseEvent; | 17 | import java.awt.event.MouseEvent; |
| 21 | import java.io.IOException; | 18 | import java.io.IOException; |
| 22 | import java.io.InputStream; | 19 | import java.io.InputStream; |
| @@ -26,10 +23,6 @@ import java.net.URISyntaxException; | |||
| 26 | import java.util.Arrays; | 23 | import java.util.Arrays; |
| 27 | 24 | ||
| 28 | import javax.swing.*; | 25 | import javax.swing.*; |
| 29 | import javax.swing.text.BadLocationException; | ||
| 30 | import javax.swing.text.Highlighter; | ||
| 31 | |||
| 32 | import cuchaz.enigma.analysis.Token; | ||
| 33 | 26 | ||
| 34 | public class Utils { | 27 | public class Utils { |
| 35 | 28 | ||