diff --git a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastBinaryOperator.kt b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastBinaryOperator.kt index 3205f7c0736..8f0bef29f0d 100644 --- a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastBinaryOperator.kt +++ b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastBinaryOperator.kt @@ -127,4 +127,8 @@ open class UastBinaryOperator(override val text: String): UastOperator { @JvmField val UNSIGNED_SHIFT_RIGHT_ASSIGN = AssignOperator(">>>=") } + + override fun toString(): String{ + return "UastBinaryOperator(text='$text')" + } } \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastCallKind.kt b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastCallKind.kt index 6336972fb24..43f4e295f9d 100644 --- a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastCallKind.kt +++ b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastCallKind.kt @@ -23,4 +23,8 @@ class UastCallKind(val name: String) { @JvmField val CONSTRUCTOR_CALL = UastCallKind("constructor_call") } + + override fun toString(): String{ + return "UastCallKind(name='$name')" + } } \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastClassKind.kt b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastClassKind.kt index d3be387a45c..6f6319c6533 100644 --- a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastClassKind.kt +++ b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastClassKind.kt @@ -35,4 +35,8 @@ open class UastClassKind(val text: String) { @JvmField val OBJECT = UastClassKind("object") } + + override fun toString(): String{ + return "UastClassKind(text='$text')" + } } \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastFunctionKind.kt b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastFunctionKind.kt index b589e576892..15463a0e618 100644 --- a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastFunctionKind.kt +++ b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastFunctionKind.kt @@ -25,4 +25,8 @@ open class UastFunctionKind(val text: String) { @JvmField val CONSTRUCTOR = UastFunctionKind("CONSTRUCTOR") } + + override fun toString(): String{ + return "UastFunctionKind(text='$text')" + } } \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastImportKind.kt b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastImportKind.kt index cb196680caf..790801a4360 100644 --- a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastImportKind.kt +++ b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastImportKind.kt @@ -25,4 +25,8 @@ class UastImportKind(val text: String) { @JvmField val MEMBER = UastImportKind("member") } + + override fun toString(): String{ + return "UastImportKind(text='$text')" + } } \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastModifier.kt b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastModifier.kt index 4417dc24dd4..ad63533cea1 100644 --- a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastModifier.kt +++ b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastModifier.kt @@ -28,4 +28,8 @@ class UastModifier(val name: String) { @JvmField val OVERRIDE = UastModifier("override") } + + override fun toString(): String{ + return "UastModifier(name='$name')" + } } diff --git a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastPostfixOperator.kt b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastPostfixOperator.kt index c6696537447..c2ef7e1913b 100644 --- a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastPostfixOperator.kt +++ b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastPostfixOperator.kt @@ -28,4 +28,8 @@ class UastPostfixOperator(override val text: String): UastOperator { @JvmField val UNKNOWN = UastPostfixOperator("") } + + override fun toString(): String{ + return "UastPostfixOperator(text='$text')" + } } diff --git a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastPrefixOperator.kt b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastPrefixOperator.kt index 2172aa41f04..3bdc50cc2c3 100644 --- a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastPrefixOperator.kt +++ b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastPrefixOperator.kt @@ -40,4 +40,8 @@ class UastPrefixOperator(override val text: String): UastOperator { @JvmField val UNKNOWN = UastPrefixOperator("") } + + override fun toString(): String{ + return "UastPrefixOperator(text='$text')" + } } diff --git a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastQualifiedExpressionAccessType.kt b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastQualifiedExpressionAccessType.kt index 2c88bc12477..4e4d01d94b7 100644 --- a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastQualifiedExpressionAccessType.kt +++ b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastQualifiedExpressionAccessType.kt @@ -20,4 +20,8 @@ class UastQualifiedExpressionAccessType(val name: String) { @JvmField val SIMPLE = UastQualifiedExpressionAccessType(".") } + + override fun toString(): String{ + return "UastQualifiedExpressionAccessType(name='$name')" + } } \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastSpecialExpressionKind.kt b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastSpecialExpressionKind.kt index 653eecef1d4..369d3f8e443 100644 --- a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastSpecialExpressionKind.kt +++ b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastSpecialExpressionKind.kt @@ -29,4 +29,8 @@ class UastSpecialExpressionKind(val name: String) { @JvmField val CONTINUE = UastSpecialExpressionKind("continue") } + + override fun toString(): String{ + return "UastSpecialExpressionKind(name='$name')" + } } diff --git a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastVariableKind.kt b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastVariableKind.kt index 891c3f09978..823bc4e86fb 100644 --- a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastVariableKind.kt +++ b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastVariableKind.kt @@ -26,4 +26,8 @@ class UastVariableKind(val name: String) { @JvmField val VALUE_PARAMETER = UastVariableKind("parameter") } + + override fun toString(): String{ + return "UastVariableKind(name='$name')" + } } \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastVisibility.kt b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastVisibility.kt index 88d84d507a6..188f5ee83ac 100644 --- a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastVisibility.kt +++ b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastVisibility.kt @@ -28,4 +28,8 @@ class UastVisibility(val name: String) { } fun isPublic() = this == PUBLIC + + override fun toString(): String { + return "UastVisibility(name='$name')" + } } \ No newline at end of file diff --git a/plugins/uast-java/test/org/jetbrains/uast/AbstractStructureTest.kt b/plugins/uast-java/test/org/jetbrains/uast/AbstractStructureTest.kt index 28971cd2a2a..ac2ccb1face 100644 --- a/plugins/uast-java/test/org/jetbrains/uast/AbstractStructureTest.kt +++ b/plugins/uast-java/test/org/jetbrains/uast/AbstractStructureTest.kt @@ -24,7 +24,7 @@ import java.io.File open class AbstractStructureTest : LightCodeInsightTestCase() { fun test(name: String) { - val testDir = File("testData") + val testDir = testDataPath val javaFile = File(testDir, "$name.java") val logFile = File(File(testDir, "log"), "$name.txt") val renderFile = File(File(testDir, "render"), "$name.txt") @@ -61,4 +61,6 @@ open class AbstractStructureTest : LightCodeInsightTestCase() { } private class NoTestFileException(file: File) : RuntimeException("Test file was generated: $file") + + override fun getTestDataPath() = "plugins/uast-java/testData" } \ No newline at end of file diff --git a/plugins/uast-java/testData/log/ControlStructures.txt b/plugins/uast-java/testData/log/ControlStructures.txt index 2c64a7de5f7..d0457ed6aed 100644 --- a/plugins/uast-java/testData/log/ControlStructures.txt +++ b/plugins/uast-java/testData/log/ControlStructures.txt @@ -1,6 +1,6 @@ UFile (package = null) - UClass (_Dummy_, enum = false, interface = false, object = false) - UClass (ControlStructures, enum = false, interface = false, object = false) + UClass (_Dummy_, kind = class) + UClass (ControlStructures, kind = class) UFunction (main, kind = function, paramCount = 1) UBlockExpression UIfExpression @@ -11,7 +11,7 @@ UFile (package = null) ULiteralExpression (0) UBlockExpression USpecialExpressionList (return) - + EmptyExpression UDeclarationsExpression UVariable (mode, kind = local) @@ -30,7 +30,7 @@ UFile (package = null) UQualifiedExpression USimpleReferenceExpression (System) USimpleReferenceExpression (out) - UFunctionCallExpression (FUNCTION_CALL, argCount = 1) + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) USimpleReferenceExpression (println) USimpleReferenceExpression (arg) UForExpression @@ -49,7 +49,7 @@ UFile (package = null) UQualifiedExpression USimpleReferenceExpression (System) USimpleReferenceExpression (out) - UFunctionCallExpression (FUNCTION_CALL, argCount = 1) + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) USimpleReferenceExpression (println) UBinaryExpression (+) UBinaryExpression (+) @@ -72,7 +72,7 @@ UFile (package = null) UQualifiedExpression USimpleReferenceExpression (System) USimpleReferenceExpression (out) - UFunctionCallExpression (FUNCTION_CALL, argCount = 1) + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) USimpleReferenceExpression (println) UBinaryExpression (+) ULiteralExpression ("Index ") @@ -93,7 +93,7 @@ UFile (package = null) UQualifiedExpression USimpleReferenceExpression (System) USimpleReferenceExpression (out) - UFunctionCallExpression (FUNCTION_CALL, argCount = 1) + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) USimpleReferenceExpression (println) USimpleReferenceExpression (i) UAssignmentExpression (+=) diff --git a/plugins/uast-java/testData/log/Lambda.txt b/plugins/uast-java/testData/log/Lambda.txt index b67dae3402b..de7e743deda 100644 --- a/plugins/uast-java/testData/log/Lambda.txt +++ b/plugins/uast-java/testData/log/Lambda.txt @@ -1,9 +1,9 @@ UFile (package = null) - UClass (_Dummy_, enum = false, interface = false, object = false) - UClass (Lambda, enum = false, interface = false, object = false) + UClass (_Dummy_, kind = class) + UClass (Lambda, kind = class) UFunction (example, kind = function, paramCount = 0) UBlockExpression - UFunctionCallExpression (FUNCTION_CALL, argCount = 2) + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 2) USimpleReferenceExpression (doJob) ULambdaExpression UVariable (arg, kind = parameter) @@ -18,13 +18,13 @@ UFile (package = null) UQualifiedExpression USimpleReferenceExpression (System) USimpleReferenceExpression (out) - UFunctionCallExpression (FUNCTION_CALL, argCount = 1) + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) USimpleReferenceExpression (println) UQualifiedExpression USimpleReferenceExpression (job) - UFunctionCallExpression (FUNCTION_CALL, argCount = 1) + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) USimpleReferenceExpression (doJob) USimpleReferenceExpression (arg) - UClass (Job, enum = false, interface = true, object = false) + UClass (Job, kind = interface) UFunction (doJob, kind = function, paramCount = 1) EmptyExpression \ No newline at end of file diff --git a/plugins/uast-java/testData/log/NestedClasses.txt b/plugins/uast-java/testData/log/NestedClasses.txt index d7582c99731..574500d9846 100644 --- a/plugins/uast-java/testData/log/NestedClasses.txt +++ b/plugins/uast-java/testData/log/NestedClasses.txt @@ -1,11 +1,10 @@ UFile (package = null) - UClass (_Dummy_, enum = false, interface = false, object = false) - UClass (NestedClasses, enum = false, interface = false, object = false) - UClass (Nested, enum = false, interface = false, object = false) + UClass (_Dummy_, kind = class) + UClass (NestedClasses, kind = class) + UClass (Nested, kind = class) UFunction (func1, kind = function, paramCount = 0) UBlockExpression - - UClass (Inner, enum = false, interface = false, object = false) + + UClass (Inner, kind = class) UFunction (func2, kind = function, paramCount = 0) - UBlockExpression - \ No newline at end of file + UBlockExpression \ No newline at end of file diff --git a/plugins/uast-java/testData/log/Simple.txt b/plugins/uast-java/testData/log/Simple.txt index 8e277c53c9e..a1a9d98476a 100644 --- a/plugins/uast-java/testData/log/Simple.txt +++ b/plugins/uast-java/testData/log/Simple.txt @@ -1,9 +1,9 @@ UFile (package = null) - UClass (_Dummy_, enum = false, interface = false, object = false) - UClass (Simple, enum = false, interface = false, object = false) + UClass (_Dummy_, kind = class) + UClass (Simple, kind = class) UVariable (name, kind = member) EmptyExpression - UFunction (Simple, kind = function, paramCount = 1) + UFunction (, kind = CONSTRUCTOR, paramCount = 1) UBlockExpression UAssignmentExpression (=) UQualifiedExpression diff --git a/plugins/uast-java/testData/log/SpecialExpressions.txt b/plugins/uast-java/testData/log/SpecialExpressions.txt index 2ce98d7fa93..6b9bc5154ec 100644 --- a/plugins/uast-java/testData/log/SpecialExpressions.txt +++ b/plugins/uast-java/testData/log/SpecialExpressions.txt @@ -1,6 +1,6 @@ UFile (package = null) - UClass (_Dummy_, enum = false, interface = false, object = false) - UClass (SpecialExpressions, enum = false, interface = false, object = false) + UClass (_Dummy_, kind = class) + UClass (SpecialExpressions, kind = class) UFunction (test, kind = function, paramCount = 0) UBlockExpression USpecialExpressionList (assert) @@ -20,7 +20,7 @@ UFile (package = null) UQualifiedExpression USimpleReferenceExpression (System) USimpleReferenceExpression (out) - UFunctionCallExpression (FUNCTION_CALL, argCount = 1) + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) USimpleReferenceExpression (println) ULiteralExpression ("A") UDeclarationsExpression @@ -41,7 +41,7 @@ UFile (package = null) ULiteralExpression (3) UBlockExpression USpecialExpressionList (break) - + EmptyExpression UIfExpression UBinaryExpression (===) @@ -51,20 +51,20 @@ UFile (package = null) ULiteralExpression (0) UBlockExpression USpecialExpressionList (continue) - + EmptyExpression UPostfixExpression (--) USimpleReferenceExpression (a) UQualifiedExpression UThisExpression - UFunctionCallExpression (FUNCTION_CALL, argCount = 0) + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 0) USimpleReferenceExpression (test) - + UQualifiedExpression USuperExpression - UFunctionCallExpression (FUNCTION_CALL, argCount = 0) + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 0) USimpleReferenceExpression (hashCode) - + UDeclarationsExpression UVariable (x, kind = local) EmptyExpression @@ -78,7 +78,7 @@ UFile (package = null) USimpleReferenceExpression (x) ULiteralExpression ("1") USpecialExpressionList (break) - + UExpressionSwitchClauseExpression ULiteralExpression (3) UAssignmentExpression (=) @@ -97,16 +97,16 @@ UFile (package = null) UQualifiedExpression UQualifiedExpression USimpleReferenceExpression (System) - UFunctionCallExpression (FUNCTION_CALL, argCount = 2) + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 2) USimpleReferenceExpression (getProperty) ULiteralExpression ("abc") ULiteralExpression ("") - UFunctionCallExpression (FUNCTION_CALL, argCount = 1) + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) USimpleReferenceExpression (equals) ULiteralExpression ("1") UBlockExpression USpecialExpressionList (throw) - UFunctionCallExpression (CONSTRUCTOR_CALL, argCount = 1) + UFunctionCallExpression (UastCallKind(name='constructor_call'), argCount = 1) ULiteralExpression ("Err") EmptyExpression @@ -114,7 +114,7 @@ UFile (package = null) UBlockExpression UQualifiedExpression USimpleReferenceExpression (Thread) - UFunctionCallExpression (FUNCTION_CALL, argCount = 1) + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) USimpleReferenceExpression (sleep) ULiteralExpression (1000) UCatchClause UBlockExpression diff --git a/plugins/uast-java/testData/render/ControlStructures.txt b/plugins/uast-java/testData/render/ControlStructures.txt index daf9a294e75..6d92c6d44a8 100644 --- a/plugins/uast-java/testData/render/ControlStructures.txt +++ b/plugins/uast-java/testData/render/ControlStructures.txt @@ -1,33 +1,33 @@ default class _Dummy_ { - default inner class ControlStructures { - public fun main(args: java.lang.String[]): void { + default class ControlStructures { + public fun main(args: String[]): void { if (args.length === 0) { - return + return } - + var mode: String = (args.length === 1) ? ("singleArg") : ("multiArgs") for (arg : args) { System.out.println(arg) } - + for (var i: int = 0; i < args.length; ++i) { System.out.println(i + ": " + args[i]) } - + var i: int = 0 while (i < args.length) { System.out.println("Index " + i) i++ } - + i = 0 do { System.out.println(i) i += 1 } while (i < args.length) - + } - + } -} +} \ No newline at end of file diff --git a/plugins/uast-java/testData/render/Lambda.txt b/plugins/uast-java/testData/render/Lambda.txt index 87eeb5d3e65..f3a04eb828a 100644 --- a/plugins/uast-java/testData/render/Lambda.txt +++ b/plugins/uast-java/testData/render/Lambda.txt @@ -1,5 +1,5 @@ default class _Dummy_ { - default inner class Lambda { + default class Lambda { default fun example(): void { doJob({ arg: String -> arg + arg @@ -11,7 +11,7 @@ default class _Dummy_ { } } - default abstract interface Job { + default abstract static interface Job { public fun doJob(arg: String): String = EmptyExpression } } \ No newline at end of file diff --git a/plugins/uast-java/testData/render/NestedClasses.txt b/plugins/uast-java/testData/render/NestedClasses.txt index 155a1de6d15..3a661e459ea 100644 --- a/plugins/uast-java/testData/render/NestedClasses.txt +++ b/plugins/uast-java/testData/render/NestedClasses.txt @@ -1,14 +1,14 @@ default class _Dummy_ { - default inner class NestedClasses { - public class Nested { + default class NestedClasses { + public static class Nested { default fun func1(): void { } - + } - public inner class Inner { + public class Inner { default fun func2(): void { } - + } } -} +} \ No newline at end of file diff --git a/plugins/uast-java/testData/render/Simple.txt b/plugins/uast-java/testData/render/Simple.txt index 5727e7fdbaf..ac9d4914508 100644 --- a/plugins/uast-java/testData/render/Simple.txt +++ b/plugins/uast-java/testData/render/Simple.txt @@ -1,18 +1,18 @@ default class _Dummy_ { - default inner class Simple { + default class Simple { var name: String - - public fun Simple(name: String) { + + public fun (name: String) { this.name = name } - + public fun getName(): String { return name } - + public fun setName(name: String): void { this.name = name } - + } -} +} \ No newline at end of file diff --git a/plugins/uast-java/testData/render/SpecialExpressions.txt b/plugins/uast-java/testData/render/SpecialExpressions.txt index 2120337706a..fd66784c6cf 100644 --- a/plugins/uast-java/testData/render/SpecialExpressions.txt +++ b/plugins/uast-java/testData/render/SpecialExpressions.txt @@ -1,68 +1,68 @@ default class _Dummy_ { - default inner class SpecialExpressions { + default class SpecialExpressions { default fun test(): boolean { assert 5 > 3 : EmptyExpression assert 5 > 3 : "Message" synchronized this : { System.out.println("A") } - + var a: int = 5 var b: int = 7 var c: int while (a > 0) { if (a === 3) { - break + break } - + if (a % 5 === 0) { - continue + continue } - + a-- } - + this.test() super.hashCode() var x: String switch (a) { - case 1: + 1 -> { x = "1" - break + break } - - case 3: + + 3 -> x = "3" - case 4: + 4 -> x = "4" - else: + else -> x = "" } - - + + if (System.getProperty("abc", "").equals("1")) { - throw ("Err") + throw AssertionError("Err") } - + try { Thread.sleep(1000) } - + catch (e) { } - + finally { a = 3 } - + { a = 5 } - + return true } - + } -} +} \ No newline at end of file diff --git a/plugins/uast-kotlin/testData/log/ControlStructures.txt b/plugins/uast-kotlin/testData/log/ControlStructures.txt index 727f223f81a..456fde57d90 100644 --- a/plugins/uast-kotlin/testData/log/ControlStructures.txt +++ b/plugins/uast-kotlin/testData/log/ControlStructures.txt @@ -1,11 +1,202 @@ UFile (package = null) - UClass (ControlStructures, enum = false, interface = false, object = false) + UClass (ControlStructures, kind = class) + UFunction (, kind = CONSTRUCTOR, paramCount = 0) + EmptyExpression UFunction (test, kind = function, paramCount = 0) UBlockExpression + UIfExpression + UBinaryExpression (>) + ULiteralExpression (5) + ULiteralExpression (3) + UBlockExpression + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) + USimpleReferenceExpression (println) + ULiteralExpression ("5 > 3") + + UForEachExpression (c) + ULiteralExpression ("ABC") + UBlockExpression + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) + USimpleReferenceExpression (println) + USimpleReferenceExpression (c) + UForEachExpression (c) + ULiteralExpression ("DEF") + UBlockExpression + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) + USimpleReferenceExpression (println) + UQualifiedExpression + USimpleReferenceExpression (c) + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 0) + USimpleReferenceExpression (toByte) + + UDeclarationsExpression + UVariable (i, kind = local) + ULiteralExpression (5) + UWhileExpression + UBinaryExpression (>) + USimpleReferenceExpression (i) + ULiteralExpression (0) + UBlockExpression + UPostfixExpression (--) + USimpleReferenceExpression (i) + UIfExpression + UBinaryExpression (==) + USimpleReferenceExpression (i) + ULiteralExpression (3) + USpecialExpressionList (break) + + + UIfExpression + UBinaryExpression (==) + USimpleReferenceExpression (i) + ULiteralExpression (2) + UBlockExpression + USpecialExpressionList (continue) + + + UBinaryExpression (=) + USimpleReferenceExpression (i) + ULiteralExpression (5) + UDoWhileExpression + UBinaryExpression (>) + USimpleReferenceExpression (i) + ULiteralExpression (0) + UBlockExpression + UBinaryExpression (-=) + USimpleReferenceExpression (i) + ULiteralExpression (1) + UQualifiedExpression + ULiteralExpression ("ABC") + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) + USimpleReferenceExpression (forEach) + ULambdaExpression + + UBlockExpression + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) + USimpleReferenceExpression (println) + UArrayAccessExpression + UQualifiedExpression + USimpleReferenceExpression (it) + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 0) + USimpleReferenceExpression (toString) + + ULiteralExpression (0) + UQualifiedExpression + UQualifiedExpression + ULiteralExpression ("ABC") + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) + USimpleReferenceExpression (zip) + ULiteralExpression ("DEF") + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) + USimpleReferenceExpression (forEach) + ULambdaExpression + + UBlockExpression + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) + USimpleReferenceExpression (println) + UBinaryExpression (+) + UBinaryExpression (+) + UQualifiedExpression + USimpleReferenceExpression (it) + USimpleReferenceExpression (first) + ULiteralExpression (" ") + UQualifiedExpression + USimpleReferenceExpression (it) + USimpleReferenceExpression (second) + UDeclarationsExpression + UVariable (var1496943053, kind = local) + UQualifiedExpression + ULiteralExpression ("ABC") + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) + USimpleReferenceExpression (zip) + ULiteralExpression ("DEF") + UVariable (a, kind = local) + UQualifiedExpression + USimpleReferenceExpression (var1496943053) + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 0) + USimpleReferenceExpression (component1) + + UVariable (b, kind = local) + UQualifiedExpression + USimpleReferenceExpression (var1496943053) + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 0) + USimpleReferenceExpression (component2) + + UDeclarationsExpression + UVariable (value, kind = local) + UIfExpression + UBinaryExpression (>) + ULiteralExpression (5) + ULiteralExpression (3) + ULiteralExpression ("a") + ULiteralExpression ("b") + UDeclarationsExpression + UVariable (list, kind = local) + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) + USimpleReferenceExpression (listOf) + ULiteralExpression ("A") + UDeclarationsExpression + UVariable (list2, kind = local) + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) + USimpleReferenceExpression (listOf) + ULiteralExpression ("A") + UDeclarationsExpression + UVariable (type, kind = local) + USwitchExpression + USimpleReferenceExpression (value) + USpecialExpressionList (when) + KotlinUSwitchEntry + USpecialExpressionList (when_entry) + ULiteralExpression ("inlist") + USpecialExpressionList (break) + + KotlinUSwitchEntry + USpecialExpressionList (when_entry) + ULiteralExpression ("notinlist2") + USpecialExpressionList (break) + + KotlinUSwitchEntry + USpecialExpressionList (when_entry) + ULiteralExpression ("string") + USpecialExpressionList (break) + + KotlinUSwitchEntry + USpecialExpressionList (when_entry) + ULiteralExpression ("cs") + USpecialExpressionList (break) + + KotlinUSwitchEntry + USpecialExpressionList (when_entry) + ULiteralExpression ("unknown") + USpecialExpressionList (break) + UDeclarationsExpression UVariable (x, kind = local) - UFunctionCallExpression (FUNCTION_CALL, argCount = 1) - USimpleReferenceExpression (listOf) - ULiteralExpression ("ABC") + USwitchExpression + + USpecialExpressionList (when) + KotlinUSwitchEntry + USpecialExpressionList (when_entry) + ULiteralExpression ("B") + USpecialExpressionList (break) + + KotlinUSwitchEntry + USpecialExpressionList (when_entry) + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) + USimpleReferenceExpression (println) + ULiteralExpression ("A") + ULiteralExpression ("Q") + USpecialExpressionList (break) + + KotlinUSwitchEntry + USpecialExpressionList (when_entry) + ULiteralExpression ("!") + USpecialExpressionList (break) + + KotlinUSwitchEntry + USpecialExpressionList (when_entry) + ULiteralExpression ("A") + USpecialExpressionList (break) + USpecialExpressionList (return) - ULiteralExpression (false) + ULiteralExpression (false) \ No newline at end of file diff --git a/plugins/uast-kotlin/testData/log/Declarations.txt b/plugins/uast-kotlin/testData/log/Declarations.txt index 297a4ee6992..b2240295f9a 100644 --- a/plugins/uast-kotlin/testData/log/Declarations.txt +++ b/plugins/uast-kotlin/testData/log/Declarations.txt @@ -1,11 +1,17 @@ UFile (package = null) - UClass (Declarations, enum = false, interface = false, object = false) + UClass (Declarations, kind = class) + UFunction (, kind = CONSTRUCTOR, paramCount = 0) + EmptyExpression UVariable (a, kind = member) ULiteralExpression ("a") - UClass (NestedClass, enum = false, interface = false, object = false) + UClass (NestedClass, kind = class) + UFunction (, kind = CONSTRUCTOR, paramCount = 0) + EmptyExpression UVariable (b, kind = member) ULiteralExpression ("b") - UClass (InnerClass, enum = false, interface = false, object = false) + UClass (InnerClass, kind = class) + UFunction (, kind = CONSTRUCTOR, paramCount = 0) + EmptyExpression UVariable (c, kind = member) USimpleReferenceExpression (a) UFunction (func, kind = function, paramCount = 2) @@ -18,4 +24,4 @@ UFile (package = null) ULiteralExpression (1) UQualifiedExpression USimpleReferenceExpression (b) - USimpleReferenceExpression (length) + USimpleReferenceExpression (length) \ No newline at end of file diff --git a/plugins/uast-kotlin/testData/log/Simple.txt b/plugins/uast-kotlin/testData/log/Simple.txt index 6496ac3caa1..c2c6f6a0ddf 100644 --- a/plugins/uast-kotlin/testData/log/Simple.txt +++ b/plugins/uast-kotlin/testData/log/Simple.txt @@ -1,19 +1,25 @@ UFile (package = null) - UClass (Simple, enum = false, interface = false, object = false) + UClass (Simple, kind = class) + UFunction (, kind = CONSTRUCTOR, paramCount = 0) + EmptyExpression UVariable (a, kind = member) UBinaryExpression (+) UBinaryExpression (+) ULiteralExpression ("text") ULiteralExpression ("other") ULiteralExpression ("text") + UVariable (b, kind = member) + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) + USimpleReferenceExpression (listOf) + ULiteralExpression ("A") UFunction (test, kind = function, paramCount = 0) UBlockExpression UQualifiedExpression UQualifiedExpression USimpleReferenceExpression (System) USimpleReferenceExpression (out) - UFunctionCallExpression (FUNCTION_CALL, argCount = 1) + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) USimpleReferenceExpression (println) UBinaryExpression (/) ULiteralExpression (5.0f) - ULiteralExpression (2) + ULiteralExpression (2) \ No newline at end of file diff --git a/plugins/uast-kotlin/testData/render/ControlStructures.txt b/plugins/uast-kotlin/testData/render/ControlStructures.txt index 6bc8e8b5a80..03e31ea7e1b 100644 --- a/plugins/uast-kotlin/testData/render/ControlStructures.txt +++ b/plugins/uast-kotlin/testData/render/ControlStructures.txt @@ -1,6 +1,98 @@ -public class ControlStructures { +public static class ControlStructures { + public fun () = EmptyExpression public fun test(): Boolean { - var x: List = listOf("ABC") + if (5 > 3) { + println("5 > 3") + } + + for (c : "ABC") { + println(c) + } + + for (c : "DEF") { + println(c.toByte()) + } + + var i: Int = 5 + while (i > 0) { + i-- + if (i == 3) break + if (i == 2) { + continue + } + + } + + i = 5 + do { + i -= 1 + } + while (i > 0) + + "ABC".forEach({ + println(it.toString()[0]) + }) + "ABC".zip("DEF").forEach({ + println(it.first + " " + it.second) + }) + var var1496943053: = "ABC".zip("DEF") + var a: Pair = var1496943053.component1() + var b: Pair = var1496943053.component2() + var value: String = if (5 > 3) "a" else "b" + var list: List = listOf("A") + var list2: List = listOf("A") + var type: String = switch (value) { + it in list -> { + "inlist" + break + } + + it in list2 -> { + "notinlist2" + break + } + + (it) is null -> { + "string" + break + } + + (it) is null -> { + "cs" + break + } + + else -> { + "unknown" + break + } + + } + + var x: String = switch { + value == "b" -> { + "B" + break + } + + 5 % 2 == 0 -> { + println("A") + "Q" + break + } + + false -> { + "!" + break + } + + else -> { + "A" + break + } + + } + return false } diff --git a/plugins/uast-kotlin/testData/render/Declarations.txt b/plugins/uast-kotlin/testData/render/Declarations.txt index 097cf604522..88c905cfb49 100644 --- a/plugins/uast-kotlin/testData/render/Declarations.txt +++ b/plugins/uast-kotlin/testData/render/Declarations.txt @@ -1,11 +1,14 @@ -public class Declarations { +public static class Declarations { + public fun () = EmptyExpression var a: String = "a" - public class NestedClass { + public static class NestedClass { + public fun () = EmptyExpression var b: String = "b" } - public inner class InnerClass { + public class InnerClass { + public fun () = EmptyExpression var c: CharSequence = a } diff --git a/plugins/uast-kotlin/testData/render/Simple.txt b/plugins/uast-kotlin/testData/render/Simple.txt index 24f2786c257..b8256ae00b3 100644 --- a/plugins/uast-kotlin/testData/render/Simple.txt +++ b/plugins/uast-kotlin/testData/render/Simple.txt @@ -1,6 +1,8 @@ -public class Simple { +public static class Simple { + public fun () = EmptyExpression var a: String = "text" + "other" + "text" - val b = listOf("A") + + var b: List = listOf("A") public fun test(): Unit { System.out.println(5.0f / 2)