UAST: Add testConvertTypeInAnnotation

This commit is contained in:
Vyacheslav Gerasimov
2017-08-01 22:50:35 +03:00
committed by Nikolay Krasko
parent 92c23aa0ed
commit e6efaaf752
2 changed files with 15 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
class C {
@Test
fun foo() {
}
}
@@ -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<KtUserType>(false)!!
assertNotNull(element.getUastParentOfType(UAnnotation::class.java))
}
}
@Test fun testElvisType() {
doTest("ElvisType") { _, file ->
val elvisExpression = file.findElementByText<UExpression>("text ?: return")