diff options
author | Jonas Herzig <me@johni0702.de> | 2019-04-26 23:11:35 +0200 |
---|---|---|
committer | Jonas Herzig <me@johni0702.de> | 2019-04-26 23:11:35 +0200 |
commit | 47f6619af6c0448911464210cc4143da7ad18d3b (patch) | |
tree | 4743dab4e4fac60a37f26b9e1b5613095e93d619 | |
parent | 8f3a2e709178fc88d1f99b65af3255e1018196a8 (diff) | |
download | Remap-47f6619af6c0448911464210cc4143da7ad18d3b.tar.gz Remap-47f6619af6c0448911464210cc4143da7ad18d3b.tar.bz2 Remap-47f6619af6c0448911464210cc4143da7ad18d3b.zip |
Support remapping of overridden methods
-rw-r--r-- | src/main/java/com/replaymod/gradle/remap/Transformer.java | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/main/java/com/replaymod/gradle/remap/Transformer.java b/src/main/java/com/replaymod/gradle/remap/Transformer.java index bbc6b2e..801cfb6 100644 --- a/src/main/java/com/replaymod/gradle/remap/Transformer.java +++ b/src/main/java/com/replaymod/gradle/remap/Transformer.java @@ -13,6 +13,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.nio.file.Files; +import java.util.ArrayDeque; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -352,11 +353,32 @@ class Transformer { String name = declaringClass.getQualifiedName(); if (name.isEmpty()) return true; Mapping mapping = mixinMappings.get(name); - if (mapping == null) { - mapping = map.get(name); + ArrayDeque<ITypeBinding> parentQueue = new ArrayDeque<>(); + parentQueue.offer(declaringClass); + while (true) { + if (mapping != null) { + mapped = mapping.methods.get(node.getIdentifier()); + if (mapped != null) { + break; + } + mapping = null; + } + + ITypeBinding superClass = declaringClass.getSuperclass(); + if (superClass != null) { + parentQueue.offer(superClass); + } + for (ITypeBinding anInterface : declaringClass.getInterfaces()) { + parentQueue.offer(anInterface); + } + while (mapping == null) { + declaringClass = parentQueue.poll(); + if (declaringClass == null) return true; + name = declaringClass.getQualifiedName(); + if (name.isEmpty()) continue; + mapping = map.get(name); + } } - if (mapping == null) return true; - mapped = mapping.methods.get(node.getIdentifier()); } else if (binding instanceof ITypeBinding) { String name = ((ITypeBinding) binding).getQualifiedName(); if (name.isEmpty()) return true; |