From 47f6619af6c0448911464210cc4143da7ad18d3b Mon Sep 17 00:00:00 2001 From: Jonas Herzig Date: Fri, 26 Apr 2019 23:11:35 +0200 Subject: Support remapping of overridden methods --- .../com/replaymod/gradle/remap/Transformer.java | 30 +++++++++++++++++++--- 1 file 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 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; -- cgit