Implement Kotlin Script support in UAST
#KT-18353 Fixed
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
class Foo {
|
||||
class Bar(val a: Int, val b: Int) {
|
||||
fun getAPlusB() = a + b
|
||||
class Baz {
|
||||
fun doNothing() = Unit
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
UFile (package = )
|
||||
UClass (name = Foo)
|
||||
UAnnotationMethod (name = Foo)
|
||||
UClass (name = Bar)
|
||||
UField (name = a)
|
||||
UAnnotation (fqName = null)
|
||||
UField (name = b)
|
||||
UAnnotation (fqName = null)
|
||||
UAnnotationMethod (name = getAPlusB)
|
||||
UBinaryExpression (operator = +)
|
||||
USimpleNameReferenceExpression (identifier = a)
|
||||
USimpleNameReferenceExpression (identifier = b)
|
||||
UAnnotationMethod (name = getA)
|
||||
UAnnotationMethod (name = getB)
|
||||
UAnnotationMethod (name = Bar)
|
||||
UParameter (name = a)
|
||||
UAnnotation (fqName = null)
|
||||
UParameter (name = b)
|
||||
UAnnotation (fqName = null)
|
||||
UClass (name = Baz)
|
||||
UAnnotationMethod (name = doNothing)
|
||||
USimpleNameReferenceExpression (identifier = Unit)
|
||||
UAnnotationMethod (name = Baz)
|
||||
@@ -0,0 +1,15 @@
|
||||
public final class Foo {
|
||||
public fun Foo() = UastEmptyExpression
|
||||
public static final class Bar {
|
||||
private final var a: int
|
||||
private final var b: int
|
||||
public final fun getAPlusB() : int = a + b
|
||||
public final fun getA() : int = UastEmptyExpression
|
||||
public final fun getB() : int = UastEmptyExpression
|
||||
public fun Bar(a: int, b: int) = UastEmptyExpression
|
||||
public static final class Baz {
|
||||
public final fun doNothing() : void = Unit
|
||||
public fun Baz() = UastEmptyExpression
|
||||
}
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
println("Hello World!")
|
||||
|
||||
fun getBarOrNull(flag: Boolean): Bar? {
|
||||
return if (flag) Bar(42) else null
|
||||
}
|
||||
|
||||
class Bar(val a: Int) {
|
||||
val b: Int = 0
|
||||
|
||||
fun getAPlusB() = a + b
|
||||
|
||||
class Baz {
|
||||
fun doSomething() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getBarOrNull(true)
|
||||
println("Goodbye World!")
|
||||
@@ -0,0 +1,49 @@
|
||||
UFile (package = )
|
||||
UClass (name = SimpleScript)
|
||||
UAnnotationMethod (name = getBarOrNull)
|
||||
UParameter (name = flag)
|
||||
UAnnotation (fqName = null)
|
||||
UBlockExpression
|
||||
UReturnExpression
|
||||
UIfExpression
|
||||
USimpleNameReferenceExpression (identifier = flag)
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
|
||||
UIdentifier (Identifier (Bar))
|
||||
USimpleNameReferenceExpression (identifier = <init>)
|
||||
ULiteralExpression (value = 42)
|
||||
ULiteralExpression (value = null)
|
||||
UAnnotationMethod (name = SimpleScript)
|
||||
UParameter (name = p)
|
||||
UAnnotation (fqName = null)
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1))
|
||||
UIdentifier (Identifier (println))
|
||||
USimpleNameReferenceExpression (identifier = println)
|
||||
ULiteralExpression (value = "Hello World!")
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1))
|
||||
UIdentifier (Identifier (getBarOrNull))
|
||||
USimpleNameReferenceExpression (identifier = getBarOrNull)
|
||||
ULiteralExpression (value = true)
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1))
|
||||
UIdentifier (Identifier (println))
|
||||
USimpleNameReferenceExpression (identifier = println)
|
||||
ULiteralExpression (value = "Goodbye World!")
|
||||
UClass (name = Bar)
|
||||
UField (name = b)
|
||||
UAnnotation (fqName = null)
|
||||
ULiteralExpression (value = 0)
|
||||
UField (name = a)
|
||||
UAnnotation (fqName = null)
|
||||
UAnnotationMethod (name = getB)
|
||||
UAnnotationMethod (name = getAPlusB)
|
||||
UBinaryExpression (operator = +)
|
||||
USimpleNameReferenceExpression (identifier = a)
|
||||
USimpleNameReferenceExpression (identifier = b)
|
||||
UAnnotationMethod (name = getA)
|
||||
UAnnotationMethod (name = Bar)
|
||||
UParameter (name = a)
|
||||
UAnnotation (fqName = null)
|
||||
UClass (name = Baz)
|
||||
UAnnotationMethod (name = doSomething)
|
||||
UBlockExpression
|
||||
UAnnotationMethod (name = Baz)
|
||||
@@ -0,0 +1,23 @@
|
||||
public class SimpleScript : kotlin.script.templates.standard.ScriptTemplateWithArgs {
|
||||
public final fun getBarOrNull(flag: boolean) : SimpleScript.Bar {
|
||||
return if (flag) <init>(42) else null
|
||||
}
|
||||
public fun SimpleScript(p: java.lang.String[]) {
|
||||
println("Hello World!")
|
||||
getBarOrNull(true)
|
||||
println("Goodbye World!")
|
||||
}
|
||||
public static final class Bar {
|
||||
private final var b: int = 0
|
||||
private final var a: int
|
||||
public final fun getB() : int = UastEmptyExpression
|
||||
public final fun getAPlusB() : int = a + b
|
||||
public final fun getA() : int = UastEmptyExpression
|
||||
public fun Bar(a: int) = UastEmptyExpression
|
||||
public static final class Baz {
|
||||
public final fun doSomething() : void {
|
||||
}
|
||||
public fun Baz() = UastEmptyExpression
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user