aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Herzig <me@johni0702.de>2019-04-27 09:29:53 +0200
committerJonas Herzig <me@johni0702.de>2019-04-27 09:29:53 +0200
commitc846ecc80c903ee761e28e95ea2056cb89f91f63 (patch)
treec551ebe26e40ef63b170a31625c38e6498fc0120
parent47f6619af6c0448911464210cc4143da7ad18d3b (diff)
downloadRemap-c846ecc80c903ee761e28e95ea2056cb89f91f63.tar.gz
Remap-c846ecc80c903ee761e28e95ea2056cb89f91f63.tar.bz2
Remap-c846ecc80c903ee761e28e95ea2056cb89f91f63.zip
Also fix method/field mappings for types with generics
-rw-r--r--src/main/java/com/replaymod/gradle/remap/Transformer.java17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/main/java/com/replaymod/gradle/remap/Transformer.java b/src/main/java/com/replaymod/gradle/remap/Transformer.java
index 801cfb6..0598546 100644
--- a/src/main/java/com/replaymod/gradle/remap/Transformer.java
+++ b/src/main/java/com/replaymod/gradle/remap/Transformer.java
@@ -244,6 +244,11 @@ class Transformer {
return changed.get();
}
+ private static String stripGenerics(String name) {
+ int paramIndex = name.indexOf('<');
+ return paramIndex != -1 ? name.substring(0, paramIndex) : name;
+ }
+
private boolean remapClass(CompilationUnit cu) {
AtomicBoolean changed = new AtomicBoolean(false);
Map<String, String> mappedImports = new HashMap<>();
@@ -339,7 +344,7 @@ class Transformer {
if (binding instanceof IVariableBinding) {
ITypeBinding declaringClass = ((IVariableBinding) binding).getDeclaringClass();
if (declaringClass == null) return true;
- String name = declaringClass.getQualifiedName();
+ String name = stripGenerics(declaringClass.getQualifiedName());
if (name.isEmpty()) return true;
Mapping mapping = mixinMappings.get(name);
if (mapping == null) {
@@ -350,7 +355,7 @@ class Transformer {
} else if (binding instanceof IMethodBinding) {
ITypeBinding declaringClass = ((IMethodBinding) binding).getDeclaringClass();
if (declaringClass == null) return true;
- String name = declaringClass.getQualifiedName();
+ String name = stripGenerics(declaringClass.getQualifiedName());
if (name.isEmpty()) return true;
Mapping mapping = mixinMappings.get(name);
ArrayDeque<ITypeBinding> parentQueue = new ArrayDeque<>();
@@ -374,18 +379,14 @@ class Transformer {
while (mapping == null) {
declaringClass = parentQueue.poll();
if (declaringClass == null) return true;
- name = declaringClass.getQualifiedName();
+ name = stripGenerics(declaringClass.getQualifiedName());
if (name.isEmpty()) continue;
mapping = map.get(name);
}
}
} else if (binding instanceof ITypeBinding) {
- String name = ((ITypeBinding) binding).getQualifiedName();
+ String name = stripGenerics(((ITypeBinding) binding).getQualifiedName());
if (name.isEmpty()) return true;
- int paramIndex = name.indexOf('<');
- if (paramIndex != -1) {
- name = name.substring(0, paramIndex);
- }
Mapping mapping = map.get(name);
if (mapping == null) return true;
mapped = mapping.newName;