UAST: Fix getType and getText for UastKotlinPsiVariable

This commit is contained in:
Vyacheslav Gerasimov
2017-09-13 20:16:47 +03:00
parent 14742a6048
commit bba2d27e82
12 changed files with 141 additions and 50 deletions
+4 -4
View File
@@ -2,11 +2,11 @@ UFile (package = ) [public final class InKt {...]
UClass (name = InKt) [public final class InKt {...}]
UAnnotationMethod (name = foo) [public static final fun foo() : boolean {...}]
UBlockExpression [{...}] = Nothing
UDeclarationsExpression [var x: <ErrorType> = 1] = Undetermined
ULocalVariable (name = x) [var x: <ErrorType> = 1]
UDeclarationsExpression [var x: int = 1] = Undetermined
ULocalVariable (name = x) [var x: int = 1]
ULiteralExpression (value = 1) [1] = 1
UDeclarationsExpression [var y: <ErrorType> = 10] = Undetermined
ULocalVariable (name = y) [var y: <ErrorType> = 10]
UDeclarationsExpression [var y: int = 10] = Undetermined
ULocalVariable (name = y) [var y: int = 10]
ULiteralExpression (value = 10) [10] = 10
UReturnExpression [return x in 0 .. 5 && y !in 4 .. 9] = Nothing
UBinaryExpression (operator = &&) [x in 0 .. 5 && y !in 4 .. 9] = true (depending on: (var x = 1), (var y = 10))
+1 -1
View File
@@ -6,7 +6,7 @@ public final class LocalDeclarationsKt {
var bar: <ErrorType> = fun () {
<init>()
}
var baz: <ErrorType> = fun () {
var baz: kotlin.jvm.functions.Function0<? extends kotlin.Unit> = fun () {
<init>()
}
var someLocalFun: kotlin.jvm.functions.Function2<? super java.lang.Integer,? super java.lang.String,? extends java.lang.Integer> = fun (var text: java.lang.String) {
+2 -2
View File
@@ -11,8 +11,8 @@ UFile (package = ) [public final class LocalDeclarationsKt {...]
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) [<init>()] : PsiType:<ErrorType>
UIdentifier (Identifier (Local)) [UIdentifier (Identifier (Local))]
USimpleNameReferenceExpression (identifier = <init>) [<init>] : PsiType:<ErrorType>
UDeclarationsExpression [var baz: <ErrorType> = fun () {...}]
ULocalVariable (name = baz) [var baz: <ErrorType> = fun () {...}]
UDeclarationsExpression [var baz: kotlin.jvm.functions.Function0<? extends kotlin.Unit> = fun () {...}]
ULocalVariable (name = baz) [var baz: kotlin.jvm.functions.Function0<? extends kotlin.Unit> = fun () {...}]
ULambdaExpression [fun () {...}]
UBlockExpression [{...}] : PsiType:<ErrorType>
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) [<init>()] : PsiType:<ErrorType>
+2 -2
View File
@@ -11,8 +11,8 @@ UFile (package = ) [public final class LocalDeclarationsKt {...]
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) [<init>()] = external <init>()()
UIdentifier (Identifier (Local)) [UIdentifier (Identifier (Local))]
USimpleNameReferenceExpression (identifier = <init>) [<init>] = external <init>()()
UDeclarationsExpression [var baz: <ErrorType> = fun () {...}] = Undetermined
ULocalVariable (name = baz) [var baz: <ErrorType> = fun () {...}]
UDeclarationsExpression [var baz: kotlin.jvm.functions.Function0<? extends kotlin.Unit> = fun () {...}] = Undetermined
ULocalVariable (name = baz) [var baz: kotlin.jvm.functions.Function0<? extends kotlin.Unit> = fun () {...}]
ULambdaExpression [fun () {...}] = Undetermined
UBlockExpression [{...}] = external <init>()()
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) [<init>()] = external <init>()()
@@ -0,0 +1,27 @@
UFile (package = )
UClass (name = MyAnnotation)
UClass (name = Test1)
UField (name = bar)
UAnnotation (fqName = null)
UAnnotationMethod (name = getBar)
UAnnotationMethod (name = setBar)
UParameter (name = p)
UAnnotation (fqName = null)
UAnnotationMethod (name = Test1)
UParameter (name = bar)
UAnnotation (fqName = MyAnnotation)
UAnnotation (fqName = null)
UClass (name = Test2)
UField (name = bar)
UAnnotation (fqName = MyAnnotation)
UAnnotation (fqName = null)
UAnnotationMethod (name = getBar)
UAnnotation (fqName = MyAnnotation)
UAnnotationMethod (name = setBar)
UAnnotation (fqName = MyAnnotation)
UParameter (name = p)
UAnnotation (fqName = MyAnnotation)
UAnnotation (fqName = null)
UAnnotationMethod (name = Test2)
UParameter (name = bar)
UAnnotation (fqName = null)
@@ -0,0 +1,18 @@
public abstract annotation MyAnnotation {
}
public final class Test1 {
private var bar: int
public final fun getBar() : int = UastEmptyExpression
public final fun setBar(p: int) : void = UastEmptyExpression
public fun Test1(bar: int) = UastEmptyExpression
}
public final class Test2 {
private var bar: int
@MyAnnotation
public final fun getBar() : int = UastEmptyExpression
@MyAnnotation
public final fun setBar(p: int) : void = UastEmptyExpression
public fun Test2(bar: int) = UastEmptyExpression
}
@@ -0,0 +1,4 @@
fun foo(a: Int, b: String, c: Int = 0, flag: Boolean = false) {
}
@@ -0,0 +1,14 @@
UFile (package = )
UClass (name = ParametersWithDefaultValuesKt)
UAnnotationMethod (name = foo)
UParameter (name = a)
UAnnotation (fqName = null)
UParameter (name = b)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UParameter (name = c)
UAnnotation (fqName = null)
ULiteralExpression (value = 0)
UParameter (name = flag)
UAnnotation (fqName = null)
ULiteralExpression (value = false)
UBlockExpression
@@ -0,0 +1,4 @@
public final class ParametersWithDefaultValuesKt {
public static final fun foo(a: int, b: java.lang.String, c: int, flag: boolean) : void {
}
}
+1 -1
View File
@@ -2,6 +2,6 @@ public final class PropertyDelegateKt {
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: <ErrorType>
var sdCardPathLocal: java.lang.String
}
}