aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/replaymod
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/com/replaymod')
-rw-r--r--src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt17
-rw-r--r--src/main/kotlin/com/replaymod/gradle/remap/PsiUtils.kt10
2 files changed, 18 insertions, 9 deletions
diff --git a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
index 7d4c054..1109a01 100644
--- a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
+++ b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
@@ -67,8 +67,8 @@ internal class PsiMapper(private val map: MappingSet, private val file: PsiFile)
private fun map(expr: PsiElement, field: PsiField) {
val fieldName = field.name ?: return
val declaringClass = field.containingClass ?: return
- val name = declaringClass.qualifiedName ?: return
- var mapping: ClassMapping<*, *>? = this.mixinMappings[name]
+ val name = declaringClass.dollarQualifiedName ?: return
+ var mapping: ClassMapping<*, *>? = this.mixinMappings[declaringClass.qualifiedName ?: return]
if (mapping == null) {
mapping = map.findClassMapping(name)
}
@@ -168,7 +168,7 @@ internal class PsiMapper(private val map: MappingSet, private val file: PsiFile)
parentQueue.offer(anInterface)
}
- name = declaringClass.qualifiedName
+ name = declaringClass.dollarQualifiedName
if (name == null) continue
mapping = map.findClassMapping(name)
}
@@ -177,10 +177,11 @@ internal class PsiMapper(private val map: MappingSet, private val file: PsiFile)
private fun map(expr: PsiElement, resolved: PsiQualifiedNamedElement) {
val name = resolved.qualifiedName ?: return
- val mapping = map.findClassMapping(name) ?: return
- var mapped = mapping.deobfuscatedName
- if (mapped == name) return
- mapped = mapped.replace('/', '.')
+ val dollarName = (if (resolved is PsiClass) resolved.dollarQualifiedName else name) ?: return
+ val mapping = map.findClassMapping(dollarName) ?: return
+ var mapped = mapping.fullDeobfuscatedName
+ if (mapped == dollarName) return
+ mapped = mapped.replace('/', '.').replace('$', '.')
if (expr.text == name) {
replace(expr, mapped)
@@ -391,7 +392,7 @@ internal class PsiMapper(private val map: MappingSet, private val file: PsiFile)
remapAtTargets()
val target = getMixinTarget(annotation) ?: return
- val qualifiedName = target.qualifiedName ?: return
+ val qualifiedName = target.dollarQualifiedName ?: return
val mapping = map.findClassMapping(qualifiedName) ?: return
diff --git a/src/main/kotlin/com/replaymod/gradle/remap/PsiUtils.kt b/src/main/kotlin/com/replaymod/gradle/remap/PsiUtils.kt
index 4a435b9..63f0e76 100644
--- a/src/main/kotlin/com/replaymod/gradle/remap/PsiUtils.kt
+++ b/src/main/kotlin/com/replaymod/gradle/remap/PsiUtils.kt
@@ -8,8 +8,16 @@ import org.cadixdev.bombe.type.Type
import org.cadixdev.bombe.type.VoidType
import org.cadixdev.bombe.type.signature.MethodSignature
import org.jetbrains.kotlin.com.intellij.psi.*
+import org.jetbrains.kotlin.com.intellij.psi.util.PsiTreeUtil
import org.jetbrains.kotlin.com.intellij.psi.util.TypeConversionUtil
+internal val PsiClass.dollarQualifiedName: String? get() {
+ val parent = PsiTreeUtil.getParentOfType<PsiClass>(this, PsiClass::class.java) ?: return qualifiedName
+ val parentName = parent.dollarQualifiedName ?: return qualifiedName
+ val selfName = name ?: return qualifiedName
+ return "$parentName$$selfName"
+}
+
internal object PsiUtils {
fun getSignature(method: PsiMethod): MethodSignature = MethodSignature(method.name, getDescriptor(method))
@@ -26,7 +34,7 @@ internal object PsiUtils {
}
is PsiClassType -> {
val resolved = erasedType.resolve() ?: throw NullPointerException("Failed to resolve type $erasedType")
- val qualifiedName = resolved.qualifiedName
+ val qualifiedName = resolved.dollarQualifiedName
?: throw NullPointerException("Type $erasedType has no qualified name.")
ObjectType(qualifiedName)
}