Spring Support: Fixed computation of values in Java annotations referred by Kotlin annotation entries

#KT-11702 Fixed
This commit is contained in:
Alexey Sedunov
2016-04-04 13:06:04 +03:00
parent a818d4714e
commit eeac739f69
11 changed files with 122 additions and 19 deletions
@@ -22,7 +22,6 @@ import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry
import com.intellij.util.IncorrectOperationException
import org.jetbrains.kotlin.idea.KotlinLanguage
import org.jetbrains.kotlin.psi.KtAnnotationEntry
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtParameter
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
@@ -37,7 +36,7 @@ class KtLightAnnotation(
private val owner: PsiAnnotationOwner
) : PsiAnnotation by clsDelegate, KtLightElement<KtAnnotationEntry, PsiAnnotation> {
inner class LightExpressionValue(private val delegate: PsiExpression) : PsiAnnotationMemberValue, PsiExpression by delegate {
val originalExpression: KtExpression? by lazy {
val originalExpression: PsiElement? by lazy {
val nameAndValue = getStrictParentOfType<PsiNameValuePair>() ?: return@lazy null
val annotationEntry = this@KtLightAnnotation.kotlinOrigin
val context = LightClassGenerationSupport.getInstance(project).analyze(annotationEntry)
@@ -49,7 +48,12 @@ class KtLightAnnotation(
val resolvedArgument = resolvedCall.valueArguments[parameter] ?: return@lazy null
when (resolvedArgument) {
is DefaultValueArgument -> {
(parameter.source.getPsi() as? KtParameter)?.defaultValue
val psi = parameter.source.getPsi()
when (psi) {
is KtParameter -> psi.defaultValue
is PsiAnnotationMethod -> psi.defaultValue
else -> null
}
}
is ExpressionValueArgument -> {