Add test for converting a string literal to UAST
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
class Demo {
|
||||||
|
val foo = X.bar("lorem")
|
||||||
|
}
|
||||||
@@ -1,8 +1,13 @@
|
|||||||
package org.jetbrains.uast.test.kotlin
|
package org.jetbrains.uast.test.kotlin
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.psi.KtLiteralStringTemplateEntry
|
||||||
import org.jetbrains.uast.UAnnotation
|
import org.jetbrains.uast.UAnnotation
|
||||||
import org.jetbrains.uast.UFile
|
import org.jetbrains.uast.UFile
|
||||||
|
import org.jetbrains.uast.ULiteralExpression
|
||||||
|
import org.jetbrains.uast.psi.PsiElementBacked
|
||||||
import org.jetbrains.uast.test.env.findElementByText
|
import org.jetbrains.uast.test.env.findElementByText
|
||||||
|
import org.jetbrains.uast.toUElement
|
||||||
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
|
|
||||||
@@ -17,5 +22,15 @@ class KotlinUastApiTest : AbstractKotlinUastTest() {
|
|||||||
assertEquals(annotation.findAttributeValue("to")?.expression?.evaluate(), 0)
|
assertEquals(annotation.findAttributeValue("to")?.expression?.evaluate(), 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
@Test fun testConvertStringTemplate() {
|
||||||
|
doTest("StringTemplateInClass") { name, file ->
|
||||||
|
val literalExpression = file.findElementByText<ULiteralExpression>("lorem")
|
||||||
|
val psi = (literalExpression as PsiElementBacked).psi!!
|
||||||
|
Assert.assertTrue(psi is KtLiteralStringTemplateEntry)
|
||||||
|
val literalExpressionAgain = psi.toUElement()
|
||||||
|
Assert.assertTrue(literalExpressionAgain is ULiteralExpression)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user