Uast: TypeReferences log test added

This commit is contained in:
Nicolay Mitropolsky
2019-02-28 13:09:30 +03:00
parent adb13b2f9e
commit ec26ea4e36
5 changed files with 98 additions and 0 deletions
@@ -107,6 +107,7 @@ abstract class AbstractKotlinUVariable(givenParent: UElement?) : KotlinAbstractU
// receiver param in extension function
(it as? KtUserType)?.referenceExpression?.getIdentifier() ?: it
} ?: sourcePsi
is KtNameReferenceExpression -> sourcePsi.getReferencedNameElement()
is KtBinaryExpression, is KtCallExpression -> null // e.g. `foo("Lorem ipsum") ?: foo("dolor sit amet")`
is KtDestructuringDeclaration -> sourcePsi.valOrVarKeyword
else -> sourcePsi
+69
View File
@@ -0,0 +1,69 @@
UFile (package = )
UClass (name = TypeReferencesKt)
UAnnotationMethod (name = foo)
UParameter (name = parameter)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UBlockExpression
UDeclarationsExpression
ULocalVariable (name = varWithType)
ULiteralExpression (value = "Not Null")
UDeclarationsExpression
ULocalVariable (name = varWithoutType)
ULiteralExpression (value = "lorem ipsum")
UDeclarationsExpression
ULocalVariable (name = result)
UBinaryExpression (operator = +)
USimpleNameReferenceExpression (identifier = varWithType)
USimpleNameReferenceExpression (identifier = varWithoutType)
UReturnExpression
USimpleNameReferenceExpression (identifier = result)
UAnnotationMethod (name = parameterizedFoo)
UParameter (name = arg)
UAnnotation (fqName = org.jetbrains.annotations.Nullable)
UBlockExpression
UDeclarationsExpression
ULocalVariable (name = a)
USimpleNameReferenceExpression (identifier = arg)
UDeclarationsExpression
ULocalVariable (name = at)
UExpressionList (elvis)
UDeclarationsExpression
ULocalVariable (name = var708e1d08)
UAnnotation (fqName = org.jetbrains.annotations.Nullable)
USimpleNameReferenceExpression (identifier = arg)
UIfExpression
UBinaryExpression (operator = !=)
USimpleNameReferenceExpression (identifier = var708e1d08)
ULiteralExpression (value = null)
USimpleNameReferenceExpression (identifier = var708e1d08)
UReturnExpression
UDeclarationsExpression
ULocalVariable (name = tl)
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1))
UIdentifier (Identifier (listOf))
USimpleNameReferenceExpression (identifier = listOf, resolvesTo = null)
USimpleNameReferenceExpression (identifier = at)
UDeclarationsExpression
ULocalVariable (name = tsl)
UQualifiedReferenceExpression
USimpleNameReferenceExpression (identifier = tl)
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1))
UIdentifier (Identifier (map))
USimpleNameReferenceExpression (identifier = map, resolvesTo = null)
ULambdaExpression
UBlockExpression
UQualifiedReferenceExpression
USimpleNameReferenceExpression (identifier = it)
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
UIdentifier (Identifier (toString))
USimpleNameReferenceExpression (identifier = toString, resolvesTo = null)
UDeclarationsExpression
ULocalVariable (name = lls)
UDeclarationsExpression
ULocalVariable (name = llt)
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1))
UIdentifier (Identifier (parameterizedFoo))
USimpleNameReferenceExpression (identifier = parameterizedFoo, resolvesTo = null)
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
UIdentifier (Identifier (emptyList))
USimpleNameReferenceExpression (identifier = emptyList, resolvesTo = null)
+22
View File
@@ -0,0 +1,22 @@
public final class TypeReferencesKt {
public static final fun foo(@org.jetbrains.annotations.NotNull parameter: int) : java.lang.String {
var varWithType: java.lang.String = "Not Null"
var varWithoutType: java.lang.String = "lorem ipsum"
var result: java.lang.String = varWithType + varWithoutType
return result
}
public static final fun parameterizedFoo(@org.jetbrains.annotations.Nullable arg: T) : void {
var a: java.lang.Object = arg
var at: java.lang.Object = elvis {
@org.jetbrains.annotations.Nullable var var708e1d08: java.lang.Object = arg
if (var708e1d08 != null) var708e1d08 else return
}
var tl: java.util.List<? extends T> = listOf(at)
var tsl: java.util.List<? extends java.lang.String> = tl.map({
it.toString()
})
var lls: java.util.List<? extends java.util.List<? extends java.lang.String>>
var llt: java.util.List<? extends java.util.List<? extends T>>
parameterizedFoo(emptyList())
}
}
@@ -85,6 +85,9 @@ class SimpleKotlinRenderLogTest : AbstractKotlinRenderLogTest() {
@Test
fun testLambdas() = doTest("Lambdas")
@Test
fun testTypeReferences() = doTest("TypeReferences")
@Test
fun testDelegate() = doTest("Delegate")
@@ -91,6 +91,9 @@ class SimpleKotlinRenderLogTest : AbstractKotlinRenderLogTest() {
@Test
fun testLambdas() = doTest("Lambdas")
@Test
fun testTypeReferences() = doTest("TypeReferences")
@Test
fun testDelegate() = doTest("Delegate")