UAST: Properly handle annotations on local variables
This commit is contained in:
committed by
Nikolay Krasko
parent
35fa8efbf3
commit
8eddb10870
@@ -1,6 +1,6 @@
|
||||
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<?>]
|
||||
UField (name = a) [@org.jetbrains.annotations.Nullable 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
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
public final class ElvisKt {
|
||||
public static final fun foo(bar: java.lang.String) : java.lang.String = null
|
||||
public static final fun foo(@org.jetbrains.annotations.NotNull 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 {
|
||||
|
||||
@@ -3,8 +3,8 @@ public enum Style {
|
||||
public fun getExitAnimation() : java.lang.String = "bar"
|
||||
fun SHEET() = UastEmptyExpression
|
||||
}
|
||||
private final var value: java.lang.String
|
||||
@org.jetbrains.annotations.NotNull 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(value: java.lang.String) = UastEmptyExpression
|
||||
protected fun Style(@org.jetbrains.annotations.NotNull value: java.lang.String) = UastEmptyExpression
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
annotation class TestAnnotation
|
||||
|
||||
fun foo() {
|
||||
@TestAnnotation
|
||||
val bar = "lorem ipsum"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
UFile (package = )
|
||||
UClass (name = LocalVariableWithAnnotationKt)
|
||||
UAnnotationMethod (name = foo)
|
||||
UBlockExpression
|
||||
UDeclarationsExpression
|
||||
ULocalVariable (name = bar)
|
||||
UAnnotation (fqName = TestAnnotation)
|
||||
ULiteralExpression (value = "lorem ipsum")
|
||||
UClass (name = TestAnnotation)
|
||||
@@ -0,0 +1,8 @@
|
||||
public final class LocalVariableWithAnnotationKt {
|
||||
public static final fun foo() : void {
|
||||
@TestAnnotation var bar: <ErrorType> = "lorem ipsum"
|
||||
}
|
||||
}
|
||||
|
||||
public abstract annotation TestAnnotation {
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
public final class PropertyTest {
|
||||
public final fun getStringRepresentation() : java.lang.String = this.toString()
|
||||
public final fun setStringRepresentation(value: java.lang.String) : void {
|
||||
public final fun setStringRepresentation(@org.jetbrains.annotations.NotNull value: java.lang.String) : void {
|
||||
setDataFromString(value)
|
||||
}
|
||||
public final fun setDataFromString(data: java.lang.String) : void {
|
||||
public final fun setDataFromString(@org.jetbrains.annotations.NotNull data: java.lang.String) : void {
|
||||
}
|
||||
public fun PropertyTest() = UastEmptyExpression
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
public final class PropertyDelegateKt {
|
||||
private static final var sdCardPath$delegate: kotlin.Lazy
|
||||
@org.jetbrains.annotations.NotNull 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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
public final class TestPropertyInitializer {
|
||||
private var withSetter: java.lang.String = "/sdcard"
|
||||
@org.jetbrains.annotations.NotNull private var withSetter: java.lang.String = "/sdcard"
|
||||
public final fun getWithSetter() : java.lang.String = field
|
||||
public final fun setWithSetter(p: java.lang.String) : void {
|
||||
public final fun setWithSetter(@org.jetbrains.annotations.NotNull p: java.lang.String) : void {
|
||||
field = p
|
||||
}
|
||||
public fun TestPropertyInitializer() = UastEmptyExpression
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
public final class PropertyInitializerWithoutSetterKt {
|
||||
private static var withoutSetter: java.lang.String = "/sdcard"
|
||||
@org.jetbrains.annotations.NotNull 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
|
||||
public static final fun setWithoutSetter(@org.jetbrains.annotations.NotNull p: java.lang.String) : void = UastEmptyExpression
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
public final class Simple {
|
||||
private final var property: java.lang.String = "Mary"
|
||||
@org.jetbrains.annotations.NotNull private final var property: java.lang.String = "Mary"
|
||||
public final fun method() : void {
|
||||
println("Hello, world!")
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
UFile (package = ) [public final class Simple {...]
|
||||
UClass (name = Simple) [public final class Simple {...}]
|
||||
UField (name = property) [private final var property: java.lang.String = "Mary"]
|
||||
UField (name = property) [@org.jetbrains.annotations.NotNull 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 {...}]
|
||||
|
||||
+4
-4
@@ -1,8 +1,8 @@
|
||||
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
|
||||
@org.jetbrains.annotations.NotNull private static final var foo: java.lang.String = "lorem"
|
||||
@org.jetbrains.annotations.NotNull private static final var bar: java.lang.String = "ipsum"
|
||||
@org.jetbrains.annotations.NotNull private static final var baz: java.lang.String = "dolor"
|
||||
@org.jetbrains.annotations.NotNull 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
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
UFile (package = ) [public abstract interface Callback {...]
|
||||
UClass (name = Callback) [public abstract interface Callback {...}]
|
||||
UAnnotationMethod (name = onError) [public abstract fun onError(throwable: java.lang.Throwable) : void = UastEmptyExpression]
|
||||
UParameter (name = throwable) [var throwable: java.lang.Throwable]
|
||||
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]
|
||||
UAnnotation (fqName = org.jetbrains.annotations.NotNull) [@org.jetbrains.annotations.NotNull]
|
||||
UClass (name = Model) [public final class Model {...}]
|
||||
UAnnotationMethod (name = crashMe) [public final fun crashMe(clazz: java.lang.Class<T>, factory: kotlin.jvm.functions.Function0<? extends T>) : void {...}]
|
||||
UParameter (name = clazz) [var clazz: java.lang.Class<T>]
|
||||
UAnnotationMethod (name = crashMe) [public final fun crashMe(@org.jetbrains.annotations.NotNull clazz: java.lang.Class<T>, @org.jetbrains.annotations.NotNull factory: kotlin.jvm.functions.Function0<? extends T>) : void {...}]
|
||||
UParameter (name = clazz) [@org.jetbrains.annotations.NotNull var clazz: java.lang.Class<T>]
|
||||
UAnnotation (fqName = org.jetbrains.annotations.NotNull) [@org.jetbrains.annotations.NotNull]
|
||||
UParameter (name = factory) [var factory: kotlin.jvm.functions.Function0<? extends T>]
|
||||
UParameter (name = factory) [@org.jetbrains.annotations.NotNull var factory: kotlin.jvm.functions.Function0<? extends T>]
|
||||
UAnnotation (fqName = org.jetbrains.annotations.NotNull) [@org.jetbrains.annotations.NotNull]
|
||||
UBlockExpression [{...}] : PsiType:Void
|
||||
UThrowExpression [throw <init>()] : 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(throwable: java.lang.Throwable) : void {...}]
|
||||
UParameter (name = throwable) [var throwable: java.lang.Throwable]
|
||||
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]
|
||||
UAnnotation (fqName = org.jetbrains.annotations.NotNull) [@org.jetbrains.annotations.NotNull]
|
||||
UBlockExpression [{...}] : PsiType:Void
|
||||
UThrowExpression [throw <init>("")] : PsiType:Void
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
public final class WhenIsKt {
|
||||
public static final fun foo(bar: java.lang.Object) : java.lang.String = switch (bar) {
|
||||
public static final fun foo(@org.jetbrains.annotations.NotNull bar: java.lang.Object) : java.lang.String = switch (bar) {
|
||||
it is java.lang.String -> {
|
||||
bar
|
||||
break
|
||||
|
||||
@@ -31,6 +31,8 @@ class SimpleKotlinRenderLogTest : AbstractKotlinRenderLogTest() {
|
||||
|
||||
@Test fun testPropertyDelegate() = doTest("PropertyDelegate") { testName, file -> check(testName, file, false) }
|
||||
|
||||
@Test fun testLocalVariableWithAnnotation() = doTest("LocalVariableWithAnnotation")
|
||||
|
||||
@Test fun testPropertyWithAnnotation() = doTest("PropertyWithAnnotation")
|
||||
|
||||
@Test fun testIfStatement() = doTest("IfStatement")
|
||||
|
||||
Reference in New Issue
Block a user