Uast: more cases for KotlinUSimpleReferenceExpression resolve (KT-30957, KT-27385)
This commit is contained in:
+19
-10
@@ -17,18 +17,17 @@
|
||||
package org.jetbrains.uast.kotlin
|
||||
|
||||
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.descriptors.PackageViewDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.load.java.sam.SamConstructorDescriptor
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getAssignmentByLHS
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForSelectorOrThis
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.ImportedFromObjectCallableDescriptor
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.source.getPsi
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.constant
|
||||
@@ -45,13 +44,27 @@ open class KotlinUSimpleReferenceExpression(
|
||||
private val resolvedDeclaration: PsiElement? by lz {
|
||||
psi.resolveCallToDeclaration()?.let { return@lz it }
|
||||
|
||||
val declarationDescriptor = psi.analyze()[BindingContext.REFERENCE_TARGET, psi] ?: return@lz null
|
||||
var declarationDescriptor = psi.analyze()[BindingContext.REFERENCE_TARGET, psi] ?: return@lz null
|
||||
if (declarationDescriptor is ImportedFromObjectCallableDescriptor<*>) {
|
||||
declarationDescriptor = declarationDescriptor.callableFromObject
|
||||
}
|
||||
if (declarationDescriptor is SyntheticJavaPropertyDescriptor) {
|
||||
declarationDescriptor = when (psi.readWriteAccess()) {
|
||||
ReferenceAccess.WRITE, ReferenceAccess.READ_WRITE ->
|
||||
declarationDescriptor.setMethod ?: declarationDescriptor.getMethod
|
||||
ReferenceAccess.READ -> declarationDescriptor.getMethod
|
||||
}
|
||||
}
|
||||
|
||||
if (declarationDescriptor is PackageViewDescriptor) {
|
||||
return@lz JavaPsiFacade.getInstance(psi.project).findPackage(declarationDescriptor.fqName.asString())
|
||||
}
|
||||
|
||||
resolveToPsiClass(this, declarationDescriptor, psi)
|
||||
resolveToPsiClass(this, declarationDescriptor, psi)?.let { return@lz it }
|
||||
if (declarationDescriptor is DeclarationDescriptorWithSource) {
|
||||
declarationDescriptor.source.getPsi()?.let { it.getMaybeLightElement() ?: it }?.let { return@lz it }
|
||||
}
|
||||
return@lz resolveDeserialized(psi, declarationDescriptor, psi.readWriteAccess())
|
||||
}
|
||||
|
||||
override val identifier get() = psi.getReferencedName()
|
||||
@@ -179,10 +192,6 @@ open class KotlinUSimpleReferenceExpression(
|
||||
}
|
||||
}
|
||||
|
||||
enum class ReferenceAccess(val isRead: Boolean, val isWrite: Boolean) {
|
||||
READ(true, false), WRITE(false, true), READ_WRITE(true, true)
|
||||
}
|
||||
|
||||
private fun KtExpression.readWriteAccess(): ReferenceAccess {
|
||||
var expression = getQualifiedExpressionForSelectorOrThis()
|
||||
loop@ while (true) {
|
||||
|
||||
+19
-10
@@ -17,18 +17,17 @@
|
||||
package org.jetbrains.uast.kotlin
|
||||
|
||||
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.descriptors.PackageViewDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.load.java.sam.SamConstructorDescriptor
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getAssignmentByLHS
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForSelectorOrThis
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.ImportedFromObjectCallableDescriptor
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.source.getPsi
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.constant
|
||||
@@ -45,13 +44,27 @@ open class KotlinUSimpleReferenceExpression(
|
||||
private val resolvedDeclaration: PsiElement? by lz {
|
||||
psi.resolveCallToDeclaration()?.let { return@lz it }
|
||||
|
||||
val declarationDescriptor = psi.analyze()[BindingContext.REFERENCE_TARGET, psi] ?: return@lz null
|
||||
var declarationDescriptor = psi.analyze()[BindingContext.REFERENCE_TARGET, psi] ?: return@lz null
|
||||
if (declarationDescriptor is ImportedFromObjectCallableDescriptor<*>) {
|
||||
declarationDescriptor = declarationDescriptor.callableFromObject
|
||||
}
|
||||
if (declarationDescriptor is SyntheticJavaPropertyDescriptor) {
|
||||
declarationDescriptor = when (psi.readWriteAccess()) {
|
||||
ReferenceAccess.WRITE, ReferenceAccess.READ_WRITE ->
|
||||
declarationDescriptor.setMethod ?: declarationDescriptor.getMethod
|
||||
ReferenceAccess.READ -> declarationDescriptor.getMethod
|
||||
}
|
||||
}
|
||||
|
||||
if (declarationDescriptor is PackageViewDescriptor) {
|
||||
return@lz JavaPsiFacade.getInstance(psi.project).findPackage(declarationDescriptor.fqName.asString())
|
||||
}
|
||||
|
||||
resolveToPsiClass(this, declarationDescriptor, psi)
|
||||
resolveToPsiClass(this, declarationDescriptor, psi)?.let { return@lz it }
|
||||
if (declarationDescriptor is DeclarationDescriptorWithSource) {
|
||||
declarationDescriptor.source.getPsi()?.let { it.getMaybeLightElement() ?: it }?.let { return@lz it }
|
||||
}
|
||||
return@lz resolveDeserialized(psi, declarationDescriptor, psi.readWriteAccess())
|
||||
}
|
||||
|
||||
override val identifier get() = psi.getReferencedName()
|
||||
@@ -177,10 +190,6 @@ open class KotlinUSimpleReferenceExpression(
|
||||
}
|
||||
}
|
||||
|
||||
enum class ReferenceAccess(val isRead: Boolean, val isWrite: Boolean) {
|
||||
READ(true, false), WRITE(false, true), READ_WRITE(true, true)
|
||||
}
|
||||
|
||||
private fun KtExpression.readWriteAccess(): ReferenceAccess {
|
||||
var expression = getQualifiedExpressionForSelectorOrThis()
|
||||
loop@ while (true) {
|
||||
|
||||
+56
-7
@@ -40,6 +40,8 @@ import org.jetbrains.kotlin.load.java.sam.SamConstructorDescriptor
|
||||
import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinaryPackageSourceElement
|
||||
import org.jetbrains.kotlin.load.kotlin.TypeMappingMode
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
||||
import org.jetbrains.kotlin.metadata.deserialization.getExtensionOrNull
|
||||
import org.jetbrains.kotlin.metadata.jvm.JvmProtoBuf
|
||||
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmMemberSignature
|
||||
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmProtoBufUtil
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
@@ -96,7 +98,7 @@ internal fun resolveSource(context: KtElement, descriptor: DeclarationDescriptor
|
||||
return when (source) {
|
||||
is KtFunction -> LightClassUtil.getLightClassMethod(source)
|
||||
is PsiMethod -> source
|
||||
null -> resolveDeserialized(context, descriptor)
|
||||
null -> resolveDeserialized(context, descriptor) as? PsiMethod
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
@@ -128,7 +130,11 @@ internal fun resolveToPsiClass(uElement: UElement, declarationDescriptor: Declar
|
||||
}?.toPsiType(uElement, context, true).let { PsiTypesUtil.getPsiClass(it) }
|
||||
|
||||
|
||||
private fun resolveDeserialized(context: KtElement, descriptor: DeclarationDescriptor): PsiMethod? {
|
||||
internal fun resolveDeserialized(
|
||||
context: KtElement,
|
||||
descriptor: DeclarationDescriptor,
|
||||
accessHint: ReferenceAccess? = null
|
||||
): PsiModifierListOwner? {
|
||||
if (descriptor !is DeserializedCallableMemberDescriptor) return null
|
||||
|
||||
val psiClass = resolveContainingDeserializedClass(context, descriptor) ?: return null
|
||||
@@ -139,11 +145,10 @@ private fun resolveDeserialized(context: KtElement, descriptor: DeclarationDescr
|
||||
|
||||
return when (proto) {
|
||||
is ProtoBuf.Function -> {
|
||||
val signature = JvmProtoBufUtil.getJvmMethodSignature(proto, nameResolver, typeTable)
|
||||
?: getMethodSignatureFromDescriptor(context, descriptor)
|
||||
?: return null
|
||||
|
||||
psiClass.methods.firstOrNull { it.name == signature.name && it.matchesDesc(signature.desc) }
|
||||
psiClass.getMethodBySignature(
|
||||
JvmProtoBufUtil.getJvmMethodSignature(proto, nameResolver, typeTable)
|
||||
?: getMethodSignatureFromDescriptor(context, descriptor)
|
||||
)
|
||||
}
|
||||
is ProtoBuf.Constructor -> {
|
||||
val signature = JvmProtoBufUtil.getJvmConstructorSignature(proto, nameResolver, typeTable)
|
||||
@@ -152,10 +157,49 @@ private fun resolveDeserialized(context: KtElement, descriptor: DeclarationDescr
|
||||
|
||||
psiClass.constructors.firstOrNull { it.matchesDesc(signature.desc) }
|
||||
}
|
||||
is ProtoBuf.Property -> {
|
||||
JvmProtoBufUtil.getJvmFieldSignature(proto, nameResolver, typeTable, false)
|
||||
?.let { signature -> psiClass.fields.firstOrNull { it.name == signature.name } }
|
||||
?.let { return it }
|
||||
|
||||
val propertySignature = proto.getExtensionOrNull(JvmProtoBuf.propertySignature)
|
||||
if (propertySignature != null) {
|
||||
with(propertySignature) {
|
||||
when {
|
||||
hasGetter() && accessHint?.isRead != false -> getter
|
||||
hasSetter() && accessHint?.isWrite != false -> setter
|
||||
else -> null // it should have been handled by the previous case
|
||||
}
|
||||
}?.let { methodSignature ->
|
||||
psiClass.getMethodBySignature(
|
||||
nameResolver.getString(methodSignature.name),
|
||||
if (methodSignature.hasDesc()) nameResolver.getString(methodSignature.desc) else null
|
||||
)
|
||||
}?.let { return it }
|
||||
|
||||
} else if (proto.hasName()) {
|
||||
// Property without a Property signature, looks like a @JvmField
|
||||
val name = nameResolver.getString(proto.name)
|
||||
psiClass.fields
|
||||
.firstOrNull { it.name == name }
|
||||
?.let { return it }
|
||||
}
|
||||
|
||||
getMethodSignatureFromDescriptor(context, descriptor)
|
||||
?.let { signature -> psiClass.getMethodBySignature(signature) }
|
||||
?.let { return it }
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
private fun PsiClass.getMethodBySignature(methodSignature: JvmMemberSignature?) = methodSignature?.let { signature ->
|
||||
getMethodBySignature(signature.name, signature.desc)
|
||||
}
|
||||
|
||||
private fun PsiClass.getMethodBySignature(name: String, descr: String?) =
|
||||
methods.firstOrNull { method -> method.name == name && descr?.let { method.matchesDesc(it) } ?: true }
|
||||
|
||||
private fun PsiMethod.matchesDesc(desc: String) = desc == buildString {
|
||||
parameterList.parameters.joinTo(this, separator = "", prefix = "(", postfix = ")") { MapPsiToAsmDesc.typeDesc(it.type) }
|
||||
append(MapPsiToAsmDesc.typeDesc(returnType ?: PsiType.VOID))
|
||||
@@ -358,4 +402,9 @@ internal fun KotlinULambdaExpression.getFunctionalInterfaceType(): PsiType? {
|
||||
|
||||
internal fun unwrapFakeFileForLightClass(file: PsiFile): PsiFile = (file as? FakeFileForLightClass)?.ktFile ?: file
|
||||
|
||||
// mb merge with org.jetbrains.kotlin.idea.references.ReferenceAccess ?
|
||||
internal enum class ReferenceAccess(val isRead: Boolean, val isWrite: Boolean) {
|
||||
READ(true, false), WRITE(false, true), READ_WRITE(true, true)
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = In
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = runnable) -> LightVariableBuilder:runnable: runnable
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) -> USimpleNameReferenceExpression (identifier = run) -> KtLightMethodImpl:run: run
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) -> USimpleNameReferenceExpression (identifier = Runnable) -> PsiClass:Runnable: Runnable
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) -> USimpleNameReferenceExpression (identifier = println) -> null: null
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) -> USimpleNameReferenceExpression (identifier = println) -> PsiMethod:println: println
|
||||
UBlockExpression -> UQualifiedReferenceExpression -> PsiMethod:run: run
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = runnable2) -> LightVariableBuilder:runnable2: runnable2
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) -> USimpleNameReferenceExpression (identifier = run) -> PsiMethod:run: run
|
||||
|
||||
+7
-7
@@ -4,20 +4,20 @@ UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1)) ->
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = i) -> Light Parameter: i
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) -> USimpleNameReferenceExpression (identifier = toString) -> null: null
|
||||
UTypeReferenceExpression (name = java.lang.String) -> USimpleNameReferenceExpression (identifier = String) -> PsiClass:String: String
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) -> USimpleNameReferenceExpression (identifier = println) -> null: null
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) -> USimpleNameReferenceExpression (identifier = println) -> PsiMethod:println: println
|
||||
UTypeReferenceExpression (name = int) -> USimpleNameReferenceExpression (identifier = Int) -> PsiClass:Integer: Integer
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1)) -> UQualifiedReferenceExpression -> null: null
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = i) -> Light Parameter: i
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) -> USimpleNameReferenceExpression (identifier = toString) -> null: null
|
||||
UTypeReferenceExpression (name = java.lang.String) -> USimpleNameReferenceExpression (identifier = String) -> PsiClass:String: String
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) -> USimpleNameReferenceExpression (identifier = println) -> null: null
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) -> USimpleNameReferenceExpression (identifier = println) -> null: null
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) -> USimpleNameReferenceExpression (identifier = println) -> PsiMethod:println: println
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) -> USimpleNameReferenceExpression (identifier = println) -> PsiMethod:println: println
|
||||
UTypeReferenceExpression (name = int) -> USimpleNameReferenceExpression (identifier = Int) -> PsiClass:Integer: Integer
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1)) -> UQualifiedReferenceExpression -> null: null
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = i) -> Light Parameter: i
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) -> USimpleNameReferenceExpression (identifier = toString) -> null: null
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) -> USimpleNameReferenceExpression (identifier = println) -> null: null
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) -> USimpleNameReferenceExpression (identifier = println) -> null: null
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) -> USimpleNameReferenceExpression (identifier = println) -> PsiMethod:println: println
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) -> USimpleNameReferenceExpression (identifier = println) -> PsiMethod:println: println
|
||||
UTypeReferenceExpression (name = java.lang.String) -> USimpleNameReferenceExpression (identifier = String) -> PsiClass:String: String
|
||||
UTypeReferenceExpression (name = int) -> USimpleNameReferenceExpression (identifier = Int) -> PsiClass:Integer: Integer
|
||||
UBinaryExpression (operator = =) -> USimpleNameReferenceExpression (identifier = a) -> KtLightMethodImpl:getA: getA
|
||||
@@ -30,7 +30,7 @@ UTypeReferenceExpression (name = java.lang.String) -> USimpleNameReferenceExpres
|
||||
UBinaryExpression (operator = =) -> USimpleNameReferenceExpression (identifier = =) -> null: null
|
||||
UBinaryExpression (operator = =) -> USimpleNameReferenceExpression (identifier = s) -> Light Parameter: s
|
||||
UTypeReferenceExpression (name = java.lang.String) -> USimpleNameReferenceExpression (identifier = String) -> PsiClass:String: String
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) -> USimpleNameReferenceExpression (identifier = println) -> null: null
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) -> USimpleNameReferenceExpression (identifier = println) -> PsiMethod:println: println
|
||||
UTypeReferenceExpression (name = int) -> USimpleNameReferenceExpression (identifier = Int) -> PsiClass:Integer: Integer
|
||||
UBinaryExpression (operator = =) -> USimpleNameReferenceExpression (identifier = a) -> KtLightMethodImpl:getA: getA
|
||||
UBinaryExpression (operator = =) -> USimpleNameReferenceExpression (identifier = =) -> null: null
|
||||
@@ -45,4 +45,4 @@ UTypeReferenceExpression (name = java.lang.String) -> USimpleNameReferenceExpres
|
||||
ULocalVariable (name = local) -> USimpleNameReferenceExpression (identifier = s) -> Light Parameter: s
|
||||
UBlockExpression -> UQualifiedReferenceExpression -> null: null
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = local) -> LightVariableBuilder:local: local
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) -> USimpleNameReferenceExpression (identifier = toString) -> null: null
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) -> USimpleNameReferenceExpression (identifier = toString) -> PsiMethod:toString: toString
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import java.lang.Thread.currentThread
|
||||
import java.lang.Thread.NORM_PRIORITY
|
||||
import java.lang.Thread.UncaughtExceptionHandler
|
||||
import java.lang.Thread.sleep
|
||||
import kotlin.collections.emptyList
|
||||
import kotlin.Int.Companion.SIZE_BYTES
|
||||
@@ -0,0 +1,40 @@
|
||||
UImportStatement (isOnDemand = false) -> UQualifiedReferenceExpression -> null: null
|
||||
UQualifiedReferenceExpression -> UQualifiedReferenceExpression -> null: null
|
||||
UQualifiedReferenceExpression -> UQualifiedReferenceExpression -> null: null
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = java) -> PsiPackage:java: java
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = lang) -> PsiPackage:java.lang: lang
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = Thread) -> PsiClass:Thread: Thread
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = currentThread) -> PsiMethod:currentThread: currentThread
|
||||
UImportStatement (isOnDemand = false) -> UQualifiedReferenceExpression -> null: null
|
||||
UQualifiedReferenceExpression -> UQualifiedReferenceExpression -> null: null
|
||||
UQualifiedReferenceExpression -> UQualifiedReferenceExpression -> null: null
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = java) -> PsiPackage:java: java
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = lang) -> PsiPackage:java.lang: lang
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = Thread) -> PsiClass:Thread: Thread
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = NORM_PRIORITY) -> PsiField:NORM_PRIORITY: NORM_PRIORITY
|
||||
UImportStatement (isOnDemand = false) -> UQualifiedReferenceExpression -> null: null
|
||||
UQualifiedReferenceExpression -> UQualifiedReferenceExpression -> null: null
|
||||
UQualifiedReferenceExpression -> UQualifiedReferenceExpression -> null: null
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = java) -> PsiPackage:java: java
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = lang) -> PsiPackage:java.lang: lang
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = Thread) -> PsiClass:Thread: Thread
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = UncaughtExceptionHandler) -> PsiClass:UncaughtExceptionHandler: UncaughtExceptionHandler
|
||||
UImportStatement (isOnDemand = false) -> UQualifiedReferenceExpression -> null: null
|
||||
UQualifiedReferenceExpression -> UQualifiedReferenceExpression -> null: null
|
||||
UQualifiedReferenceExpression -> UQualifiedReferenceExpression -> null: null
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = java) -> PsiPackage:java: java
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = lang) -> PsiPackage:java.lang: lang
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = Thread) -> PsiClass:Thread: Thread
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = sleep) -> null: null
|
||||
UImportStatement (isOnDemand = false) -> UQualifiedReferenceExpression -> null: null
|
||||
UQualifiedReferenceExpression -> UQualifiedReferenceExpression -> null: null
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = kotlin) -> PsiPackage:kotlin: kotlin
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = collections) -> PsiPackage:kotlin.collections: collections
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = emptyList) -> PsiMethod:emptyList: emptyList
|
||||
UImportStatement (isOnDemand = false) -> UQualifiedReferenceExpression -> null: null
|
||||
UQualifiedReferenceExpression -> UQualifiedReferenceExpression -> null: null
|
||||
UQualifiedReferenceExpression -> UQualifiedReferenceExpression -> null: null
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = kotlin) -> PsiPackage:kotlin: kotlin
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = Int) -> PsiClass:Integer: Integer
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = Companion) -> PsiClass:IntCompanionObject: IntCompanionObject
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = SIZE_BYTES) -> PsiField:SIZE_BYTES: SIZE_BYTES
|
||||
+3
@@ -11,6 +11,9 @@ fun bar() {
|
||||
listOf(A()).forEach { println(it) } // inline from stdlib
|
||||
listOf("").joinToString() // not inline from stdlib
|
||||
listOf("").size // property from stdlib
|
||||
listOf("").indices // property from stdlib without backing method
|
||||
val date: java.util.Date = java.util.Date()
|
||||
date.time = 1000 // setter from Java
|
||||
listOf("").last() // overloaded extension from stdlib
|
||||
mutableMapOf(1 to "1").entries.first().setValue("123") // call on nested method in stdlib
|
||||
val intRange = 0L..3L
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
UBlockExpression -> UQualifiedReferenceExpression -> KtLightMethodImpl:foo: foo
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) -> USimpleNameReferenceExpression (identifier = A) -> KtLightClassImpl:open class A {
|
||||
fun foo() {}
|
||||
inline fun inlineFoo() {
|
||||
|
||||
}
|
||||
}: A
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) -> USimpleNameReferenceExpression (identifier = foo) -> KtLightMethodImpl:foo: foo
|
||||
UBlockExpression -> UQualifiedReferenceExpression -> KtLightMethodImpl:inlineFoo: inlineFoo
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) -> USimpleNameReferenceExpression (identifier = A) -> KtLightClassImpl:open class A {
|
||||
fun foo() {}
|
||||
inline fun inlineFoo() {
|
||||
|
||||
}
|
||||
}: A
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) -> USimpleNameReferenceExpression (identifier = inlineFoo) -> KtLightMethodImpl:inlineFoo: inlineFoo
|
||||
UBlockExpression -> UQualifiedReferenceExpression -> null: null
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) -> USimpleNameReferenceExpression (identifier = listOf) -> PsiMethod:listOf: listOf
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) -> USimpleNameReferenceExpression (identifier = A) -> KtLightClassImpl:open class A {
|
||||
fun foo() {}
|
||||
inline fun inlineFoo() {
|
||||
|
||||
}
|
||||
}: A
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) -> USimpleNameReferenceExpression (identifier = forEach) -> PsiMethod:forEach: forEach
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) -> USimpleNameReferenceExpression (identifier = println) -> PsiMethod:println: println
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) -> USimpleNameReferenceExpression (identifier = it) -> null: null
|
||||
UBlockExpression -> UQualifiedReferenceExpression -> null: null
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) -> USimpleNameReferenceExpression (identifier = listOf) -> PsiMethod:listOf: listOf
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) -> USimpleNameReferenceExpression (identifier = joinToString) -> PsiMethod:joinToString: joinToString
|
||||
UBlockExpression -> UQualifiedReferenceExpression -> null: null
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) -> USimpleNameReferenceExpression (identifier = listOf) -> PsiMethod:listOf: listOf
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = size) -> PsiMethod:size: size
|
||||
UBlockExpression -> UQualifiedReferenceExpression -> null: null
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) -> USimpleNameReferenceExpression (identifier = listOf) -> PsiMethod:listOf: listOf
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = indices) -> PsiMethod:getIndices: getIndices
|
||||
UTypeReferenceExpression (name = java.util.Date) -> USimpleNameReferenceExpression (identifier = java) -> PsiPackage:java: java
|
||||
UTypeReferenceExpression (name = java.util.Date) -> USimpleNameReferenceExpression (identifier = util) -> PsiPackage:java.util: util
|
||||
UTypeReferenceExpression (name = java.util.Date) -> USimpleNameReferenceExpression (identifier = Date) -> PsiClass:Date: Date
|
||||
ULocalVariable (name = date) -> UQualifiedReferenceExpression -> PsiMethod:Date: Date
|
||||
UQualifiedReferenceExpression -> UQualifiedReferenceExpression -> null: null
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = java) -> PsiPackage:java: java
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = util) -> PsiPackage:java.util: util
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) -> USimpleNameReferenceExpression (identifier = Date) -> PsiMethod:Date: Date
|
||||
UBinaryExpression (operator = =) -> UQualifiedReferenceExpression -> null: null
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = date) -> LightVariableBuilder:date: date
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = time) -> PsiMethod:setTime: setTime
|
||||
UBinaryExpression (operator = =) -> USimpleNameReferenceExpression (identifier = =) -> null: null
|
||||
UBlockExpression -> UQualifiedReferenceExpression -> null: null
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) -> USimpleNameReferenceExpression (identifier = listOf) -> PsiMethod:listOf: listOf
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) -> USimpleNameReferenceExpression (identifier = last) -> PsiMethod:last: last
|
||||
UBlockExpression -> UQualifiedReferenceExpression -> null: null
|
||||
UQualifiedReferenceExpression -> UQualifiedReferenceExpression -> null: null
|
||||
UQualifiedReferenceExpression -> UQualifiedReferenceExpression -> null: null
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) -> USimpleNameReferenceExpression (identifier = mutableMapOf) -> PsiMethod:mutableMapOf: mutableMapOf
|
||||
UBinaryExpression (operator = <other>) -> USimpleNameReferenceExpression (identifier = to) -> PsiMethod:to: to
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = entries) -> null: null
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) -> USimpleNameReferenceExpression (identifier = first) -> PsiMethod:first: first
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) -> USimpleNameReferenceExpression (identifier = setValue) -> PsiMethod:setValue: setValue
|
||||
UBinaryExpression (operator = ..) -> USimpleNameReferenceExpression (identifier = ..) -> null: null
|
||||
UBlockExpression -> UQualifiedReferenceExpression -> null: null
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = intRange) -> LightVariableBuilder:intRange: intRange
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) -> USimpleNameReferenceExpression (identifier = contains) -> PsiMethod:longRangeContains: longRangeContains
|
||||
UBinaryExpressionWithType -> USimpleNameReferenceExpression (identifier = as) -> null: null
|
||||
UTypeReferenceExpression (name = int) -> USimpleNameReferenceExpression (identifier = Int) -> PsiClass:Integer: Integer
|
||||
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 2)) -> USimpleNameReferenceExpression (identifier = IntRange) -> PsiClass:IntRange: IntRange
|
||||
UTypeReferenceExpression (name = A) -> USimpleNameReferenceExpression (identifier = A) -> KtLightClassImpl:open class A {
|
||||
fun foo() {}
|
||||
inline fun inlineFoo() {
|
||||
|
||||
}
|
||||
}: A
|
||||
UTypeReferenceExpression (name = T) -> USimpleNameReferenceExpression (identifier = T) -> KotlinLightTypeParameter:T: T
|
||||
UBlockExpression -> UQualifiedReferenceExpression -> KtLightMethodImpl:foo: foo
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = t) -> Light Parameter: t
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) -> USimpleNameReferenceExpression (identifier = foo) -> KtLightMethodImpl:foo: foo
|
||||
UTypeReferenceExpression (name = java.util.List<? extends A>) -> USimpleNameReferenceExpression (identifier = List) -> PsiClass:List: List
|
||||
UTypeReferenceExpression (name = A) -> USimpleNameReferenceExpression (identifier = A) -> KtLightClassImpl:open class A {
|
||||
fun foo() {}
|
||||
inline fun inlineFoo() {
|
||||
|
||||
}
|
||||
}: A
|
||||
UTypeReferenceExpression (name = T) -> USimpleNameReferenceExpression (identifier = T) -> KotlinLightTypeParameter:T: T
|
||||
UBlockExpression -> UQualifiedReferenceExpression -> null: null
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = listT) -> Light Parameter: listT
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) -> USimpleNameReferenceExpression (identifier = isEmpty) -> PsiMethod:isEmpty: isEmpty
|
||||
UForEachExpression -> USimpleNameReferenceExpression (identifier = listT) -> Light Parameter: listT
|
||||
UBlockExpression -> UQualifiedReferenceExpression -> KtLightMethodImpl:foo: foo
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = a) -> VALUE_PARAMETER: a
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) -> USimpleNameReferenceExpression (identifier = foo) -> KtLightMethodImpl:foo: foo
|
||||
@@ -1,5 +1,5 @@
|
||||
UTypeReferenceExpression (name = kotlin.Suppress) -> USimpleNameReferenceExpression (identifier = Suppress) -> PsiClass:Suppress: Suppress
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) -> USimpleNameReferenceExpression (identifier = println) -> null: null
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) -> USimpleNameReferenceExpression (identifier = println) -> PsiMethod:println: println
|
||||
UTypeReferenceExpression (name = kotlin.SinceKotlin) -> USimpleNameReferenceExpression (identifier = kotlin) -> PsiPackage:kotlin: kotlin
|
||||
UTypeReferenceExpression (name = kotlin.SinceKotlin) -> USimpleNameReferenceExpression (identifier = SinceKotlin) -> PsiClass:SinceKotlin: SinceKotlin
|
||||
UTypeReferenceExpression (name = java.lang.String) -> USimpleNameReferenceExpression (identifier = String) -> PsiClass:String: String
|
||||
|
||||
@@ -15,13 +15,13 @@ UTypeReferenceExpression (name = T) -> USimpleNameReferenceExpression (identifie
|
||||
UExpressionList (elvis) -> USimpleNameReferenceExpression (identifier = ?:) -> null: null
|
||||
UTypeReferenceExpression (name = java.util.List<? extends T>) -> USimpleNameReferenceExpression (identifier = List) -> PsiClass:List: List
|
||||
UTypeReferenceExpression (name = T) -> USimpleNameReferenceExpression (identifier = T) -> KotlinLightTypeParameter:T: T
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) -> USimpleNameReferenceExpression (identifier = listOf) -> null: null
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) -> USimpleNameReferenceExpression (identifier = listOf) -> PsiMethod:listOf: listOf
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) -> USimpleNameReferenceExpression (identifier = at) -> LightVariableBuilder:at: at
|
||||
UTypeReferenceExpression (name = java.util.List<? extends java.lang.String>) -> USimpleNameReferenceExpression (identifier = List) -> PsiClass:List: List
|
||||
UTypeReferenceExpression (name = java.lang.String) -> USimpleNameReferenceExpression (identifier = String) -> PsiClass:String: String
|
||||
ULocalVariable (name = tsl) -> UQualifiedReferenceExpression -> null: null
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = tl) -> LightVariableBuilder:tl: tl
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) -> USimpleNameReferenceExpression (identifier = map) -> null: null
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) -> USimpleNameReferenceExpression (identifier = map) -> PsiMethod:map: map
|
||||
UBlockExpression -> UQualifiedReferenceExpression -> null: null
|
||||
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = it) -> null: null
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) -> USimpleNameReferenceExpression (identifier = toString) -> null: null
|
||||
@@ -35,4 +35,4 @@ UTypeReferenceExpression (name = T) -> USimpleNameReferenceExpression (identifie
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) -> USimpleNameReferenceExpression (identifier = parameterizedFoo) -> KtLightMethodImpl:parameterizedFoo: parameterizedFoo
|
||||
UTypeReferenceExpression (name = java.util.List<? extends java.lang.String>) -> USimpleNameReferenceExpression (identifier = List) -> PsiClass:List: List
|
||||
UTypeReferenceExpression (name = java.lang.String) -> USimpleNameReferenceExpression (identifier = String) -> PsiClass:String: String
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) -> USimpleNameReferenceExpression (identifier = emptyList) -> null: null
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) -> USimpleNameReferenceExpression (identifier = emptyList) -> PsiMethod:emptyList: emptyList
|
||||
|
||||
@@ -27,4 +27,10 @@ class KotlinUastResolveEverythingTest : AbstractKotlinResolveEverythingTest() {
|
||||
@Test
|
||||
fun testTypeReferences() = doTest("TypeReferences")
|
||||
|
||||
@Test
|
||||
fun testImports() = doTest("Imports")
|
||||
|
||||
@Test
|
||||
fun testResolve() = doTest("Resolve")
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user