diff options
author | Jonas Herzig <jonas@spark-squared.com> | 2021-11-11 15:06:54 +0100 |
---|---|---|
committer | Jonas Herzig <jonas@spark-squared.com> | 2021-11-11 15:06:54 +0100 |
commit | b4462eb6030f8e5a072ad4b6508d7a93d574522f (patch) | |
tree | 6b00df9b43c732069ec4a68c1e063ff6943936c9 /src/main | |
parent | 62e3c5a678f10fc810605053289700014a16acd5 (diff) | |
download | Remap-b4462eb6030f8e5a072ad4b6508d7a93d574522f.tar.gz Remap-b4462eb6030f8e5a072ad4b6508d7a93d574522f.tar.bz2 Remap-b4462eb6030f8e5a072ad4b6508d7a93d574522f.zip |
Fix mixin @At target not considering mappings from parent classes
When remapping the @At `target` argument, we used to only look at the mappings
for the target class but we also need to consider mappings for its super classes
and interfaces.
This commit now searches for the target Psi method and then uses the regular
remap method for PsiMethod to get its properly mapped name.
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt index 3adc4f1..07d7d1d 100644 --- a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt +++ b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt @@ -399,10 +399,24 @@ internal class PsiMapper( val name = signature.substring(ownerEnd + 1, argsBegin) val returnType = signature.substring(argsEnd + 1) + val ownerPsi = JavaPsiFacade.getInstance(file.project).findClass( + owner.drop(1).dropLast(1).replace('/', '.').replace('$', '.'), + GlobalSearchScope.allScope(file.project), + ) + val methodPsi = if (method) { + val desc = signature.substring(argsBegin) + ownerPsi?.findMethodsByName(name, true)?.find { ClassUtil.getAsmMethodSignature(it) == desc } + } else { + null + } + val builder = StringBuilder(signature.length + 32) val mapping = remapInternalType(owner, builder) var mapped: String? = null - if (mapping != null) { + if (methodPsi != null) { + mapped = findMapping(methodPsi)?.deobfuscatedName + } + if (mapped == null && mapping != null) { mapped = (if (method) { mapping.findMethodMapping(MethodSignature.of(signature.substring(ownerEnd + 1))) } else { |