mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
K2 UAST: expand typealias for qualified annotation name
^KTIJ-34026 fixed GitOrigin-RevId: 007b737d8347b75a141b0b9246e1d93accd29f02
This commit is contained in:
committed by
intellij-monorepo-bot
parent
599f689ba4
commit
7094917ed4
+43
@@ -2126,4 +2126,47 @@ interface UastApiFixtureTestBase {
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun checkTypealiasAnnotation(myFixture: JavaCodeInsightTestFixture) {
|
||||
myFixture.addClass(
|
||||
"""
|
||||
package org.junit;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.METHOD})
|
||||
public @interface Test {
|
||||
static class None extends Throwable {
|
||||
private None() {
|
||||
}
|
||||
}
|
||||
Class<? extends Throwable> expected() default None.class;
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
myFixture.configureByText(
|
||||
"test.kt",
|
||||
"""
|
||||
// Mimic typealias kotlin.test.Test
|
||||
typealias TT = org.junit.Test
|
||||
|
||||
class MyTest {
|
||||
@TT(expected = Throwable::class)
|
||||
fun foo() {}
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
val uFile = myFixture.file.toUElement()!!
|
||||
val foo = uFile.findElementByTextFromPsi<UMethod>("foo", strict = false)
|
||||
.orFail("cant convert to UMethod: foo")
|
||||
val anno = foo.findAnnotation("org.junit.Test")
|
||||
TestCase.assertNotNull(anno)
|
||||
val expected = anno!!.findDeclaredAttributeValue("expected") as? UClassLiteralExpression
|
||||
TestCase.assertEquals("java.lang.Throwable", expected?.type?.canonicalText)
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.analysis.api.types.KaErrorType
|
||||
import org.jetbrains.kotlin.analysis.api.types.KaType
|
||||
import org.jetbrains.kotlin.analysis.api.types.KaTypeMappingMode
|
||||
import org.jetbrains.kotlin.analysis.api.types.KaTypeNullability
|
||||
import org.jetbrains.kotlin.analysis.api.types.symbol
|
||||
import org.jetbrains.kotlin.asJava.toLightAnnotation
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
@@ -354,7 +355,8 @@ interface FirKotlinUastResolveProviderService : BaseKotlinUastResolveProviderSer
|
||||
analyzeForUast(ktCallElement) {
|
||||
val resolvedAnnotationConstructorSymbol =
|
||||
ktCallElement.resolveToCall()?.singleConstructorCallOrNull()?.symbol ?: return null
|
||||
return resolvedAnnotationConstructorSymbol.containingClassId
|
||||
val type = resolvedAnnotationConstructorSymbol.returnType.fullyExpandedType
|
||||
return type.symbol?.classId
|
||||
?.asSingleFqName()
|
||||
?.toString()
|
||||
}
|
||||
|
||||
+4
@@ -233,4 +233,8 @@ class FirUastApiFixtureTest : KotlinLightCodeInsightFixtureTestCase(), UastApiFi
|
||||
fun testAnnotationOnMemberWithValueClassInSignature() {
|
||||
checkAnnotationOnMemberWithValueClassInSignature(myFixture)
|
||||
}
|
||||
|
||||
fun testTypealiasAnnotation() {
|
||||
checkTypealiasAnnotation(myFixture)
|
||||
}
|
||||
}
|
||||
+4
@@ -226,6 +226,10 @@ class FE1UastApiFixtureTest : KotlinLightCodeInsightFixtureTestCase(), UastApiFi
|
||||
checkJavaConstantEvaluation(myFixture)
|
||||
}
|
||||
|
||||
fun testTypealiasAnnotation() {
|
||||
checkTypealiasAnnotation(myFixture)
|
||||
}
|
||||
|
||||
fun testAnnotationOnMemberWithValueClassInSignature() {
|
||||
checkAnnotationOnMemberWithValueClassInSignature(myFixture)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user