diff --git a/plugins/uast-kotlin/testData/TypeInAnnotation.kt b/plugins/uast-kotlin/testData/TypeInAnnotation.kt new file mode 100644 index 00000000000..d7fd4b53e57 --- /dev/null +++ b/plugins/uast-kotlin/testData/TypeInAnnotation.kt @@ -0,0 +1,6 @@ +class C { + @Test + fun foo() { + + } +} \ No newline at end of file diff --git a/plugins/uast-kotlin/tests/KotlinUastApiTest.kt b/plugins/uast-kotlin/tests/KotlinUastApiTest.kt index 3d84c3e97b1..8d2fd514e2e 100644 --- a/plugins/uast-kotlin/tests/KotlinUastApiTest.kt +++ b/plugins/uast-kotlin/tests/KotlinUastApiTest.kt @@ -7,6 +7,7 @@ import org.jetbrains.kotlin.psi.KtAnnotationEntry import org.jetbrains.kotlin.psi.KtBinaryExpression import org.jetbrains.kotlin.psi.KtLiteralStringTemplateEntry import org.jetbrains.kotlin.psi.KtStringTemplateExpression +import org.jetbrains.kotlin.psi.KtUserType import org.jetbrains.kotlin.psi.psiUtil.getParentOfType import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase import org.jetbrains.kotlin.utils.addToStdlib.cast @@ -131,6 +132,14 @@ class KotlinUastApiTest : AbstractKotlinUastTest() { } } + @Test fun testConvertTypeInAnnotation() { + doTest("TypeInAnnotation") { _, file -> + val index = file.psi.text.indexOf("Test") + val element = file.psi.findElementAt(index)!!.getParentOfType(false)!! + assertNotNull(element.getUastParentOfType(UAnnotation::class.java)) + } + } + @Test fun testElvisType() { doTest("ElvisType") { _, file -> val elvisExpression = file.findElementByText("text ?: return")