diff options
| -rw-r--r-- | src/main/java/cuchaz/enigma/analysis/TranslationIndex.java | 14 | ||||
| -rw-r--r-- | src/main/java/cuchaz/enigma/mapping/Translator.java | 3 |
2 files changed, 12 insertions, 5 deletions
diff --git a/src/main/java/cuchaz/enigma/analysis/TranslationIndex.java b/src/main/java/cuchaz/enigma/analysis/TranslationIndex.java index 94af0311..14bc6044 100644 --- a/src/main/java/cuchaz/enigma/analysis/TranslationIndex.java +++ b/src/main/java/cuchaz/enigma/analysis/TranslationIndex.java | |||
| @@ -186,11 +186,15 @@ public class TranslationIndex { | |||
| 186 | } | 186 | } |
| 187 | 187 | ||
| 188 | public ClassEntry resolveEntryClass(Entry entry) { | 188 | public ClassEntry resolveEntryClass(Entry entry) { |
| 189 | return resolveEntryClass(entry, false); | ||
| 190 | } | ||
| 191 | |||
| 192 | public ClassEntry resolveEntryClass(Entry entry, boolean checkSuperclassBeforeChild) { | ||
| 189 | if (entry instanceof ClassEntry) { | 193 | if (entry instanceof ClassEntry) { |
| 190 | return (ClassEntry) entry; | 194 | return (ClassEntry) entry; |
| 191 | } | 195 | } |
| 192 | 196 | ||
| 193 | ClassEntry superclassEntry = resolveSuperclass(entry); | 197 | ClassEntry superclassEntry = resolveSuperclass(entry, checkSuperclassBeforeChild); |
| 194 | if (superclassEntry != null) { | 198 | if (superclassEntry != null) { |
| 195 | return superclassEntry; | 199 | return superclassEntry; |
| 196 | } | 200 | } |
| @@ -204,6 +208,10 @@ public class TranslationIndex { | |||
| 204 | } | 208 | } |
| 205 | 209 | ||
| 206 | public ClassEntry resolveSuperclass(Entry entry) { | 210 | public ClassEntry resolveSuperclass(Entry entry) { |
| 211 | return resolveSuperclass(entry, false); | ||
| 212 | } | ||
| 213 | |||
| 214 | public ClassEntry resolveSuperclass(Entry entry, boolean checkSuperclassBeforeChild) { | ||
| 207 | // this entry could refer to a method on a class where the method is not actually implemented | 215 | // this entry could refer to a method on a class where the method is not actually implemented |
| 208 | // travel up the inheritance tree to find the closest implementation | 216 | // travel up the inheritance tree to find the closest implementation |
| 209 | 217 | ||
| @@ -212,14 +220,14 @@ public class TranslationIndex { | |||
| 212 | 220 | ||
| 213 | // Scan superclass before main class to avoid missing override issues | 221 | // Scan superclass before main class to avoid missing override issues |
| 214 | ClassEntry superclassEntry = null; | 222 | ClassEntry superclassEntry = null; |
| 215 | while (superclassEntry == null || !entryExists(entry)) { | 223 | while ((checkSuperclassBeforeChild && superclassEntry == null) || !entryExists(entry)) { |
| 216 | 224 | ||
| 217 | // is there a parent class? | 225 | // is there a parent class? |
| 218 | superclassEntry = getSuperclass(entry.getClassEntry()); | 226 | superclassEntry = getSuperclass(entry.getClassEntry()); |
| 219 | if (superclassEntry == null) { | 227 | if (superclassEntry == null) { |
| 220 | // this is probably a method from a class in a library or it's in the default class | 228 | // this is probably a method from a class in a library or it's in the default class |
| 221 | // we can't trace the implementation up any higher unless we index the library | 229 | // we can't trace the implementation up any higher unless we index the library |
| 222 | return entryExists(originalEntry) ? originalEntry.getClassEntry() : null; | 230 | return checkSuperclassBeforeChild && entryExists(originalEntry) ? originalEntry.getClassEntry() : null; |
| 223 | } | 231 | } |
| 224 | 232 | ||
| 225 | // move up to the parent class | 233 | // move up to the parent class |
diff --git a/src/main/java/cuchaz/enigma/mapping/Translator.java b/src/main/java/cuchaz/enigma/mapping/Translator.java index eb6a1892..de48c9a1 100644 --- a/src/main/java/cuchaz/enigma/mapping/Translator.java +++ b/src/main/java/cuchaz/enigma/mapping/Translator.java | |||
| @@ -157,9 +157,8 @@ public class Translator { | |||
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | public String translate(MethodEntry in) { | 159 | public String translate(MethodEntry in) { |
| 160 | |||
| 161 | // resolve the class entry | 160 | // resolve the class entry |
| 162 | ClassEntry resolvedClassEntry = this.index.resolveEntryClass(in); | 161 | ClassEntry resolvedClassEntry = this.index.resolveEntryClass(in, true); |
| 163 | if (resolvedClassEntry != null) { | 162 | if (resolvedClassEntry != null) { |
| 164 | 163 | ||
| 165 | // look for class | 164 | // look for class |