Skip to content

Commit 0000368

Browse files
committed
Add test for converting a string literal to UAST
1 parent 5dc1784 commit 0000368

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Demo {
2+
val foo = X.bar("lorem")
3+
}

plugins/uast-kotlin/tests/KotlinUastApiTest.kt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
package org.jetbrains.uast.test.kotlin
22

3+
import org.jetbrains.kotlin.psi.KtLiteralStringTemplateEntry
34
import org.jetbrains.uast.UAnnotation
45
import org.jetbrains.uast.UFile
6+
import org.jetbrains.uast.ULiteralExpression
7+
import org.jetbrains.uast.psi.PsiElementBacked
58
import org.jetbrains.uast.test.env.findElementByText
9+
import org.jetbrains.uast.toUElement
10+
import org.junit.Assert
611
import org.junit.Test
712

813

@@ -17,5 +22,15 @@ class KotlinUastApiTest : AbstractKotlinUastTest() {
1722
assertEquals(annotation.findAttributeValue("to")?.expression?.evaluate(), 0)
1823
}
1924
}
20-
}
2125

26+
@Test fun testConvertStringTemplate() {
27+
doTest("StringTemplateInClass") { name, file ->
28+
val literalExpression = file.findElementByText<ULiteralExpression>("lorem")
29+
val psi = (literalExpression as PsiElementBacked).psi!!
30+
Assert.assertTrue(psi is KtLiteralStringTemplateEntry)
31+
val literalExpressionAgain = psi.toUElement()
32+
Assert.assertTrue(literalExpressionAgain is ULiteralExpression)
33+
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)