diff --git a/plugins/uast-kotlin/testData/StringTemplate.kt b/plugins/uast-kotlin/testData/StringTemplate.kt index bd49f63527e..b8b252dfe46 100644 --- a/plugins/uast-kotlin/testData/StringTemplate.kt +++ b/plugins/uast-kotlin/testData/StringTemplate.kt @@ -3,13 +3,3 @@ val bar = "ipsum" val baz = "dolor" val foobarbaz = "$foo $bar $baz" - -val case4 = "a ${"literal"} z" - -fun simpleForTemplate(i: Int = 0) = "$i" - -fun foo() { - println("$baz") - val template1 = "${simpleForTemplate()}" - val template2 = ".${simpleForTemplate()}" -} diff --git a/plugins/uast-kotlin/testData/StringTemplate.log.txt b/plugins/uast-kotlin/testData/StringTemplate.log.txt index 58a614ecb0a..e38047dc442 100644 --- a/plugins/uast-kotlin/testData/StringTemplate.log.txt +++ b/plugins/uast-kotlin/testData/StringTemplate.log.txt @@ -17,37 +17,7 @@ UFile (package = ) USimpleNameReferenceExpression (identifier = bar) ULiteralExpression (value = " ") USimpleNameReferenceExpression (identifier = baz) - UField (name = case4) - UAnnotation (fqName = org.jetbrains.annotations.NotNull) - UPolyadicExpression (operator = +) - ULiteralExpression (value = "a ") - ULiteralExpression (value = "literal") - ULiteralExpression (value = " z") UAnnotationMethod (name = getFoo) UAnnotationMethod (name = getBar) UAnnotationMethod (name = getBaz) UAnnotationMethod (name = getFoobarbaz) - UAnnotationMethod (name = getCase4) - UAnnotationMethod (name = simpleForTemplate) - UParameter (name = i) - UAnnotation (fqName = null) - ULiteralExpression (value = 0) - USimpleNameReferenceExpression (identifier = i) - UAnnotationMethod (name = foo) - UBlockExpression - UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) - UIdentifier (Identifier (println)) - USimpleNameReferenceExpression (identifier = println) - USimpleNameReferenceExpression (identifier = baz) - UDeclarationsExpression - ULocalVariable (name = template1) - UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) - UIdentifier (Identifier (simpleForTemplate)) - USimpleNameReferenceExpression (identifier = simpleForTemplate) - UDeclarationsExpression - ULocalVariable (name = template2) - UPolyadicExpression (operator = +) - ULiteralExpression (value = ".") - UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) - UIdentifier (Identifier (simpleForTemplate)) - USimpleNameReferenceExpression (identifier = simpleForTemplate) diff --git a/plugins/uast-kotlin/testData/StringTemplate.render.txt b/plugins/uast-kotlin/testData/StringTemplate.render.txt index 53352b5611c..2d56a3954b6 100644 --- a/plugins/uast-kotlin/testData/StringTemplate.render.txt +++ b/plugins/uast-kotlin/testData/StringTemplate.render.txt @@ -3,16 +3,8 @@ public final class StringTemplateKt { private static final var bar: java.lang.String = "ipsum" private static final var baz: java.lang.String = "dolor" private static final var foobarbaz: java.lang.String = foo + " " + bar + " " + baz - private static final var case4: java.lang.String = "a " + "literal" + " z" public static final fun getFoo() : java.lang.String = UastEmptyExpression public static final fun getBar() : java.lang.String = UastEmptyExpression public static final fun getBaz() : java.lang.String = UastEmptyExpression public static final fun getFoobarbaz() : java.lang.String = UastEmptyExpression - public static final fun getCase4() : java.lang.String = UastEmptyExpression - public static final fun simpleForTemplate(i: int) : java.lang.String = i - public static final fun foo() : void { - println(baz) - var template1: java.lang.String = simpleForTemplate() - var template2: java.lang.String = "." + simpleForTemplate() - } } diff --git a/plugins/uast-kotlin/testData/StringTemplateComplex.kt b/plugins/uast-kotlin/testData/StringTemplateComplex.kt new file mode 100644 index 00000000000..5f4748f3f3a --- /dev/null +++ b/plugins/uast-kotlin/testData/StringTemplateComplex.kt @@ -0,0 +1,17 @@ +val muchRecur = "${"${"${"abc"}"}"}" + +val case4 = "a ${"literal"} z" + +val case5 = "a ${"literal"} ${"literal"} z" + +val literalInLiteral = "a ${"literal$case4"} z" + +val literalInLiteral2 = "a ${"literal$case4".repeat(4)} z" + +fun simpleForTemplate(i: Int = 0) = "$i" + +fun foo() { + println("$baz") + val template1 = "${simpleForTemplate()}" + val template2 = ".${simpleForTemplate()}" +} diff --git a/plugins/uast-kotlin/testData/StringTemplateComplex.log.txt b/plugins/uast-kotlin/testData/StringTemplateComplex.log.txt new file mode 100644 index 00000000000..06361791488 --- /dev/null +++ b/plugins/uast-kotlin/testData/StringTemplateComplex.log.txt @@ -0,0 +1,68 @@ +UFile (package = ) + UClass (name = StringTemplateComplexKt) + UField (name = muchRecur) + UAnnotation (fqName = org.jetbrains.annotations.NotNull) + ULiteralExpression (value = "abc") + UField (name = case4) + UAnnotation (fqName = org.jetbrains.annotations.NotNull) + UPolyadicExpression (operator = +) + ULiteralExpression (value = "a ") + ULiteralExpression (value = "literal") + ULiteralExpression (value = " z") + UField (name = case5) + UAnnotation (fqName = org.jetbrains.annotations.NotNull) + UPolyadicExpression (operator = +) + ULiteralExpression (value = "a ") + ULiteralExpression (value = "literal") + ULiteralExpression (value = " ") + ULiteralExpression (value = "literal") + ULiteralExpression (value = " z") + UField (name = literalInLiteral) + UAnnotation (fqName = org.jetbrains.annotations.NotNull) + UPolyadicExpression (operator = +) + ULiteralExpression (value = "a ") + UPolyadicExpression (operator = +) + ULiteralExpression (value = "literal") + USimpleNameReferenceExpression (identifier = case4) + ULiteralExpression (value = " z") + UField (name = literalInLiteral2) + UAnnotation (fqName = org.jetbrains.annotations.NotNull) + UPolyadicExpression (operator = +) + ULiteralExpression (value = "a ") + UQualifiedReferenceExpression + UPolyadicExpression (operator = +) + ULiteralExpression (value = "literal") + USimpleNameReferenceExpression (identifier = case4) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) + UIdentifier (Identifier (repeat)) + USimpleNameReferenceExpression (identifier = repeat) + ULiteralExpression (value = 4) + ULiteralExpression (value = " z") + UAnnotationMethod (name = getMuchRecur) + UAnnotationMethod (name = getCase4) + UAnnotationMethod (name = getCase5) + UAnnotationMethod (name = getLiteralInLiteral) + UAnnotationMethod (name = getLiteralInLiteral2) + UAnnotationMethod (name = simpleForTemplate) + UParameter (name = i) + UAnnotation (fqName = null) + ULiteralExpression (value = 0) + USimpleNameReferenceExpression (identifier = i) + UAnnotationMethod (name = foo) + UBlockExpression + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) + UIdentifier (Identifier (println)) + USimpleNameReferenceExpression (identifier = println) + USimpleNameReferenceExpression (identifier = baz) + UDeclarationsExpression + ULocalVariable (name = template1) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) + UIdentifier (Identifier (simpleForTemplate)) + USimpleNameReferenceExpression (identifier = simpleForTemplate) + UDeclarationsExpression + ULocalVariable (name = template2) + UPolyadicExpression (operator = +) + ULiteralExpression (value = ".") + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) + UIdentifier (Identifier (simpleForTemplate)) + USimpleNameReferenceExpression (identifier = simpleForTemplate) diff --git a/plugins/uast-kotlin/testData/StringTemplateComplex.render.txt b/plugins/uast-kotlin/testData/StringTemplateComplex.render.txt new file mode 100644 index 00000000000..9e44df2367e --- /dev/null +++ b/plugins/uast-kotlin/testData/StringTemplateComplex.render.txt @@ -0,0 +1,18 @@ +public final class StringTemplateComplexKt { + private static final var muchRecur: java.lang.String = "abc" + private static final var case4: java.lang.String = "a " + "literal" + " z" + private static final var case5: java.lang.String = "a " + "literal" + " " + "literal" + " z" + private static final var literalInLiteral: java.lang.String = "a " + "literal" + case4 + " z" + private static final var literalInLiteral2: java.lang.String = "a " + "literal" + case4.repeat(4) + " z" + public static final fun getMuchRecur() : java.lang.String = UastEmptyExpression + public static final fun getCase4() : java.lang.String = UastEmptyExpression + public static final fun getCase5() : java.lang.String = UastEmptyExpression + public static final fun getLiteralInLiteral() : java.lang.String = UastEmptyExpression + public static final fun getLiteralInLiteral2() : java.lang.String = UastEmptyExpression + public static final fun simpleForTemplate(i: int) : java.lang.String = i + public static final fun foo() : void { + println(baz) + var template1: java.lang.String = simpleForTemplate() + var template2: java.lang.String = "." + simpleForTemplate() + } +} diff --git a/plugins/uast-kotlin/tests/SimpleKotlinRenderLogTest.kt b/plugins/uast-kotlin/tests/SimpleKotlinRenderLogTest.kt index d8d50993b41..bae9099820e 100644 --- a/plugins/uast-kotlin/tests/SimpleKotlinRenderLogTest.kt +++ b/plugins/uast-kotlin/tests/SimpleKotlinRenderLogTest.kt @@ -1,5 +1,9 @@ package org.jetbrains.uast.test.kotlin +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiElementVisitor +import org.jetbrains.kotlin.psi.KtFile +import org.jetbrains.kotlin.psi.KtVisitor import org.junit.Test class SimpleKotlinRenderLogTest : AbstractKotlinRenderLogTest() { @@ -25,6 +29,8 @@ class SimpleKotlinRenderLogTest : AbstractKotlinRenderLogTest() { @Test fun testStringTemplate() = doTest("StringTemplate") + @Test fun testStringTemplateComplex() = doTest("StringTemplateComplex") + @Test fun testQualifiedConstructorCall() = doTest("QualifiedConstructorCall") @Test fun testPropertyDelegate() = doTest("PropertyDelegate") { testName, file -> check(testName, file, false) }