diff --git a/src/main/kotlin/platform/mixin/inspection/reference/AmbiguousReferenceInspection.kt b/src/main/kotlin/platform/mixin/inspection/reference/AmbiguousReferenceInspection.kt index 2586cc9ed..674c0dce3 100644 --- a/src/main/kotlin/platform/mixin/inspection/reference/AmbiguousReferenceInspection.kt +++ b/src/main/kotlin/platform/mixin/inspection/reference/AmbiguousReferenceInspection.kt @@ -35,7 +35,6 @@ import com.intellij.psi.PsiAnnotation import com.intellij.psi.PsiAnnotationMemberValue import com.intellij.psi.PsiArrayInitializerMemberValue import com.intellij.psi.PsiBinaryExpression -import com.intellij.psi.PsiLiteral class AmbiguousReferenceInspection : MixinAnnotationAttributeInspection("method") { @@ -53,8 +52,8 @@ class AmbiguousReferenceInspection : MixinAnnotationAttributeInspection("method" } when (value) { - is PsiLiteral -> checkMember(value, holder) is PsiArrayInitializerMemberValue -> value.initializers.forEach { checkMember(it, holder) } + else -> checkMember(value, holder) } } @@ -80,7 +79,7 @@ class AmbiguousReferenceInspection : MixinAnnotationAttributeInspection("method" val elementFactory = JavaPsiFacade.getElementFactory(project) - if (constantValue != null && element is PsiLiteral) { + if (constantValue != null) { val newLiteral = "\"${StringUtil.escapeStringCharacters("$constantValue*")}\"" element.replace(elementFactory.createExpressionFromText(newLiteral, null)) } else { diff --git a/src/main/kotlin/platform/mixin/inspection/reference/InvalidMemberReferenceInspection.kt b/src/main/kotlin/platform/mixin/inspection/reference/InvalidMemberReferenceInspection.kt index ed325be96..53bff2154 100644 --- a/src/main/kotlin/platform/mixin/inspection/reference/InvalidMemberReferenceInspection.kt +++ b/src/main/kotlin/platform/mixin/inspection/reference/InvalidMemberReferenceInspection.kt @@ -33,7 +33,6 @@ import com.intellij.psi.JavaElementVisitor import com.intellij.psi.PsiArrayInitializerMemberValue import com.intellij.psi.PsiElement import com.intellij.psi.PsiElementVisitor -import com.intellij.psi.PsiLiteral import com.intellij.psi.PsiNameValuePair class InvalidMemberReferenceInspection : MixinInspection() { @@ -68,10 +67,10 @@ class InvalidMemberReferenceInspection : MixinInspection() { // Attempt to parse the reference when (value) { - is PsiLiteral -> checkMemberReference(value, value.constantStringValue) is PsiArrayInitializerMemberValue -> value.initializers.forEach { checkMemberReference(it, it.constantStringValue) } + else -> checkMemberReference(value, value.constantStringValue) } } diff --git a/src/main/kotlin/platform/mixin/inspection/reference/UnnecessaryQualifiedMemberReferenceInspection.kt b/src/main/kotlin/platform/mixin/inspection/reference/UnnecessaryQualifiedMemberReferenceInspection.kt index 7931a2ad3..fbe4573fc 100644 --- a/src/main/kotlin/platform/mixin/inspection/reference/UnnecessaryQualifiedMemberReferenceInspection.kt +++ b/src/main/kotlin/platform/mixin/inspection/reference/UnnecessaryQualifiedMemberReferenceInspection.kt @@ -34,7 +34,6 @@ import com.intellij.psi.JavaPsiFacade import com.intellij.psi.PsiAnnotation import com.intellij.psi.PsiAnnotationMemberValue import com.intellij.psi.PsiArrayInitializerMemberValue -import com.intellij.psi.PsiLiteral class UnnecessaryQualifiedMemberReferenceInspection : MixinAnnotationAttributeInspection("method") { @@ -51,8 +50,8 @@ class UnnecessaryQualifiedMemberReferenceInspection : MixinAnnotationAttributeIn } when (value) { - is PsiLiteral -> checkMemberReference(value, holder) is PsiArrayInitializerMemberValue -> value.initializers.forEach { checkMemberReference(it, holder) } + else -> checkMemberReference(value, holder) } } diff --git a/src/main/kotlin/platform/mixin/reference/AbstractMethodReference.kt b/src/main/kotlin/platform/mixin/reference/AbstractMethodReference.kt index 89aa5dbd5..399bd23f4 100644 --- a/src/main/kotlin/platform/mixin/reference/AbstractMethodReference.kt +++ b/src/main/kotlin/platform/mixin/reference/AbstractMethodReference.kt @@ -43,7 +43,6 @@ import com.intellij.codeInsight.lookup.LookupElementBuilder import com.intellij.psi.PsiAnnotation import com.intellij.psi.PsiArrayInitializerMemberValue import com.intellij.psi.PsiElement -import com.intellij.psi.PsiLiteral import com.intellij.psi.PsiSubstitutor import com.intellij.psi.ResolveResult import com.intellij.psi.util.parentOfType @@ -111,9 +110,8 @@ abstract class AbstractMethodReference : PolyReferenceResolver(), MixinReference private fun resolve(context: PsiElement): Sequence? { val targets = getTargets(context) ?: return null val targetedMethods = when (context) { - is PsiLiteral -> context.constantStringValue?.let { listOf(it) } ?: emptyList() is PsiArrayInitializerMemberValue -> context.initializers.mapNotNull { it.constantStringValue } - else -> emptyList() + else -> context.constantStringValue?.let { listOf(it) } ?: emptyList() } return targetedMethods.asSequence().flatMap { method -> @@ -141,9 +139,8 @@ abstract class AbstractMethodReference : PolyReferenceResolver(), MixinReference val targets = getTargets(context) ?: return null val targetedMethods = when (context) { - is PsiLiteral -> context.constantStringValue?.let { listOf(it) } ?: emptyList() is PsiArrayInitializerMemberValue -> context.initializers.mapNotNull { it.constantStringValue } - else -> emptyList() + else -> context.constantStringValue?.let { listOf(it) } ?: emptyList() } return targetedMethods.asSequence().flatMap { method ->