aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com
diff options
context:
space:
mode:
authorJonas Herzig <me@johni0702.de>2019-12-07 12:07:23 +0100
committerJonas Herzig <me@johni0702.de>2019-12-07 12:07:23 +0100
commitec5bedf0458bec38c39290be85bafac0ea78f2ad (patch)
tree7c5bb2b60f15c62d286db83827ced97467928125 /src/main/kotlin/com
parent356541c5c2b279d29675e15a9098d5a21d399317 (diff)
downloadRemap-ec5bedf0458bec38c39290be85bafac0ea78f2ad.tar.gz
Remap-ec5bedf0458bec38c39290be85bafac0ea78f2ad.tar.bz2
Remap-ec5bedf0458bec38c39290be85bafac0ea78f2ad.zip
Remap string mixin target in `package.Outer.Inner` form (fixes #3)
Diffstat (limited to 'src/main/kotlin/com')
-rw-r--r--src/main/kotlin/com/replaymod/gradle/remap/LorenzExtensions.kt14
-rw-r--r--src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt2
2 files changed, 15 insertions, 1 deletions
diff --git a/src/main/kotlin/com/replaymod/gradle/remap/LorenzExtensions.kt b/src/main/kotlin/com/replaymod/gradle/remap/LorenzExtensions.kt
index cd04918..4994251 100644
--- a/src/main/kotlin/com/replaymod/gradle/remap/LorenzExtensions.kt
+++ b/src/main/kotlin/com/replaymod/gradle/remap/LorenzExtensions.kt
@@ -7,5 +7,19 @@ import org.cadixdev.lorenz.model.FieldMapping
import org.cadixdev.lorenz.model.MethodMapping
fun MappingSet.findClassMapping(obfuscatedName: String): ClassMapping<*, *>? = getClassMapping(obfuscatedName).orElse(null)
+
+// Find an inner class mapping with obfuscatedName in form of package.Outer.Inner
+// see https://github.com/ReplayMod/remap/issues/3
+fun MappingSet.findPotentialInnerClassMapping(obfuscatedName: String): ClassMapping<*, *>? {
+ val idx = obfuscatedName.lastIndexOf('.')
+ if (idx < 0) {
+ return findClassMapping(obfuscatedName)
+ }
+ val outerName = obfuscatedName.substring(0, idx)
+ val innerName = obfuscatedName.substring(idx + 1)
+ val outer = findPotentialInnerClassMapping(outerName) ?: return findClassMapping(obfuscatedName)
+ return outer.getInnerClassMapping(innerName).orElse(null)
+}
+
fun ClassMapping<*, *>.findFieldMapping(obfuscatedName: String): FieldMapping? = getFieldMapping(obfuscatedName).orElse(null)
fun ClassMapping<*, *>.findMethodMapping(signature: MethodSignature): MethodMapping? = getMethodMapping(signature).orElse(null)
diff --git a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
index e6b5f80..f999f8f 100644
--- a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
+++ b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
@@ -241,7 +241,7 @@ internal class PsiMapper(private val map: MappingSet, private val file: PsiFile)
val value = pair.value
if (value !is PsiLiteral) continue
val qualifiedName = value.value as? String ?: continue
- val mapping = map.findClassMapping(qualifiedName) ?: continue
+ val mapping = map.findPotentialInnerClassMapping(qualifiedName) ?: continue
val mapped = mapping.fullDeobfuscatedName?.replace('/', '.')
if (mapped != qualifiedName) {
replace(value, "\"$mapped\"")