Add a LookupLocation to 'getSyntheticExtensionProperties()', use it in 'DebuggerFieldSyntheticScopeProvider'
This commit is contained in:
+1
-1
@@ -87,5 +87,5 @@ fun getSourceElement(descriptor: DeclarationDescriptor): SourceElement =
|
|||||||
descriptor.toSourceElement
|
descriptor.toSourceElement
|
||||||
}
|
}
|
||||||
|
|
||||||
private val DeclarationDescriptor.toSourceElement: SourceElement
|
val DeclarationDescriptor.toSourceElement: SourceElement
|
||||||
get() = if (this is DeclarationDescriptorWithSource) source else SourceElement.NO_SOURCE
|
get() = if (this is DeclarationDescriptorWithSource) source else SourceElement.NO_SOURCE
|
||||||
|
|||||||
+4
-1
@@ -227,7 +227,10 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager, private val l
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>): Collection<PropertyDescriptor> {
|
override fun getSyntheticExtensionProperties(
|
||||||
|
receiverTypes: Collection<KotlinType>,
|
||||||
|
location: LookupLocation
|
||||||
|
): Collection<PropertyDescriptor> {
|
||||||
val result = ArrayList<PropertyDescriptor>()
|
val result = ArrayList<PropertyDescriptor>()
|
||||||
val processedTypes = HashSet<TypeConstructor>()
|
val processedTypes = HashSet<TypeConstructor>()
|
||||||
receiverTypes.forEach { result.collectSyntheticProperties(it.constructor, processedTypes) }
|
receiverTypes.forEach { result.collectSyntheticProperties(it.constructor, processedTypes) }
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ interface SyntheticScope {
|
|||||||
fun getSyntheticStaticFunctions(scope: ResolutionScope, name: Name, location: LookupLocation): Collection<FunctionDescriptor>
|
fun getSyntheticStaticFunctions(scope: ResolutionScope, name: Name, location: LookupLocation): Collection<FunctionDescriptor>
|
||||||
fun getSyntheticConstructors(scope: ResolutionScope, name: Name, location: LookupLocation): Collection<FunctionDescriptor>
|
fun getSyntheticConstructors(scope: ResolutionScope, name: Name, location: LookupLocation): Collection<FunctionDescriptor>
|
||||||
|
|
||||||
fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>): Collection<PropertyDescriptor>
|
fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>, location: LookupLocation): Collection<PropertyDescriptor>
|
||||||
fun getSyntheticMemberFunctions(receiverTypes: Collection<KotlinType>): Collection<FunctionDescriptor>
|
fun getSyntheticMemberFunctions(receiverTypes: Collection<KotlinType>): Collection<FunctionDescriptor>
|
||||||
fun getSyntheticStaticFunctions(scope: ResolutionScope): Collection<FunctionDescriptor>
|
fun getSyntheticStaticFunctions(scope: ResolutionScope): Collection<FunctionDescriptor>
|
||||||
fun getSyntheticConstructors(scope: ResolutionScope): Collection<FunctionDescriptor>
|
fun getSyntheticConstructors(scope: ResolutionScope): Collection<FunctionDescriptor>
|
||||||
@@ -70,7 +70,10 @@ interface SyntheticScope {
|
|||||||
return emptyList()
|
return emptyList()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>): Collection<PropertyDescriptor> {
|
override fun getSyntheticExtensionProperties(
|
||||||
|
receiverTypes: Collection<KotlinType>,
|
||||||
|
location: LookupLocation
|
||||||
|
): Collection<PropertyDescriptor> {
|
||||||
return emptyList()
|
return emptyList()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,8 +116,8 @@ fun SyntheticScopes.collectSyntheticStaticFunctions(scope: ResolutionScope, name
|
|||||||
fun SyntheticScopes.collectSyntheticConstructors(scope: ResolutionScope, name: Name, location: LookupLocation)
|
fun SyntheticScopes.collectSyntheticConstructors(scope: ResolutionScope, name: Name, location: LookupLocation)
|
||||||
= scopes.flatMap { it.getSyntheticConstructors(scope, name, location) }
|
= scopes.flatMap { it.getSyntheticConstructors(scope, name, location) }
|
||||||
|
|
||||||
fun SyntheticScopes.collectSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>)
|
fun SyntheticScopes.collectSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>, location: LookupLocation)
|
||||||
= scopes.flatMap { it.getSyntheticExtensionProperties(receiverTypes) }
|
= scopes.flatMap { it.getSyntheticExtensionProperties(receiverTypes, location) }
|
||||||
|
|
||||||
fun SyntheticScopes.collectSyntheticMemberFunctions(receiverTypes: Collection<KotlinType>)
|
fun SyntheticScopes.collectSyntheticMemberFunctions(receiverTypes: Collection<KotlinType>)
|
||||||
= scopes.flatMap { it.getSyntheticMemberFunctions(receiverTypes) }
|
= scopes.flatMap { it.getSyntheticMemberFunctions(receiverTypes) }
|
||||||
|
|||||||
+9
-5
@@ -23,14 +23,14 @@ import org.jetbrains.kotlin.descriptors.*
|
|||||||
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
|
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
|
||||||
import org.jetbrains.kotlin.idea.resolve.frontendService
|
import org.jetbrains.kotlin.idea.resolve.frontendService
|
||||||
import org.jetbrains.kotlin.idea.util.*
|
import org.jetbrains.kotlin.idea.util.*
|
||||||
|
import org.jetbrains.kotlin.incremental.KotlinLookupLocation
|
||||||
|
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||||
import org.jetbrains.kotlin.js.resolve.diagnostics.findPsi
|
import org.jetbrains.kotlin.js.resolve.diagnostics.findPsi
|
||||||
|
import org.jetbrains.kotlin.load.kotlin.toSourceElement
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.name.FqNameUnsafe
|
import org.jetbrains.kotlin.name.FqNameUnsafe
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.KtExpression
|
|
||||||
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
|
|
||||||
import org.jetbrains.kotlin.psi.KtVariableDeclaration
|
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf
|
import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.getDataFlowInfoBefore
|
import org.jetbrains.kotlin.resolve.bindingContextUtil.getDataFlowInfoBefore
|
||||||
@@ -43,6 +43,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ClassQualifier
|
|||||||
import org.jetbrains.kotlin.resolve.scopes.utils.collectAllFromMeAndParent
|
import org.jetbrains.kotlin.resolve.scopes.utils.collectAllFromMeAndParent
|
||||||
import org.jetbrains.kotlin.resolve.scopes.utils.collectDescriptorsFiltered
|
import org.jetbrains.kotlin.resolve.scopes.utils.collectDescriptorsFiltered
|
||||||
import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsImportingScope
|
import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsImportingScope
|
||||||
|
import org.jetbrains.kotlin.resolve.source.getPsi
|
||||||
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
|
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.expressions.DoubleColonLHS
|
import org.jetbrains.kotlin.types.expressions.DoubleColonLHS
|
||||||
@@ -415,7 +416,10 @@ class ReferenceVariantsHelper(
|
|||||||
|
|
||||||
val syntheticScopes = resolutionFacade.getFrontendService(SyntheticScopes::class.java)
|
val syntheticScopes = resolutionFacade.getFrontendService(SyntheticScopes::class.java)
|
||||||
if (kindFilter.acceptsKinds(DescriptorKindFilter.VARIABLES_MASK)) {
|
if (kindFilter.acceptsKinds(DescriptorKindFilter.VARIABLES_MASK)) {
|
||||||
for (extension in syntheticScopes.collectSyntheticExtensionProperties(receiverTypes)) {
|
val lookupLocation = (scope.ownerDescriptor.toSourceElement.getPsi() as? KtElement)?.let { KotlinLookupLocation(it) }
|
||||||
|
?: NoLookupLocation.FROM_IDE
|
||||||
|
|
||||||
|
for (extension in syntheticScopes.collectSyntheticExtensionProperties(receiverTypes, lookupLocation)) {
|
||||||
process(extension)
|
process(extension)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.codegen.StackValue
|
|||||||
import org.jetbrains.kotlin.codegen.extensions.ExpressionCodegenExtension
|
import org.jetbrains.kotlin.codegen.extensions.ExpressionCodegenExtension
|
||||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||||
|
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||||
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
|
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
|
||||||
import org.jetbrains.kotlin.load.java.descriptors.JavaPropertyDescriptor
|
import org.jetbrains.kotlin.load.java.descriptors.JavaPropertyDescriptor
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||||
@@ -33,7 +34,7 @@ class DebuggerFieldExpressionCodegenExtension : ExpressionCodegenExtension {
|
|||||||
val containingClass = propertyDescriptor.containingDeclaration as? JavaClassDescriptor
|
val containingClass = propertyDescriptor.containingDeclaration as? JavaClassDescriptor
|
||||||
if (containingClass != null) {
|
if (containingClass != null) {
|
||||||
val correspondingGetter = JavaSyntheticPropertiesScope(LockBasedStorageManager.NO_LOCKS, LookupTracker.DO_NOTHING)
|
val correspondingGetter = JavaSyntheticPropertiesScope(LockBasedStorageManager.NO_LOCKS, LookupTracker.DO_NOTHING)
|
||||||
.getSyntheticExtensionProperties(listOf(containingClass.defaultType))
|
.getSyntheticExtensionProperties(listOf(containingClass.defaultType), NoLookupLocation.FROM_BACKEND)
|
||||||
.firstOrNull { it.name == propertyDescriptor.name }
|
.firstOrNull { it.name == propertyDescriptor.name }
|
||||||
|
|
||||||
if (correspondingGetter != null) {
|
if (correspondingGetter != null) {
|
||||||
|
|||||||
+15
-11
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.descriptors.impl.PropertyGetterDescriptorImpl
|
|||||||
import org.jetbrains.kotlin.idea.project.platform
|
import org.jetbrains.kotlin.idea.project.platform
|
||||||
import org.jetbrains.kotlin.incremental.KotlinLookupLocation
|
import org.jetbrains.kotlin.incremental.KotlinLookupLocation
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||||
|
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||||
import org.jetbrains.kotlin.load.java.components.JavaSourceElementFactoryImpl
|
import org.jetbrains.kotlin.load.java.components.JavaSourceElementFactoryImpl
|
||||||
import org.jetbrains.kotlin.load.java.components.TypeUsage
|
import org.jetbrains.kotlin.load.java.components.TypeUsage
|
||||||
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
|
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
|
||||||
@@ -53,12 +54,24 @@ private class DebuggerFieldSyntheticScope(val javaSyntheticPropertiesScope: Java
|
|||||||
receiverTypes: Collection<KotlinType>,
|
receiverTypes: Collection<KotlinType>,
|
||||||
name: Name,
|
name: Name,
|
||||||
location: LookupLocation
|
location: LookupLocation
|
||||||
|
): Collection<PropertyDescriptor> {
|
||||||
|
return getSyntheticExtensionProperties(receiverTypes, location).filter { it.name == name }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getSyntheticExtensionProperties(
|
||||||
|
receiverTypes: Collection<KotlinType>,
|
||||||
|
location: LookupLocation
|
||||||
): Collection<PropertyDescriptor> {
|
): Collection<PropertyDescriptor> {
|
||||||
if (!isInEvaluator(location)) {
|
if (!isInEvaluator(location)) {
|
||||||
return emptyList()
|
return emptyList()
|
||||||
}
|
}
|
||||||
|
|
||||||
return getSyntheticExtensionProperties(receiverTypes).filter { it.name == name }
|
val result = mutableListOf<PropertyDescriptor>()
|
||||||
|
for (type in receiverTypes) {
|
||||||
|
val clazz = type.constructor.declarationDescriptor as? ClassDescriptor ?: continue
|
||||||
|
result += getSyntheticPropertiesForClass(clazz)
|
||||||
|
}
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isInEvaluator(location: LookupLocation): Boolean {
|
private fun isInEvaluator(location: LookupLocation): Boolean {
|
||||||
@@ -73,20 +86,11 @@ private class DebuggerFieldSyntheticScope(val javaSyntheticPropertiesScope: Java
|
|||||||
return containingFile.suppressDiagnosticsInDebugMode
|
return containingFile.suppressDiagnosticsInDebugMode
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>): Collection<PropertyDescriptor> {
|
|
||||||
val result = mutableListOf<PropertyDescriptor>()
|
|
||||||
for (type in receiverTypes) {
|
|
||||||
val clazz = type.constructor.declarationDescriptor as? ClassDescriptor ?: continue
|
|
||||||
result += getSyntheticPropertiesForClass(clazz)
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getSyntheticPropertiesForClass(clazz: ClassDescriptor): Collection<PropertyDescriptor> {
|
private fun getSyntheticPropertiesForClass(clazz: ClassDescriptor): Collection<PropertyDescriptor> {
|
||||||
val collected = mutableMapOf<Name, PropertyDescriptor>()
|
val collected = mutableMapOf<Name, PropertyDescriptor>()
|
||||||
|
|
||||||
val syntheticPropertyNames = javaSyntheticPropertiesScope
|
val syntheticPropertyNames = javaSyntheticPropertiesScope
|
||||||
.getSyntheticExtensionProperties(listOf(clazz.defaultType))
|
.getSyntheticExtensionProperties(listOf(clazz.defaultType), NoLookupLocation.FROM_SYNTHETIC_SCOPE)
|
||||||
.mapTo(mutableSetOf()) { it.name }
|
.mapTo(mutableSetOf()) { it.name }
|
||||||
|
|
||||||
collectPropertiesWithParent(clazz, syntheticPropertyNames, collected)
|
collectPropertiesWithParent(clazz, syntheticPropertyNames, collected)
|
||||||
|
|||||||
Reference in New Issue
Block a user