From 64f615806b4f21998cdc3da0885ad9958d4de369 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Wed, 31 Jul 2024 21:20:49 +0200 Subject: Add method to error message when failing to get method signature --- src/main/kotlin/com/replaymod/gradle/remap/PsiUtils.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/main/kotlin/com/replaymod/gradle') diff --git a/src/main/kotlin/com/replaymod/gradle/remap/PsiUtils.kt b/src/main/kotlin/com/replaymod/gradle/remap/PsiUtils.kt index de42dcf..0240aa5 100644 --- a/src/main/kotlin/com/replaymod/gradle/remap/PsiUtils.kt +++ b/src/main/kotlin/com/replaymod/gradle/remap/PsiUtils.kt @@ -41,8 +41,12 @@ internal val PsiAnnotationMemberValue.resolvedLiteralValues: List listOfNotNull(resolvedLiteralValue) } +internal class MethodSignatureException(val method: PsiMethod, cause: Exception) + : Exception("Failed to resolve signature of method $method in ${method.containingFile}", cause) + internal object PsiUtils { - fun getSignature(method: PsiMethod): MethodSignature = MethodSignature(method.name, getDescriptor(method)) + fun getSignature(method: PsiMethod): MethodSignature = runCatching { MethodSignature(method.name, getDescriptor(method)) } + .getOrElse { throw MethodSignatureException(method, it as Exception) } private fun getDescriptor(method: PsiMethod): MethodDescriptor = MethodDescriptor( method.parameterList.parameters.map { getFieldType(it.type) }, -- cgit