Uast: KotlinClassViaConstructorUSimpleReferenceExpression resolve to PsiClass (KT-41290)
This commit is contained in:
+11
-7
@@ -16,19 +16,16 @@
|
||||
|
||||
package org.jetbrains.uast.kotlin
|
||||
|
||||
import com.intellij.psi.PsiClassType
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiMethod
|
||||
import com.intellij.psi.PsiNamedElement
|
||||
import com.intellij.psi.*
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.resolve.sam.SamConstructorDescriptor
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.NewResolvedCallImpl
|
||||
import org.jetbrains.kotlin.resolve.sam.SamConstructorDescriptor
|
||||
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
|
||||
import org.jetbrains.uast.*
|
||||
import org.jetbrains.uast.internal.acceptList
|
||||
@@ -177,7 +174,7 @@ class KotlinClassViaConstructorUSimpleReferenceExpression(
|
||||
private val resolved by lazy {
|
||||
when (val resultingDescriptor = sourcePsi.getResolvedCall(sourcePsi.analyze())?.descriptorForResolveViaConstructor()) {
|
||||
is ConstructorDescriptor -> {
|
||||
sourcePsi.calleeExpression?.let { resolveToDeclaration(it, resultingDescriptor) }
|
||||
sourcePsi.calleeExpression?.let { resolveToDeclaration(it, resultingDescriptor.constructedClass) }
|
||||
}
|
||||
is SamConstructorDescriptor ->
|
||||
(resultingDescriptor.returnType?.getFunctionalInterfaceType(this, sourcePsi) as? PsiClassType)?.resolve()
|
||||
@@ -191,7 +188,14 @@ class KotlinClassViaConstructorUSimpleReferenceExpression(
|
||||
|
||||
override fun resolve(): PsiElement? = resolved
|
||||
|
||||
override fun asLogString(): String = log<USimpleNameReferenceExpression>("identifier = $identifier, resolvesTo = $resolvedName")
|
||||
override fun asLogString(): String {
|
||||
val resolveStr = when(val resolved = resolve()){
|
||||
is PsiClass -> "PsiClass: ${resolved.name}"
|
||||
is PsiMethod -> "PsiMethod: ${resolved.name}"
|
||||
else -> resolved.toString()
|
||||
}
|
||||
return log<USimpleNameReferenceExpression>("identifier = $identifier, resolvesTo = $resolveStr")
|
||||
}
|
||||
|
||||
// In new inference, SAM constructor is substituted with a function descriptor, so we use candidate descriptor to preserve behavior
|
||||
private fun ResolvedCall<*>.descriptorForResolveViaConstructor(): CallableDescriptor? {
|
||||
|
||||
+4
-4
@@ -11,14 +11,14 @@ UFile (package = )
|
||||
UNamedExpression (name = value)
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0))
|
||||
UIdentifier (Identifier (Annotation))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = Annotation)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: Annotation)
|
||||
UMethod (name = B1)
|
||||
UClass (name = B2)
|
||||
UAnnotation (fqName = AnnotationArray)
|
||||
UNamedExpression (name = value)
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 2))
|
||||
UIdentifier (Identifier (Annotation))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = Annotation)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: Annotation)
|
||||
ULiteralExpression (value = "sv1")
|
||||
ULiteralExpression (value = "sv2")
|
||||
UMethod (name = B2)
|
||||
@@ -29,7 +29,7 @@ UFile (package = )
|
||||
UNamedExpression (name = value)
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
|
||||
UIdentifier (Identifier (Annotation))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = Annotation)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: Annotation)
|
||||
UCallExpression (kind = UastCallKind(name='array_initializer'), argCount = 2))
|
||||
UIdentifier (Identifier (arrayOf))
|
||||
USimpleNameReferenceExpression (identifier = arrayOf, resolvesTo = null)
|
||||
@@ -41,7 +41,7 @@ UFile (package = )
|
||||
UNamedExpression (name = value)
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
|
||||
UIdentifier (Identifier (Annotation))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = Annotation)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: Annotation)
|
||||
UCallExpression (kind = UastCallKind(name='array_initializer'), argCount = 2))
|
||||
UIdentifier (Identifier ([))
|
||||
ULiteralExpression (value = "[sar]1")
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ UFile (package = )
|
||||
ULocalVariable (name = runnable2)
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1))
|
||||
UIdentifier (Identifier (Runnable))
|
||||
USimpleNameReferenceExpression (identifier = Runnable, resolvesTo = Runnable)
|
||||
USimpleNameReferenceExpression (identifier = Runnable, resolvesTo = PsiClass: Runnable)
|
||||
ULambdaExpression
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ UFile (package = )
|
||||
ULocalVariable (name = runnable2)
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1))
|
||||
UIdentifier (Identifier (Runnable))
|
||||
USimpleNameReferenceExpression (identifier = Runnable, resolvesTo = Runnable)
|
||||
USimpleNameReferenceExpression (identifier = Runnable, resolvesTo = PsiClass: Runnable)
|
||||
ULambdaExpression
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
|
||||
|
||||
@@ -7,7 +7,7 @@ UFile (package = )
|
||||
UReturnExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
|
||||
UIdentifier (Identifier (BaseImpl))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = BaseImpl)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: BaseImpl)
|
||||
USimpleNameReferenceExpression (identifier = i)
|
||||
UClass (name = Base)
|
||||
UMethod (name = print)
|
||||
|
||||
@@ -7,7 +7,7 @@ UFile (package = )
|
||||
UReturnExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
|
||||
UIdentifier (Identifier (BaseImpl))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = BaseImpl)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: BaseImpl)
|
||||
USimpleNameReferenceExpression (identifier = i)
|
||||
UClass (name = Base)
|
||||
UMethod (name = print)
|
||||
|
||||
+7
-7
@@ -12,7 +12,7 @@ UFile (package = )
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
|
||||
UIdentifier (Identifier (this))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = A)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: A)
|
||||
UQualifiedReferenceExpression
|
||||
USimpleNameReferenceExpression (identifier = i)
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
|
||||
@@ -36,7 +36,7 @@ UFile (package = )
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
|
||||
UIdentifier (Identifier (this))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = AWithInit)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: AWithInit)
|
||||
UQualifiedReferenceExpression
|
||||
USimpleNameReferenceExpression (identifier = i)
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
|
||||
@@ -66,7 +66,7 @@ UFile (package = )
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
|
||||
UIdentifier (Identifier (this))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = AWith2Init)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: AWith2Init)
|
||||
UQualifiedReferenceExpression
|
||||
USimpleNameReferenceExpression (identifier = i)
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
|
||||
@@ -98,7 +98,7 @@ UFile (package = )
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0))
|
||||
UIdentifier (Identifier ())
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = Object)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: Object)
|
||||
UBinaryExpression (operator = =)
|
||||
USimpleNameReferenceExpression (identifier = a)
|
||||
UQualifiedReferenceExpression
|
||||
@@ -112,7 +112,7 @@ UFile (package = )
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0))
|
||||
UIdentifier (Identifier ())
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = Object)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: Object)
|
||||
UBinaryExpression (operator = =)
|
||||
USimpleNameReferenceExpression (identifier = a)
|
||||
USimpleNameReferenceExpression (identifier = s)
|
||||
@@ -129,7 +129,7 @@ UFile (package = )
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0))
|
||||
UIdentifier (Identifier ())
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = Object)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: Object)
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
|
||||
UIdentifier (Identifier (println))
|
||||
@@ -147,7 +147,7 @@ UFile (package = )
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0))
|
||||
UIdentifier (Identifier ())
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = Object)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: Object)
|
||||
UBinaryExpression (operator = =)
|
||||
USimpleNameReferenceExpression (identifier = a)
|
||||
USimpleNameReferenceExpression (identifier = s)
|
||||
|
||||
+7
-7
@@ -12,7 +12,7 @@ UFile (package = )
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
|
||||
UIdentifier (Identifier (this))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = A)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: A)
|
||||
UQualifiedReferenceExpression
|
||||
USimpleNameReferenceExpression (identifier = i)
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
|
||||
@@ -36,7 +36,7 @@ UFile (package = )
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
|
||||
UIdentifier (Identifier (this))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = AWithInit)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: AWithInit)
|
||||
UQualifiedReferenceExpression
|
||||
USimpleNameReferenceExpression (identifier = i)
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
|
||||
@@ -66,7 +66,7 @@ UFile (package = )
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
|
||||
UIdentifier (Identifier (this))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = AWith2Init)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: AWith2Init)
|
||||
UQualifiedReferenceExpression
|
||||
USimpleNameReferenceExpression (identifier = i)
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
|
||||
@@ -98,7 +98,7 @@ UFile (package = )
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0))
|
||||
UIdentifier (Identifier ())
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = Object)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: Object)
|
||||
UBinaryExpression (operator = =)
|
||||
USimpleNameReferenceExpression (identifier = a)
|
||||
UQualifiedReferenceExpression
|
||||
@@ -112,7 +112,7 @@ UFile (package = )
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0))
|
||||
UIdentifier (Identifier ())
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = Object)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: Object)
|
||||
UBinaryExpression (operator = =)
|
||||
USimpleNameReferenceExpression (identifier = a)
|
||||
USimpleNameReferenceExpression (identifier = s)
|
||||
@@ -129,7 +129,7 @@ UFile (package = )
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0))
|
||||
UIdentifier (Identifier ())
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = Object)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: Object)
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
|
||||
UIdentifier (Identifier (println))
|
||||
@@ -147,7 +147,7 @@ UFile (package = )
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0))
|
||||
UIdentifier (Identifier ())
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = Object)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: Object)
|
||||
UBinaryExpression (operator = =)
|
||||
USimpleNameReferenceExpression (identifier = a)
|
||||
USimpleNameReferenceExpression (identifier = s)
|
||||
|
||||
+3
-3
@@ -27,7 +27,7 @@ UFile (package = )
|
||||
UReturnExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 3))
|
||||
UIdentifier (Identifier (MyColor))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = MyColor)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: MyColor)
|
||||
ULiteralExpression (value = 18)
|
||||
ULiteralExpression (value = 2)
|
||||
ULiteralExpression (value = 3)
|
||||
@@ -41,7 +41,7 @@ UFile (package = )
|
||||
UReturnExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 3))
|
||||
UIdentifier (Identifier (MyColor))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = MyColor)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: MyColor)
|
||||
ULiteralExpression (value = 1)
|
||||
ULiteralExpression (value = 2)
|
||||
ULiteralExpression (value = 3)
|
||||
@@ -49,7 +49,7 @@ UFile (package = )
|
||||
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 3))
|
||||
UIdentifier (Identifier (MyColor))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = MyColor)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: MyColor)
|
||||
ULiteralExpression (value = 1)
|
||||
ULiteralExpression (value = 2)
|
||||
ULiteralExpression (value = 3)
|
||||
|
||||
+3
-3
@@ -31,7 +31,7 @@ UFile (package = ) [public final class MyColor {...]
|
||||
UReturnExpression [return <init>(18, 2, 3)] = Nothing
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 3)) [<init>(18, 2, 3)] = external <init>(18, 2, 3)(18, 2, 3)
|
||||
UIdentifier (Identifier (MyColor)) [UIdentifier (Identifier (MyColor))]
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = MyColor) [<init>] = external <init>(18, 2, 3)(18, 2, 3)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: MyColor) [<init>] = external <init>(18, 2, 3)(18, 2, 3)
|
||||
ULiteralExpression (value = 18) [18] = 18
|
||||
ULiteralExpression (value = 2) [2] = 2
|
||||
ULiteralExpression (value = 3) [3] = 3
|
||||
@@ -49,7 +49,7 @@ UFile (package = ) [public final class MyColor {...]
|
||||
UReturnExpression [return <init>(1, 2, 3)] = Nothing
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 3)) [<init>(1, 2, 3)] = external <init>(1, 2, 3)(1, 2, 3)
|
||||
UIdentifier (Identifier (MyColor)) [UIdentifier (Identifier (MyColor))]
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = MyColor) [<init>] = external <init>(1, 2, 3)(1, 2, 3)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: MyColor) [<init>] = external <init>(1, 2, 3)(1, 2, 3)
|
||||
ULiteralExpression (value = 1) [1] = 1
|
||||
ULiteralExpression (value = 2) [2] = 2
|
||||
ULiteralExpression (value = 3) [3] = 3
|
||||
@@ -57,7 +57,7 @@ UFile (package = ) [public final class MyColor {...]
|
||||
UAnnotation (fqName = org.jetbrains.annotations.NotNull) [@org.jetbrains.annotations.NotNull]
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 3)) [<init>(1, 2, 3)] = external <init>(1, 2, 3)(1, 2, 3)
|
||||
UIdentifier (Identifier (MyColor)) [UIdentifier (Identifier (MyColor))]
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = MyColor) [<init>] = external <init>(1, 2, 3)(1, 2, 3)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: MyColor) [<init>] = external <init>(1, 2, 3)(1, 2, 3)
|
||||
ULiteralExpression (value = 1) [1] = 1
|
||||
ULiteralExpression (value = 2) [2] = 2
|
||||
ULiteralExpression (value = 3) [3] = 3
|
||||
|
||||
@@ -12,14 +12,14 @@ UFile (package = )
|
||||
UReturnExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0))
|
||||
UIdentifier (Identifier (Local))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = Local)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: Local)
|
||||
UDeclarationsExpression
|
||||
ULocalVariable (name = baz)
|
||||
ULambdaExpression
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0))
|
||||
UIdentifier (Identifier (Local))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = Local)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: Local)
|
||||
UDeclarationsExpression
|
||||
UVariable (name = someLocalFun)
|
||||
ULambdaExpression
|
||||
@@ -35,4 +35,4 @@ UFile (package = )
|
||||
USimpleNameReferenceExpression (identifier = bar, resolvesTo = null)
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0))
|
||||
UIdentifier (Identifier (Local))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = Local)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: Local)
|
||||
|
||||
+3
-3
@@ -12,14 +12,14 @@ UFile (package = )
|
||||
UReturnExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0))
|
||||
UIdentifier (Identifier (Local))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = Local)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: Local)
|
||||
UDeclarationsExpression
|
||||
ULocalVariable (name = baz)
|
||||
ULambdaExpression
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0))
|
||||
UIdentifier (Identifier (Local))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = Local)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: Local)
|
||||
UDeclarationsExpression
|
||||
UVariable (name = someLocalFun)
|
||||
ULambdaExpression
|
||||
@@ -35,4 +35,4 @@ UFile (package = )
|
||||
USimpleNameReferenceExpression (identifier = bar, resolvesTo = null)
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0))
|
||||
UIdentifier (Identifier (Local))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = Local)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: Local)
|
||||
|
||||
@@ -12,14 +12,14 @@ UFile (package = ) [public final class LocalDeclarationsKt {...]
|
||||
UReturnExpression [return <init>()]
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) [<init>()] : PsiType:<ErrorType>
|
||||
UIdentifier (Identifier (Local)) [UIdentifier (Identifier (Local))]
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = Local) [<init>] : PsiType:<ErrorType>
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: Local) [<init>] : PsiType:<ErrorType>
|
||||
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>
|
||||
UIdentifier (Identifier (Local)) [UIdentifier (Identifier (Local))]
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = Local) [<init>] : PsiType:<ErrorType>
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: Local) [<init>] : PsiType:<ErrorType>
|
||||
UDeclarationsExpression [var someLocalFun: kotlin.jvm.functions.Function2<? super java.lang.Integer,? super java.lang.String,? extends java.lang.Integer> = fun (@org.jetbrains.annotations.NotNull var text: java.lang.String) {...}]
|
||||
UVariable (name = someLocalFun) [var someLocalFun: kotlin.jvm.functions.Function2<? super java.lang.Integer,? super java.lang.String,? extends java.lang.Integer> = fun (@org.jetbrains.annotations.NotNull var text: java.lang.String) {...}]
|
||||
ULambdaExpression [fun (@org.jetbrains.annotations.NotNull var text: java.lang.String) {...}]
|
||||
@@ -35,4 +35,4 @@ UFile (package = ) [public final class LocalDeclarationsKt {...]
|
||||
USimpleNameReferenceExpression (identifier = bar, resolvesTo = null) [bar] : PsiType:<ErrorType>
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) [<init>()] : PsiType:<ErrorType>
|
||||
UIdentifier (Identifier (Local)) [UIdentifier (Identifier (Local))]
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = Local) [<init>] : PsiType:<ErrorType>
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: Local) [<init>] : PsiType:<ErrorType>
|
||||
|
||||
@@ -12,14 +12,14 @@ UFile (package = ) [public final class LocalDeclarationsKt {...]
|
||||
UReturnExpression [return <init>()] = Undetermined
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) [<init>()] = external <init>()()
|
||||
UIdentifier (Identifier (Local)) [UIdentifier (Identifier (Local))]
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = Local) [<init>] = external <init>()()
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: Local) [<init>] = external <init>()()
|
||||
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>()()
|
||||
UIdentifier (Identifier (Local)) [UIdentifier (Identifier (Local))]
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = Local) [<init>] = external <init>()()
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: Local) [<init>] = external <init>()()
|
||||
UDeclarationsExpression [var someLocalFun: kotlin.jvm.functions.Function2<? super java.lang.Integer,? super java.lang.String,? extends java.lang.Integer> = fun (@org.jetbrains.annotations.NotNull var text: java.lang.String) {...}] = Undetermined
|
||||
UVariable (name = someLocalFun) [var someLocalFun: kotlin.jvm.functions.Function2<? super java.lang.Integer,? super java.lang.String,? extends java.lang.Integer> = fun (@org.jetbrains.annotations.NotNull var text: java.lang.String) {...}]
|
||||
ULambdaExpression [fun (@org.jetbrains.annotations.NotNull var text: java.lang.String) {...}] = Undetermined
|
||||
@@ -35,4 +35,4 @@ UFile (package = ) [public final class LocalDeclarationsKt {...]
|
||||
USimpleNameReferenceExpression (identifier = bar, resolvesTo = null) [bar] = external bar()()
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) [<init>()] = external <init>()()
|
||||
UIdentifier (Identifier (Local)) [UIdentifier (Identifier (Local))]
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = Local) [<init>] = external <init>()()
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: Local) [<init>] = external <init>()()
|
||||
|
||||
@@ -11,7 +11,7 @@ UFile (package = )
|
||||
ULocalVariable (name = p)
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0))
|
||||
UIdentifier (Identifier (A))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = A)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: A)
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1))
|
||||
UIdentifier (Identifier ({))
|
||||
USimpleNameReferenceExpression (identifier = invoke, resolvesTo = null)
|
||||
|
||||
@@ -128,7 +128,7 @@ UFile (package = )
|
||||
USimpleNameReferenceExpression (identifier = with, resolvesTo = null)
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0))
|
||||
UIdentifier (Identifier (A))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = A)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: A)
|
||||
ULambdaExpression
|
||||
UBlockExpression
|
||||
UQualifiedReferenceExpression
|
||||
|
||||
+1
-1
@@ -128,7 +128,7 @@ UFile (package = )
|
||||
USimpleNameReferenceExpression (identifier = with, resolvesTo = null)
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0))
|
||||
UIdentifier (Identifier (A))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = A)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: A)
|
||||
ULambdaExpression
|
||||
UBlockExpression
|
||||
UQualifiedReferenceExpression
|
||||
|
||||
@@ -13,5 +13,5 @@ UFile (package = A.B.C)
|
||||
USimpleNameReferenceExpression (identifier = C)
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0))
|
||||
UIdentifier (Identifier (Foo))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = Foo)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: Foo)
|
||||
UMethod (name = Bar)
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ UFile (package = )
|
||||
USimpleNameReferenceExpression (identifier = flag)
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
|
||||
UIdentifier (Identifier (Bar))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = Bar)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: Bar)
|
||||
ULiteralExpression (value = 42)
|
||||
ULiteralExpression (value = null)
|
||||
UMethod (name = main)
|
||||
|
||||
+6
-6
@@ -20,7 +20,7 @@ UFile (package = )
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
|
||||
UIdentifier (Identifier (A))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = A)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: A)
|
||||
ULiteralExpression (value = "inner class")
|
||||
UMethod (name = getAnon)
|
||||
UMethod (name = cons)
|
||||
@@ -44,7 +44,7 @@ UFile (package = )
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
|
||||
UIdentifier (Identifier (this))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = A)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: A)
|
||||
UQualifiedReferenceExpression
|
||||
USimpleNameReferenceExpression (identifier = i)
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
|
||||
@@ -57,7 +57,7 @@ UFile (package = )
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
|
||||
UIdentifier (Identifier (A))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = A)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: A)
|
||||
USimpleNameReferenceExpression (identifier = param)
|
||||
UClass (name = C)
|
||||
UMethod (name = foo)
|
||||
@@ -76,7 +76,7 @@ UFile (package = )
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
|
||||
UIdentifier (Identifier (super))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = A)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: A)
|
||||
USimpleNameReferenceExpression (identifier = p)
|
||||
UMethod (name = C)
|
||||
UParameter (name = i)
|
||||
@@ -84,7 +84,7 @@ UFile (package = )
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
|
||||
UIdentifier (Identifier (super))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = A)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: A)
|
||||
USimpleNameReferenceExpression (identifier = i)
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
|
||||
UIdentifier (Identifier (println))
|
||||
@@ -96,5 +96,5 @@ UFile (package = )
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
|
||||
UIdentifier (Identifier (A))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = A)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: A)
|
||||
ULiteralExpression (value = "text")
|
||||
|
||||
+6
-6
@@ -20,7 +20,7 @@ UFile (package = )
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
|
||||
UIdentifier (Identifier (A))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = A)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: A)
|
||||
ULiteralExpression (value = "inner class")
|
||||
UMethod (name = getAnon)
|
||||
UMethod (name = cons)
|
||||
@@ -44,7 +44,7 @@ UFile (package = )
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
|
||||
UIdentifier (Identifier (this))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = A)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: A)
|
||||
UQualifiedReferenceExpression
|
||||
USimpleNameReferenceExpression (identifier = i)
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
|
||||
@@ -57,7 +57,7 @@ UFile (package = )
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
|
||||
UIdentifier (Identifier (A))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = A)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: A)
|
||||
USimpleNameReferenceExpression (identifier = param)
|
||||
UClass (name = C)
|
||||
UMethod (name = foo)
|
||||
@@ -76,7 +76,7 @@ UFile (package = )
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
|
||||
UIdentifier (Identifier (super))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = A)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: A)
|
||||
USimpleNameReferenceExpression (identifier = p)
|
||||
UMethod (name = C)
|
||||
UParameter (name = i)
|
||||
@@ -84,7 +84,7 @@ UFile (package = )
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
|
||||
UIdentifier (Identifier (super))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = A)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: A)
|
||||
USimpleNameReferenceExpression (identifier = i)
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
|
||||
UIdentifier (Identifier (println))
|
||||
@@ -96,5 +96,5 @@ UFile (package = )
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
|
||||
UIdentifier (Identifier (A))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = A)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: A)
|
||||
ULiteralExpression (value = "text")
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ UFile (package = test.pkg)
|
||||
UQualifiedReferenceExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0))
|
||||
UIdentifier (Identifier (Context))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = Context)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: Context)
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
|
||||
UIdentifier (Identifier (inner))
|
||||
USimpleNameReferenceExpression (identifier = inner, resolvesTo = null)
|
||||
@@ -27,4 +27,4 @@ UFile (package = test.pkg)
|
||||
UReturnExpression
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
|
||||
UIdentifier (Identifier (inner))
|
||||
USimpleNameReferenceExpression (identifier = inner, resolvesTo = null)
|
||||
USimpleNameReferenceExpression (identifier = inner, resolvesTo = null)
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ UFile (package = test.pkg)
|
||||
UQualifiedReferenceExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0))
|
||||
UIdentifier (Identifier (Context))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = Context)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: Context)
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
|
||||
UIdentifier (Identifier (inner))
|
||||
USimpleNameReferenceExpression (identifier = inner, resolvesTo = null)
|
||||
|
||||
@@ -13,7 +13,7 @@ UFile (package = )
|
||||
UThrowExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0))
|
||||
UIdentifier (Identifier (UnsupportedOperationException))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = UnsupportedOperationException)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: UnsupportedOperationException)
|
||||
UMethod (name = Model)
|
||||
UBlockExpression
|
||||
UBlockExpression
|
||||
@@ -35,6 +35,6 @@ UFile (package = )
|
||||
UThrowExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
|
||||
UIdentifier (Identifier (UnsupportedOperationException))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = UnsupportedOperationException)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: UnsupportedOperationException)
|
||||
ULiteralExpression (value = "")
|
||||
UMethod (name = )
|
||||
|
||||
@@ -13,7 +13,7 @@ UFile (package = )
|
||||
UThrowExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0))
|
||||
UIdentifier (Identifier (UnsupportedOperationException))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = UnsupportedOperationException)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: UnsupportedOperationException)
|
||||
UMethod (name = Model)
|
||||
UBlockExpression
|
||||
UBlockExpression
|
||||
@@ -35,6 +35,6 @@ UFile (package = )
|
||||
UThrowExpression
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
|
||||
UIdentifier (Identifier (UnsupportedOperationException))
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = UnsupportedOperationException)
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: UnsupportedOperationException)
|
||||
ULiteralExpression (value = "")
|
||||
UMethod (name = Model$1$1)
|
||||
|
||||
@@ -13,7 +13,7 @@ UFile (package = ) [public abstract interface Callback {...]
|
||||
UThrowExpression [throw <init>()] : PsiType:Void
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) [<init>()] : PsiType:UnsupportedOperationException
|
||||
UIdentifier (Identifier (UnsupportedOperationException)) [UIdentifier (Identifier (UnsupportedOperationException))]
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = UnsupportedOperationException) [<init>] : PsiType:UnsupportedOperationException
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: UnsupportedOperationException) [<init>] : PsiType:UnsupportedOperationException
|
||||
UMethod (name = Model) [public fun Model() {...}]
|
||||
UBlockExpression [{...}]
|
||||
UBlockExpression [{...}] : PsiType:void
|
||||
@@ -35,6 +35,6 @@ UFile (package = ) [public abstract interface Callback {...]
|
||||
UThrowExpression [throw <init>("")] : PsiType:Void
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1)) [<init>("")] : PsiType:UnsupportedOperationException
|
||||
UIdentifier (Identifier (UnsupportedOperationException)) [UIdentifier (Identifier (UnsupportedOperationException))]
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = UnsupportedOperationException) [<init>] : PsiType:UnsupportedOperationException
|
||||
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: UnsupportedOperationException) [<init>] : PsiType:UnsupportedOperationException
|
||||
ULiteralExpression (value = "") [""] : PsiType:String
|
||||
UMethod (name = Model$1$1) [fun Model$1$1() = UastEmptyExpression]
|
||||
|
||||
@@ -597,7 +597,7 @@ class KotlinUastApiTest : AbstractKotlinUastTest() {
|
||||
val localFunctionResolved = localFunction.resolve()
|
||||
assertNotNull(localFunctionResolved)
|
||||
val classReference = localFunction.classReference ?: kfail("classReference expected")
|
||||
assertEquals("USimpleNameReferenceExpression (identifier = <init>, resolvesTo = Local)", classReference.asLogString())
|
||||
assertEquals("USimpleNameReferenceExpression (identifier = <init>, resolvesTo = PsiClass: Local)", classReference.asLogString())
|
||||
val localClass = classReference.resolve().toUElement() ?: kfail("uelement expected")
|
||||
assertEquals("UClass (name = Local)", localClass.asLogString())
|
||||
assertEquals(localClass, localFunctionResolved.toUElement())
|
||||
|
||||
Reference in New Issue
Block a user