aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/replaymod/gradle/remap/PsiUtils.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/com/replaymod/gradle/remap/PsiUtils.kt')
-rw-r--r--src/main/kotlin/com/replaymod/gradle/remap/PsiUtils.kt13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/main/kotlin/com/replaymod/gradle/remap/PsiUtils.kt b/src/main/kotlin/com/replaymod/gradle/remap/PsiUtils.kt
index 936ab89..de42dcf 100644
--- a/src/main/kotlin/com/replaymod/gradle/remap/PsiUtils.kt
+++ b/src/main/kotlin/com/replaymod/gradle/remap/PsiUtils.kt
@@ -19,8 +19,11 @@ internal val PsiClass.dollarQualifiedName: String? get() {
return "$parentName$$selfName"
}
-internal val PsiNameValuePair.resolvedLiteralValue: Pair<PsiLiteralExpression, String>? get () {
- var value: PsiElement? = value
+internal val PsiNameValuePair.resolvedLiteralValue: Pair<PsiLiteralExpression, String>?
+ get () = value?.resolvedLiteralValue
+
+private val PsiElement.resolvedLiteralValue: Pair<PsiLiteralExpression, String>? get () {
+ var value: PsiElement? = this
while (value is PsiReferenceExpression) {
val resolved = value.resolve()
value = when (resolved) {
@@ -32,6 +35,12 @@ internal val PsiNameValuePair.resolvedLiteralValue: Pair<PsiLiteralExpression, S
return Pair(literal, StringUtil.unquoteString(literal.text))
}
+internal val PsiAnnotationMemberValue.resolvedLiteralValues: List<Pair<PsiLiteralExpression, String>>
+ get () = when (this) {
+ is PsiArrayInitializerMemberValue -> initializers.mapNotNull { it.resolvedLiteralValue }
+ else -> listOfNotNull(resolvedLiteralValue)
+ }
+
internal object PsiUtils {
fun getSignature(method: PsiMethod): MethodSignature = MethodSignature(method.name, getDescriptor(method))