diff --git a/plugins/uast-kotlin/testData/CycleInTypeParameters.types.txt.172 b/plugins/uast-kotlin/testData/CycleInTypeParameters.types.txt.172 new file mode 100644 index 00000000000..abfb578c83c --- /dev/null +++ b/plugins/uast-kotlin/testData/CycleInTypeParameters.types.txt.172 @@ -0,0 +1,10 @@ +UFile (package = ) [public final class CycleInTypeParametersKt {...] + UClass (name = CycleInTypeParametersKt) [public final class CycleInTypeParametersKt {...}] + UField (name = a) [private static final var a: Device = null as? Device] + UAnnotation (fqName = org.jetbrains.annotations.Nullable) [@org.jetbrains.annotations.Nullable] + UBinaryExpressionWithType [null as? Device] : PsiType:Device + ULiteralExpression (value = null) [null] : PsiType:Void + UTypeReferenceExpression (name = Device) [Device] + UAnnotationMethod (name = getA) [public static final fun getA() : Device = UastEmptyExpression] + UClass (name = Device) [public final class Device {...}] + UAnnotationMethod (name = Device) [public fun Device() = UastEmptyExpression] diff --git a/plugins/uast-kotlin/testData/Elvis.render.txt.172 b/plugins/uast-kotlin/testData/Elvis.render.txt.172 index 2554f7d42fa..558f74c7731 100644 --- a/plugins/uast-kotlin/testData/Elvis.render.txt.172 +++ b/plugins/uast-kotlin/testData/Elvis.render.txt.172 @@ -1,10 +1,6 @@ public final class ElvisKt { - public static final fun foo(@org.jetbrains.annotations.NotNull bar: java.lang.String) : java.lang.String { - return null - } - public static final fun bar() : int { - return 42 - } + public static final fun foo(bar: java.lang.String) : java.lang.String = null + public static final fun bar() : int = 42 public static final fun baz() : java.lang.String { return elvis { var var243c51a0: java.lang.String = elvis { diff --git a/plugins/uast-kotlin/testData/EnumValueMembers.render.txt.172 b/plugins/uast-kotlin/testData/EnumValueMembers.render.txt.172 index 9544478939e..a4325db460b 100644 --- a/plugins/uast-kotlin/testData/EnumValueMembers.render.txt.172 +++ b/plugins/uast-kotlin/testData/EnumValueMembers.render.txt.172 @@ -3,8 +3,8 @@ public enum Style { public fun getExitAnimation() : java.lang.String = "bar" fun SHEET() = UastEmptyExpression } - @org.jetbrains.annotations.NotNull private final var value: java.lang.String + private final var value: java.lang.String public abstract fun getExitAnimation() : java.lang.String = UastEmptyExpression public final fun getValue() : java.lang.String = UastEmptyExpression - protected fun Style(@org.jetbrains.annotations.NotNull value: java.lang.String) = UastEmptyExpression + protected fun Style(value: java.lang.String) = UastEmptyExpression } diff --git a/plugins/uast-kotlin/testData/LocalVariableWithAnnotation.kt.172 b/plugins/uast-kotlin/testData/LocalVariableWithAnnotation.kt.172 new file mode 100644 index 00000000000..e69de29bb2d diff --git a/plugins/uast-kotlin/testData/LocalVariableWithAnnotation.log.txt.172 b/plugins/uast-kotlin/testData/LocalVariableWithAnnotation.log.txt.172 new file mode 100644 index 00000000000..e69de29bb2d diff --git a/plugins/uast-kotlin/testData/LocalVariableWithAnnotation.render.txt.172 b/plugins/uast-kotlin/testData/LocalVariableWithAnnotation.render.txt.172 index 9ea15bbe75e..e69de29bb2d 100644 --- a/plugins/uast-kotlin/testData/LocalVariableWithAnnotation.render.txt.172 +++ b/plugins/uast-kotlin/testData/LocalVariableWithAnnotation.render.txt.172 @@ -1,8 +0,0 @@ -public final class LocalVariableWithAnnotationKt { - public static final fun foo() : void { - @TestAnnotation var bar: = "lorem ipsum" - } -} - -public abstract annotation TestAnnotation { -} diff --git a/plugins/uast-kotlin/testData/PropertyAccessors.render.txt.172 b/plugins/uast-kotlin/testData/PropertyAccessors.render.txt.172 new file mode 100644 index 00000000000..91e56d20bb0 --- /dev/null +++ b/plugins/uast-kotlin/testData/PropertyAccessors.render.txt.172 @@ -0,0 +1,9 @@ +public final class PropertyTest { + public final fun getStringRepresentation() : java.lang.String = this.toString() + public final fun setStringRepresentation(value: java.lang.String) : void { + setDataFromString(value) + } + public final fun setDataFromString(data: java.lang.String) : void { + } + public fun PropertyTest() = UastEmptyExpression +} diff --git a/plugins/uast-kotlin/testData/PropertyDelegate.render.txt.172 b/plugins/uast-kotlin/testData/PropertyDelegate.render.txt.172 index d496ac695d7..ce4553ea29c 100644 --- a/plugins/uast-kotlin/testData/PropertyDelegate.render.txt.172 +++ b/plugins/uast-kotlin/testData/PropertyDelegate.render.txt.172 @@ -1,5 +1,5 @@ public final class PropertyDelegateKt { - @org.jetbrains.annotations.NotNull private static final var sdCardPath$delegate: kotlin.Lazy + private static final var sdCardPath$delegate: kotlin.Lazy public static final fun getSdCardPath() : java.lang.String = UastEmptyExpression public static final fun localPropertyTest() : void { var sdCardPathLocal: java.lang.String diff --git a/plugins/uast-kotlin/testData/PropertyInitializer.render.txt.172 b/plugins/uast-kotlin/testData/PropertyInitializer.render.txt.172 new file mode 100644 index 00000000000..7d34908b700 --- /dev/null +++ b/plugins/uast-kotlin/testData/PropertyInitializer.render.txt.172 @@ -0,0 +1,8 @@ +public final class TestPropertyInitializer { + private var withSetter: java.lang.String = "/sdcard" + public final fun getWithSetter() : java.lang.String = field + public final fun setWithSetter(p: java.lang.String) : void { + field = p + } + public fun TestPropertyInitializer() = UastEmptyExpression +} diff --git a/plugins/uast-kotlin/testData/PropertyInitializerWithoutSetter.render.txt.172 b/plugins/uast-kotlin/testData/PropertyInitializerWithoutSetter.render.txt.172 new file mode 100644 index 00000000000..9a5b0de74c5 --- /dev/null +++ b/plugins/uast-kotlin/testData/PropertyInitializerWithoutSetter.render.txt.172 @@ -0,0 +1,5 @@ +public final class PropertyInitializerWithoutSetterKt { + private static var withoutSetter: java.lang.String = "/sdcard" + public static final fun getWithoutSetter() : java.lang.String = field + public static final fun setWithoutSetter(p: java.lang.String) : void = UastEmptyExpression +} diff --git a/plugins/uast-kotlin/testData/Simple.render.txt.172 b/plugins/uast-kotlin/testData/Simple.render.txt.172 new file mode 100644 index 00000000000..b354c83cca5 --- /dev/null +++ b/plugins/uast-kotlin/testData/Simple.render.txt.172 @@ -0,0 +1,8 @@ +public final class Simple { + private final var property: java.lang.String = "Mary" + public final fun method() : void { + println("Hello, world!") + } + public final fun getProperty() : java.lang.String = UastEmptyExpression + public fun Simple() = UastEmptyExpression +} diff --git a/plugins/uast-kotlin/testData/Simple.values.txt.172 b/plugins/uast-kotlin/testData/Simple.values.txt.172 new file mode 100644 index 00000000000..1e41b670245 --- /dev/null +++ b/plugins/uast-kotlin/testData/Simple.values.txt.172 @@ -0,0 +1,13 @@ +UFile (package = ) [public final class Simple {...] + UClass (name = Simple) [public final class Simple {...}] + UField (name = property) [private final var property: java.lang.String = "Mary"] + UAnnotation (fqName = org.jetbrains.annotations.NotNull) [@org.jetbrains.annotations.NotNull] + ULiteralExpression (value = "Mary") ["Mary"] = "Mary" + UAnnotationMethod (name = method) [public final fun method() : void {...}] + UBlockExpression [{...}] = external println("Hello, world!")("Hello, world!") + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) [println("Hello, world!")] = external println("Hello, world!")("Hello, world!") + UIdentifier (Identifier (println)) [UIdentifier (Identifier (println))] + USimpleNameReferenceExpression (identifier = println) [println] = external println("Hello, world!")("Hello, world!") + ULiteralExpression (value = "Hello, world!") ["Hello, world!"] = "Hello, world!" + UAnnotationMethod (name = getProperty) [public final fun getProperty() : java.lang.String = UastEmptyExpression] + UAnnotationMethod (name = Simple) [public fun Simple() = UastEmptyExpression] diff --git a/plugins/uast-kotlin/testData/StringTemplate.render.txt.172 b/plugins/uast-kotlin/testData/StringTemplate.render.txt.172 new file mode 100644 index 00000000000..2d56a3954b6 --- /dev/null +++ b/plugins/uast-kotlin/testData/StringTemplate.render.txt.172 @@ -0,0 +1,10 @@ +public final class StringTemplateKt { + private static final var foo: java.lang.String = "lorem" + 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 + 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 +} diff --git a/plugins/uast-kotlin/testData/UnexpectedContainerException.types.txt.172 b/plugins/uast-kotlin/testData/UnexpectedContainerException.types.txt.172 index abfcfc69e45..6ada6272f88 100644 --- a/plugins/uast-kotlin/testData/UnexpectedContainerException.types.txt.172 +++ b/plugins/uast-kotlin/testData/UnexpectedContainerException.types.txt.172 @@ -1,13 +1,13 @@ UFile (package = ) [public abstract interface Callback {...] UClass (name = Callback) [public abstract interface Callback {...}] - UAnnotationMethod (name = onError) [public abstract fun onError(@org.jetbrains.annotations.NotNull throwable: java.lang.Throwable) : void = UastEmptyExpression] - UParameter (name = throwable) [@org.jetbrains.annotations.NotNull var throwable: java.lang.Throwable] + UAnnotationMethod (name = onError) [public abstract fun onError(throwable: java.lang.Throwable) : void = UastEmptyExpression] + UParameter (name = throwable) [var throwable: java.lang.Throwable] UAnnotation (fqName = org.jetbrains.annotations.NotNull) [@org.jetbrains.annotations.NotNull] UClass (name = Model) [public final class Model {...}] - UAnnotationMethod (name = crashMe) [public final fun crashMe(@org.jetbrains.annotations.NotNull clazz: java.lang.Class, @org.jetbrains.annotations.NotNull factory: kotlin.jvm.functions.Function0) : void {...}] - UParameter (name = clazz) [@org.jetbrains.annotations.NotNull var clazz: java.lang.Class] + UAnnotationMethod (name = crashMe) [public final fun crashMe(clazz: java.lang.Class, factory: kotlin.jvm.functions.Function0) : void {...}] + UParameter (name = clazz) [var clazz: java.lang.Class] UAnnotation (fqName = org.jetbrains.annotations.NotNull) [@org.jetbrains.annotations.NotNull] - UParameter (name = factory) [@org.jetbrains.annotations.NotNull var factory: kotlin.jvm.functions.Function0] + UParameter (name = factory) [var factory: kotlin.jvm.functions.Function0] UAnnotation (fqName = org.jetbrains.annotations.NotNull) [@org.jetbrains.annotations.NotNull] UBlockExpression [{...}] : PsiType:Void UThrowExpression [throw ()] : PsiType:Void @@ -27,8 +27,8 @@ UFile (package = ) [public abstract interface Callback {...] UBlockExpression [{...}] UObjectLiteralExpression [anonymous object : Callback {... }] : PsiType:Callback UClass (name = null) [final class null {...}] - UAnnotationMethod (name = onError) [public fun onError(@org.jetbrains.annotations.NotNull throwable: java.lang.Throwable) : void {...}] - UParameter (name = throwable) [@org.jetbrains.annotations.NotNull var throwable: java.lang.Throwable] + UAnnotationMethod (name = onError) [public fun onError(throwable: java.lang.Throwable) : void {...}] + UParameter (name = throwable) [var throwable: java.lang.Throwable] UAnnotation (fqName = org.jetbrains.annotations.NotNull) [@org.jetbrains.annotations.NotNull] UBlockExpression [{...}] : PsiType:Void UThrowExpression [throw ("")] : PsiType:Void diff --git a/plugins/uast-kotlin/testData/WhenIs.render.txt.172 b/plugins/uast-kotlin/testData/WhenIs.render.txt.172 new file mode 100644 index 00000000000..63513a3aac2 --- /dev/null +++ b/plugins/uast-kotlin/testData/WhenIs.render.txt.172 @@ -0,0 +1,15 @@ +public final class WhenIsKt { + public static final fun foo(bar: java.lang.Object) : java.lang.String = switch (bar) { + it is java.lang.String -> { + bar + break + } + + it !is java.lang.String -> { + "" + break + } + + } + +} diff --git a/plugins/uast-kotlin/tests/SimpleKotlinRenderLogTest.kt.172 b/plugins/uast-kotlin/tests/SimpleKotlinRenderLogTest.kt.172 new file mode 100644 index 00000000000..2542f9a6c14 --- /dev/null +++ b/plugins/uast-kotlin/tests/SimpleKotlinRenderLogTest.kt.172 @@ -0,0 +1,76 @@ +package org.jetbrains.uast.test.kotlin + +import org.junit.Test + +class SimpleKotlinRenderLogTest : AbstractKotlinRenderLogTest() { + @Test fun testLocalDeclarations() = doTest("LocalDeclarations") + + @Test fun testSimple() = doTest("Simple") + + @Test fun testWhenIs() = doTest("WhenIs") + + @Test fun testDefaultImpls() = doTest("DefaultImpls") + + @Test fun testElvis() = doTest("Elvis") + + @Test fun testPropertyAccessors() = doTest("PropertyAccessors") + + @Test fun testPropertyInitializer() = doTest("PropertyInitializer") + + @Test fun testPropertyInitializerWithoutSetter() = doTest("PropertyInitializerWithoutSetter") + + @Test fun testAnnotationParameters() = doTest("AnnotationParameters") + + @Test fun testEnumValueMembers() = doTest("EnumValueMembers") + + @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) } + + @Test fun testPropertyWithAnnotation() = doTest("PropertyWithAnnotation") + + @Test fun testIfStatement() = doTest("IfStatement") + + @Test fun testInnerClasses() = doTest("InnerClasses") + + @Test fun testSimpleScript() = doTest("SimpleScript") { testName, file -> check(testName, file, false) } + + @Test fun testDestructuringDeclaration() = doTest("DestructuringDeclaration") + + @Test fun testDefaultParameterValues() = doTest("DefaultParameterValues") + + @Test fun testParameterPropertyWithAnnotation() = doTest("ParameterPropertyWithAnnotation") + + @Test fun testParametersWithDefaultValues() = doTest("ParametersWithDefaultValues") + + @Test + fun testUnexpectedContainer() = doTest("UnexpectedContainerException") + + @Test + fun testWhenStringLiteral() = doTest("WhenStringLiteral") + + @Test + fun testWhenAndDestructing() = doTest("WhenAndDestructing") { testName, file -> check(testName, file, false) } + + @Test + fun testSuperCalls() = doTest("SuperCalls") + + @Test + fun testConstructors() = doTest("Constructors") + + @Test + fun testClassAnnotation() = doTest("ClassAnnotation") + + @Test + fun testReceiverFun() = doTest("ReceiverFun") + + @Test + fun testAnonymous() = doTest("Anonymous") + + @Test + fun testAnnotationComplex() = doTest("AnnotationComplex") +}