Removed usages of MemberScope.ownerDescriptor property.
This commit is contained in:
+1
-1
@@ -59,7 +59,7 @@ public class LazyResolveBasedCache(private val resolveSession: ResolveSession) :
|
|||||||
val packageDescriptor = resolveSession.getPackageFragment(fqName)
|
val packageDescriptor = resolveSession.getPackageFragment(fqName)
|
||||||
if (packageDescriptor == null) break
|
if (packageDescriptor == null) break
|
||||||
|
|
||||||
val result = ResolveSessionUtils.findByQualifiedName(packageDescriptor.getMemberScope(), fullFqName.tail(fqName))
|
val result = ResolveSessionUtils.findClassByRelativePath(packageDescriptor.getMemberScope(), fullFqName.tail(fqName))
|
||||||
if (result != null) return result
|
if (result != null) return result
|
||||||
|
|
||||||
if (fqName.isRoot()) break
|
if (fqName.isRoot()) break
|
||||||
|
|||||||
+1
-1
@@ -78,7 +78,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager, private val l
|
|||||||
val (descriptor, lookedNames) = syntheticPropertyInClass(Pair(classifier, name))
|
val (descriptor, lookedNames) = syntheticPropertyInClass(Pair(classifier, name))
|
||||||
|
|
||||||
if (location !is NoLookupLocation) {
|
if (location !is NoLookupLocation) {
|
||||||
lookedNames.forEach { lookupTracker.record(location, classifier.unsubstitutedMemberScope, it) }
|
lookedNames.forEach { lookupTracker.record(location, classifier, classifier.unsubstitutedMemberScope, it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
return descriptor
|
return descriptor
|
||||||
|
|||||||
+4
-4
@@ -101,10 +101,10 @@ public fun resolvePossiblyAmbiguousCallableReference(
|
|||||||
): OverloadResolutionResults<CallableDescriptor>? {
|
): OverloadResolutionResults<CallableDescriptor>? {
|
||||||
val reference = callableReferenceExpression.getCallableReference()
|
val reference = callableReferenceExpression.getCallableReference()
|
||||||
|
|
||||||
fun resolveInScope(traceTitle: String, staticScope: MemberScope): OverloadResolutionResults<CallableDescriptor> {
|
fun resolveInScope(traceTitle: String, classifier: ClassifierDescriptor, staticScope: MemberScope): OverloadResolutionResults<CallableDescriptor> {
|
||||||
|
|
||||||
// todo: drop this class when new resolve will be finished
|
// todo: drop this class when new resolve will be finished
|
||||||
class StaticScopeAsLexicalScope(val staticScope: MemberScope) : BaseLexicalScope(staticScope.memberScopeAsImportingScope(), staticScope.ownerDescriptor) {
|
class StaticScopeAsLexicalScope(val staticScope: MemberScope) : BaseLexicalScope(staticScope.memberScopeAsImportingScope(), classifier) {
|
||||||
override fun printStructure(p: Printer) {
|
override fun printStructure(p: Printer) {
|
||||||
p.println(toString())
|
p.println(toString())
|
||||||
}
|
}
|
||||||
@@ -141,11 +141,11 @@ public fun resolvePossiblyAmbiguousCallableReference(
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
val possibleStatic = resolveInScope("trace to resolve ::${reference.getReferencedName()} in static scope", classifier.getStaticScope())
|
val possibleStatic = resolveInScope("trace to resolve ::${reference.getReferencedName()} in static scope", classifier, classifier.getStaticScope())
|
||||||
if (possibleStatic.isSomething()) return possibleStatic
|
if (possibleStatic.isSomething()) return possibleStatic
|
||||||
|
|
||||||
val possibleNested = resolveInScope("trace to resolve ::${reference.getReferencedName()} in static nested classes scope",
|
val possibleNested = resolveInScope("trace to resolve ::${reference.getReferencedName()} in static nested classes scope",
|
||||||
JetScopeUtils.getStaticNestedClassesScope(classifier))
|
classifier, JetScopeUtils.getStaticNestedClassesScope(classifier))
|
||||||
if (possibleNested.isSomething()) return possibleNested
|
if (possibleNested.isSomething()) return possibleNested
|
||||||
|
|
||||||
val possibleWithReceiver = resolveWithReceiver("trace to resolve ::${reference.getReferencedName()} with receiver",
|
val possibleWithReceiver = resolveWithReceiver("trace to resolve ::${reference.getReferencedName()} with receiver",
|
||||||
|
|||||||
+8
-8
@@ -38,7 +38,7 @@ public interface CallableDescriptorCollector<D : CallableDescriptor> {
|
|||||||
|
|
||||||
public fun getLocalNonExtensionsByName(lexicalScope: LexicalScope, name: Name, location: LookupLocation): Collection<D>
|
public fun getLocalNonExtensionsByName(lexicalScope: LexicalScope, name: Name, location: LookupLocation): Collection<D>
|
||||||
|
|
||||||
public fun getNonExtensionsByName(scope: LexicalScope, name: Name, location: LookupLocation): Collection<D>
|
public fun getNonExtensionsByName(scope: HierarchicalScope, name: Name, location: LookupLocation): Collection<D>
|
||||||
|
|
||||||
// todo this is hack for static members priority
|
// todo this is hack for static members priority
|
||||||
public fun getStaticInheritanceByName(lexicalScope: LexicalScope, name: Name, location: LookupLocation): Collection<D>
|
public fun getStaticInheritanceByName(lexicalScope: LexicalScope, name: Name, location: LookupLocation): Collection<D>
|
||||||
@@ -47,7 +47,7 @@ public interface CallableDescriptorCollector<D : CallableDescriptor> {
|
|||||||
|
|
||||||
public fun getStaticMembersByName(receiver: KotlinType, name: Name, location: LookupLocation): Collection<D>
|
public fun getStaticMembersByName(receiver: KotlinType, name: Name, location: LookupLocation): Collection<D>
|
||||||
|
|
||||||
public fun getExtensionsByName(scope: LexicalScope, name: Name, receiverTypes: Collection<KotlinType>, location: LookupLocation): Collection<D>
|
public fun getExtensionsByName(scope: HierarchicalScope, name: Name, receiverTypes: Collection<KotlinType>, location: LookupLocation): Collection<D>
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun <D : CallableDescriptor> CallableDescriptorCollector<D>.withDefaultFilter() = filtered { !LibrarySourceHacks.shouldSkip(it) }
|
private fun <D : CallableDescriptor> CallableDescriptorCollector<D>.withDefaultFilter() = filtered { !LibrarySourceHacks.shouldSkip(it) }
|
||||||
@@ -99,7 +99,7 @@ private object FunctionCollector : CallableDescriptorCollector<FunctionDescripto
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getNonExtensionsByName(scope: LexicalScope, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
override fun getNonExtensionsByName(scope: HierarchicalScope, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||||
return scope.collectFunctions(name, location).filter { it.extensionReceiverParameter == null } + getConstructors(scope, name, location)
|
return scope.collectFunctions(name, location).filter { it.extensionReceiverParameter == null } + getConstructors(scope, name, location)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ private object FunctionCollector : CallableDescriptorCollector<FunctionDescripto
|
|||||||
return getConstructors(receiver.memberScope.memberScopeAsImportingScope(), name, location, { isStaticNestedClass(it) })
|
return getConstructors(receiver.memberScope.memberScopeAsImportingScope(), name, location, { isStaticNestedClass(it) })
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getExtensionsByName(scope: LexicalScope, name: Name, receiverTypes: Collection<KotlinType>, location: LookupLocation): Collection<FunctionDescriptor> {
|
override fun getExtensionsByName(scope: HierarchicalScope, name: Name, receiverTypes: Collection<KotlinType>, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||||
val functions = scope.collectFunctions(name, location)
|
val functions = scope.collectFunctions(name, location)
|
||||||
val (extensions, nonExtensions) = functions.partition { it.extensionReceiverParameter != null }
|
val (extensions, nonExtensions) = functions.partition { it.extensionReceiverParameter != null }
|
||||||
val syntheticExtensions = scope.collectSyntheticExtensionFunctions(receiverTypes, name, location)
|
val syntheticExtensions = scope.collectSyntheticExtensionFunctions(receiverTypes, name, location)
|
||||||
@@ -186,7 +186,7 @@ private object VariableCollector : CallableDescriptorCollector<VariableDescripto
|
|||||||
return FakeCallableDescriptorForObject(classifier)
|
return FakeCallableDescriptorForObject(classifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getNonExtensionsByName(scope: LexicalScope, name: Name, location: LookupLocation): Collection<VariableDescriptor> {
|
override fun getNonExtensionsByName(scope: HierarchicalScope, name: Name, location: LookupLocation): Collection<VariableDescriptor> {
|
||||||
val properties = scope.collectVariables(name, location).filter { it.extensionReceiverParameter == null }
|
val properties = scope.collectVariables(name, location).filter { it.extensionReceiverParameter == null }
|
||||||
val fakeDescriptor = getFakeDescriptorForObject(scope, name, location)
|
val fakeDescriptor = getFakeDescriptorForObject(scope, name, location)
|
||||||
return if (fakeDescriptor != null) properties + fakeDescriptor else properties
|
return if (fakeDescriptor != null) properties + fakeDescriptor else properties
|
||||||
@@ -203,7 +203,7 @@ private object VariableCollector : CallableDescriptorCollector<VariableDescripto
|
|||||||
return listOf()
|
return listOf()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getExtensionsByName(scope: LexicalScope, name: Name, receiverTypes: Collection<KotlinType>, location: LookupLocation): Collection<VariableDescriptor> {
|
override fun getExtensionsByName(scope: HierarchicalScope, name: Name, receiverTypes: Collection<KotlinType>, location: LookupLocation): Collection<VariableDescriptor> {
|
||||||
// property may have an extension function type, we check the applicability later to avoid an early computing of deferred types
|
// property may have an extension function type, we check the applicability later to avoid an early computing of deferred types
|
||||||
return scope.collectVariables(name, location) +
|
return scope.collectVariables(name, location) +
|
||||||
scope.collectSyntheticExtensionProperties(receiverTypes, name, location)
|
scope.collectSyntheticExtensionProperties(receiverTypes, name, location)
|
||||||
@@ -223,7 +223,7 @@ private fun <D : CallableDescriptor> CallableDescriptorCollector<D>.filtered(fil
|
|||||||
return delegate.getStaticInheritanceByName(lexicalScope, name, location)
|
return delegate.getStaticInheritanceByName(lexicalScope, name, location)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getNonExtensionsByName(scope: LexicalScope, name: Name, location: LookupLocation): Collection<D> {
|
override fun getNonExtensionsByName(scope: HierarchicalScope, name: Name, location: LookupLocation): Collection<D> {
|
||||||
return delegate.getNonExtensionsByName(scope, name, location).filter(filter)
|
return delegate.getNonExtensionsByName(scope, name, location).filter(filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,7 +235,7 @@ private fun <D : CallableDescriptor> CallableDescriptorCollector<D>.filtered(fil
|
|||||||
return delegate.getStaticMembersByName(receiver, name, location).filter(filter)
|
return delegate.getStaticMembersByName(receiver, name, location).filter(filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getExtensionsByName(scope: LexicalScope, name: Name, receiverTypes: Collection<KotlinType>, location: LookupLocation): Collection<D> {
|
override fun getExtensionsByName(scope: HierarchicalScope, name: Name, receiverTypes: Collection<KotlinType>, location: LookupLocation): Collection<D> {
|
||||||
return delegate.getExtensionsByName(scope, name, receiverTypes, location).filter(filter)
|
return delegate.getExtensionsByName(scope, name, receiverTypes, location).filter(filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.QualifierReceiver
|
|||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue.NO_RECEIVER
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue.NO_RECEIVER
|
||||||
import org.jetbrains.kotlin.resolve.scopes.utils.getImplicitReceiversHierarchy
|
import org.jetbrains.kotlin.resolve.scopes.utils.getImplicitReceiversHierarchy
|
||||||
import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsLexicalScope
|
import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsImportingScope
|
||||||
import org.jetbrains.kotlin.resolve.validation.InfixValidator
|
import org.jetbrains.kotlin.resolve.validation.InfixValidator
|
||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
import org.jetbrains.kotlin.types.ErrorUtils
|
import org.jetbrains.kotlin.types.ErrorUtils
|
||||||
@@ -69,7 +69,8 @@ public class TaskPrioritizer(
|
|||||||
|
|
||||||
if (explicitReceiver is QualifierReceiver) {
|
if (explicitReceiver is QualifierReceiver) {
|
||||||
val qualifierReceiver: QualifierReceiver = explicitReceiver
|
val qualifierReceiver: QualifierReceiver = explicitReceiver
|
||||||
val receiverScope = qualifierReceiver.getNestedClassesAndPackageMembersScope().memberScopeAsLexicalScope()
|
val receiverScope = LexicalScope.empty(qualifierReceiver.getNestedClassesAndPackageMembersScope().memberScopeAsImportingScope(),
|
||||||
|
qualifierReceiver.descriptor)
|
||||||
doComputeTasks(NO_RECEIVER, taskPrioritizerContext.replaceScope(receiverScope))
|
doComputeTasks(NO_RECEIVER, taskPrioritizerContext.replaceScope(receiverScope))
|
||||||
computeTasksForClassObjectReceiver(qualifierReceiver, taskPrioritizerContext)
|
computeTasksForClassObjectReceiver(qualifierReceiver, taskPrioritizerContext)
|
||||||
}
|
}
|
||||||
@@ -260,7 +261,7 @@ public class TaskPrioritizer(
|
|||||||
val dynamicScope = dynamicCallableDescriptors.createDynamicDescriptorScope(c.context.call, c.scope.ownerDescriptor)
|
val dynamicScope = dynamicCallableDescriptors.createDynamicDescriptorScope(c.context.call, c.scope.ownerDescriptor)
|
||||||
|
|
||||||
val dynamicDescriptors = c.callableDescriptorCollectors.flatMap {
|
val dynamicDescriptors = c.callableDescriptorCollectors.flatMap {
|
||||||
it.getNonExtensionsByName(dynamicScope.memberScopeAsLexicalScope(), c.name, createLookupLocation(c))
|
it.getNonExtensionsByName(dynamicScope.memberScopeAsImportingScope(), c.name, createLookupLocation(c))
|
||||||
}
|
}
|
||||||
|
|
||||||
convertWithReceivers(dynamicDescriptors, explicitReceiver.value, NO_RECEIVER, createKind(DISPATCH_RECEIVER, isExplicit), c.context.call)
|
convertWithReceivers(dynamicDescriptors, explicitReceiver.value, NO_RECEIVER, createKind(DISPATCH_RECEIVER, isExplicit), c.context.call)
|
||||||
@@ -281,7 +282,7 @@ public class TaskPrioritizer(
|
|||||||
) {
|
) {
|
||||||
c.result.addCandidates {
|
c.result.addCandidates {
|
||||||
val memberExtensions =
|
val memberExtensions =
|
||||||
callableDescriptorCollector.getExtensionsByName(dispatchReceiver.type.memberScope.memberScopeAsLexicalScope(), c.name, receiverParameter.types, createLookupLocation(c))
|
callableDescriptorCollector.getExtensionsByName(dispatchReceiver.type.memberScope.memberScopeAsImportingScope(), c.name, receiverParameter.types, createLookupLocation(c))
|
||||||
convertWithReceivers(memberExtensions, dispatchReceiver, receiverParameter.value, receiverKind, c.context.call)
|
convertWithReceivers(memberExtensions, dispatchReceiver, receiverParameter.value, receiverKind, c.context.call)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.resolve.DescriptorFactory
|
|||||||
import org.jetbrains.kotlin.resolve.calls.tasks.collectors.CallableDescriptorCollector
|
import org.jetbrains.kotlin.resolve.calls.tasks.collectors.CallableDescriptorCollector
|
||||||
import org.jetbrains.kotlin.resolve.calls.tasks.collectors.CallableDescriptorCollectors
|
import org.jetbrains.kotlin.resolve.calls.tasks.collectors.CallableDescriptorCollectors
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.HierarchicalScope
|
||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScopeImpl
|
import org.jetbrains.kotlin.resolve.scopes.MemberScopeImpl
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver
|
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver
|
||||||
@@ -229,7 +230,7 @@ public fun DeclarationDescriptor.isDynamic(): Boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class CollectorForDynamicReceivers<D: CallableDescriptor>(val delegate: CallableDescriptorCollector<D>) : CallableDescriptorCollector<D> by delegate {
|
class CollectorForDynamicReceivers<D: CallableDescriptor>(val delegate: CallableDescriptorCollector<D>) : CallableDescriptorCollector<D> by delegate {
|
||||||
override fun getExtensionsByName(scope: LexicalScope, name: Name, receiverTypes: Collection<KotlinType>, location: LookupLocation): Collection<D> {
|
override fun getExtensionsByName(scope: HierarchicalScope, name: Name, receiverTypes: Collection<KotlinType>, location: LookupLocation): Collection<D> {
|
||||||
return delegate.getExtensionsByName(scope, name, receiverTypes, location).filter {
|
return delegate.getExtensionsByName(scope, name, receiverTypes, location).filter {
|
||||||
it.getExtensionReceiverParameter()?.getType()?.isDynamic() ?: false
|
it.getExtensionReceiverParameter()?.getType()?.isDynamic() ?: false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public class ResolveSessionUtils {
|
|||||||
PackageViewDescriptor packageDescriptor = module.getPackage(packageFqName);
|
PackageViewDescriptor packageDescriptor = module.getPackage(packageFqName);
|
||||||
if (!packageDescriptor.isEmpty()) {
|
if (!packageDescriptor.isEmpty()) {
|
||||||
FqName relativeClassFqName = FqNamesUtilKt.tail(fqName, packageFqName);
|
FqName relativeClassFqName = FqNamesUtilKt.tail(fqName, packageFqName);
|
||||||
ClassDescriptor classDescriptor = findByQualifiedName(packageDescriptor.getMemberScope(), relativeClassFqName);
|
ClassDescriptor classDescriptor = findClassByRelativePath(packageDescriptor.getMemberScope(), relativeClassFqName);
|
||||||
if (classDescriptor != null && filter.apply(classDescriptor)) {
|
if (classDescriptor != null && filter.apply(classDescriptor)) {
|
||||||
result.add(classDescriptor);
|
result.add(classDescriptor);
|
||||||
}
|
}
|
||||||
@@ -76,17 +76,18 @@ public class ResolveSessionUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static ClassDescriptor findByQualifiedName(@NotNull MemberScope outerScope, @NotNull FqName path) {
|
public static ClassDescriptor findClassByRelativePath(@NotNull MemberScope packageScope, @NotNull FqName path) {
|
||||||
if (path.isRoot()) return null;
|
if (path.isRoot()) return null;
|
||||||
|
|
||||||
MemberScope scope = outerScope;
|
MemberScope scope = packageScope;
|
||||||
|
ClassifierDescriptor classifier = null;
|
||||||
for (Name name : path.pathSegments()) {
|
for (Name name : path.pathSegments()) {
|
||||||
ClassifierDescriptor classifier = scope.getContributedClassifier(name, NoLookupLocation.WHEN_FIND_BY_FQNAME);
|
classifier = scope.getContributedClassifier(name, NoLookupLocation.WHEN_FIND_BY_FQNAME);
|
||||||
if (!(classifier instanceof ClassDescriptor)) return null;
|
if (!(classifier instanceof ClassDescriptor)) return null;
|
||||||
scope = ((ClassDescriptor) classifier).getUnsubstitutedInnerClassesScope();
|
scope = ((ClassDescriptor) classifier).getUnsubstitutedInnerClassesScope();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (ClassDescriptor) scope.getOwnerDescriptor();
|
return (ClassDescriptor) classifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
+1
-1
@@ -186,6 +186,6 @@ protected constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun recordLookup(name: Name, from: LookupLocation) {
|
private fun recordLookup(name: Name, from: LookupLocation) {
|
||||||
c.lookupTracker.record(from, this, name)
|
c.lookupTracker.record(from, ownerDescriptor, this, name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,9 +115,6 @@ public fun HierarchicalScope.takeSnapshot(): HierarchicalScope = if (this is Lex
|
|||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
public fun MemberScope.memberScopeAsImportingScope(parentScope: ImportingScope? = null): ImportingScope = MemberScopeToImportingScopeAdapter(parentScope, this)
|
public fun MemberScope.memberScopeAsImportingScope(parentScope: ImportingScope? = null): ImportingScope = MemberScopeToImportingScopeAdapter(parentScope, this)
|
||||||
|
|
||||||
@Deprecated("Temporary method for scope migration")
|
|
||||||
public fun MemberScope.memberScopeAsLexicalScope(): LexicalScope = LexicalScope.empty(memberScopeAsImportingScope(), ownerDescriptor)
|
|
||||||
|
|
||||||
private class MemberScopeToImportingScopeAdapter(override val parent: ImportingScope?, val memberScope: MemberScope) : ImportingScope {
|
private class MemberScopeToImportingScopeAdapter(override val parent: ImportingScope?, val memberScope: MemberScope) : ImportingScope {
|
||||||
override fun getContributedPackage(name: Name): PackageViewDescriptor? = memberScope.getPackage(name)
|
override fun getContributedPackage(name: Name): PackageViewDescriptor? = memberScope.getPackage(name)
|
||||||
|
|
||||||
|
|||||||
@@ -61,8 +61,7 @@ class LazyOperationsLog(
|
|||||||
|
|
||||||
public fun getText(): String {
|
public fun getText(): String {
|
||||||
val groupedByOwner = records.groupByTo(IdentityHashMap()) {
|
val groupedByOwner = records.groupByTo(IdentityHashMap()) {
|
||||||
val owner = it.data.fieldOwner
|
it.data.fieldOwner
|
||||||
if (owner is MemberScope) owner.ownerDescriptor else owner
|
|
||||||
}.map { Pair(it.getKey(), it.getValue()) }
|
}.map { Pair(it.getKey(), it.getValue()) }
|
||||||
|
|
||||||
return groupedByOwner.map {
|
return groupedByOwner.map {
|
||||||
|
|||||||
+6
-16
@@ -28,29 +28,19 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
|||||||
import org.jetbrains.kotlin.resolve.MemberComparator
|
import org.jetbrains.kotlin.resolve.MemberComparator
|
||||||
|
|
||||||
class DeserializedScopeValidationVisitor : ValidationVisitor() {
|
class DeserializedScopeValidationVisitor : ValidationVisitor() {
|
||||||
override fun validateScope(scope: MemberScope, collector: DescriptorValidator.DiagnosticCollector) {
|
override fun validateScope(scopeOwner: DeclarationDescriptor, scope: MemberScope, collector: DescriptorValidator.DiagnosticCollector) {
|
||||||
super.validateScope(scope, collector)
|
super.validateScope(scopeOwner, scope, collector)
|
||||||
validateDeserializedScope(scope)
|
validateDeserializedScope(scopeOwner, scope)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun validateDeserializedScope(scope: MemberScope) {
|
private fun validateDeserializedScope(scopeOwner: DeclarationDescriptor, scope: MemberScope) {
|
||||||
val isPackageViewScope = scope.safeGetContainingDeclaration() is PackageViewDescriptor
|
val isPackageViewScope = scopeOwner is PackageViewDescriptor
|
||||||
if (scope is DeserializedMemberScope || isPackageViewScope) {
|
if (scope is DeserializedMemberScope || isPackageViewScope) {
|
||||||
val relevantDescriptors = scope.getContributedDescriptors().filter { member ->
|
val relevantDescriptors = scope.getContributedDescriptors().filter { member ->
|
||||||
member is CallableMemberDescriptor && member.getKind().isReal() || (!isPackageViewScope && member is ClassDescriptor)
|
member is CallableMemberDescriptor && member.getKind().isReal() || (!isPackageViewScope && member is ClassDescriptor)
|
||||||
}
|
}
|
||||||
checkSorted(relevantDescriptors, scope.ownerDescriptor)
|
checkSorted(relevantDescriptors, scopeOwner)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//NOTE: see TypeUtils#IntersectionScope#getContainingDeclaration()
|
|
||||||
private fun MemberScope.safeGetContainingDeclaration(): DeclarationDescriptor? {
|
|
||||||
return try {
|
|
||||||
ownerDescriptor
|
|
||||||
}
|
|
||||||
catch (e: UnsupportedOperationException) {
|
|
||||||
null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class DescriptorValidator {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void validateScope(@NotNull MemberScope scope, @NotNull DiagnosticCollector collector) {
|
protected void validateScope(DeclarationDescriptor scopeOwner, @NotNull MemberScope scope, @NotNull DiagnosticCollector collector) {
|
||||||
for (DeclarationDescriptor descriptor : DescriptorUtils.getAllDescriptors(scope)) {
|
for (DeclarationDescriptor descriptor : DescriptorUtils.getAllDescriptors(scope)) {
|
||||||
if (recursiveFilter.apply(descriptor)) {
|
if (recursiveFilter.apply(descriptor)) {
|
||||||
descriptor.accept(new ScopeValidatorVisitor(collector), scope);
|
descriptor.accept(new ScopeValidatorVisitor(collector), scope);
|
||||||
@@ -107,7 +107,7 @@ public class DescriptorValidator {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
validateScope(type.getMemberScope(), collector);
|
validateScope(descriptor, type.getMemberScope(), collector);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateReturnType(CallableDescriptor descriptor, DiagnosticCollector collector) {
|
private void validateReturnType(CallableDescriptor descriptor, DiagnosticCollector collector) {
|
||||||
@@ -191,7 +191,7 @@ public class DescriptorValidator {
|
|||||||
public Boolean visitPackageFragmentDescriptor(
|
public Boolean visitPackageFragmentDescriptor(
|
||||||
PackageFragmentDescriptor descriptor, DiagnosticCollector collector
|
PackageFragmentDescriptor descriptor, DiagnosticCollector collector
|
||||||
) {
|
) {
|
||||||
validateScope(descriptor.getMemberScope(), collector);
|
validateScope(descriptor, descriptor.getMemberScope(), collector);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,7 +199,7 @@ public class DescriptorValidator {
|
|||||||
public Boolean visitPackageViewDescriptor(PackageViewDescriptor descriptor, DiagnosticCollector collector) {
|
public Boolean visitPackageViewDescriptor(PackageViewDescriptor descriptor, DiagnosticCollector collector) {
|
||||||
if (!recursiveFilter.apply(descriptor)) return false;
|
if (!recursiveFilter.apply(descriptor)) return false;
|
||||||
|
|
||||||
validateScope(descriptor.getMemberScope(), collector);
|
validateScope(descriptor, descriptor.getMemberScope(), collector);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,7 +245,7 @@ public class DescriptorValidator {
|
|||||||
|
|
||||||
validateType(descriptor, descriptor.getDefaultType(), collector);
|
validateType(descriptor, descriptor.getDefaultType(), collector);
|
||||||
|
|
||||||
validateScope(descriptor.getUnsubstitutedInnerClassesScope(), collector);
|
validateScope(descriptor, descriptor.getUnsubstitutedInnerClassesScope(), collector);
|
||||||
|
|
||||||
List<ConstructorDescriptor> primary = Lists.newArrayList();
|
List<ConstructorDescriptor> primary = Lists.newArrayList();
|
||||||
for (ConstructorDescriptor constructorDescriptor : descriptor.getConstructors()) {
|
for (ConstructorDescriptor constructorDescriptor : descriptor.getConstructors()) {
|
||||||
|
|||||||
@@ -32,7 +32,11 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
|||||||
import org.jetbrains.kotlin.resolve.lazy.JvmResolveUtil;
|
import org.jetbrains.kotlin.resolve.lazy.JvmResolveUtil;
|
||||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSession;
|
import org.jetbrains.kotlin.resolve.lazy.ResolveSession;
|
||||||
import org.jetbrains.kotlin.resolve.lazy.declarations.FileBasedDeclarationProviderFactory;
|
import org.jetbrains.kotlin.resolve.lazy.declarations.FileBasedDeclarationProviderFactory;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.*;
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeImpl;
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.MemberScope;
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.RedeclarationHandler;
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.utils.ScopeUtilsKt;
|
||||||
import org.jetbrains.kotlin.test.ConfigurationKind;
|
import org.jetbrains.kotlin.test.ConfigurationKind;
|
||||||
import org.jetbrains.kotlin.test.KotlinLiteFixture;
|
import org.jetbrains.kotlin.test.KotlinLiteFixture;
|
||||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||||
@@ -91,7 +95,7 @@ public class DefaultModalityModifiersTest extends KotlinLiteFixture {
|
|||||||
assert aClass instanceof KtClass;
|
assert aClass instanceof KtClass;
|
||||||
AnalysisResult bindingContext = JvmResolveUtil.analyzeOneFileWithJavaIntegrationAndCheckForErrors(file);
|
AnalysisResult bindingContext = JvmResolveUtil.analyzeOneFileWithJavaIntegrationAndCheckForErrors(file);
|
||||||
final DeclarationDescriptor classDescriptor = bindingContext.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, aClass);
|
final DeclarationDescriptor classDescriptor = bindingContext.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, aClass);
|
||||||
return new LexicalScopeImpl(TypeTestUtilsKt.asLexicalScope(libraryScope), root, false, null,
|
return new LexicalScopeImpl(ScopeUtilsKt.memberScopeAsImportingScope(libraryScope), root, false, null,
|
||||||
"JetDefaultModalityModifiersTest", RedeclarationHandler.DO_NOTHING,
|
"JetDefaultModalityModifiersTest", RedeclarationHandler.DO_NOTHING,
|
||||||
new Function1<LexicalScopeImpl.InitializeHandler, Unit>() {
|
new Function1<LexicalScopeImpl.InitializeHandler, Unit>() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.types;
|
package org.jetbrains.kotlin.types;
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment;
|
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment;
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor;
|
import org.jetbrains.kotlin.descriptors.FunctionDescriptor;
|
||||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor;
|
import org.jetbrains.kotlin.descriptors.ModuleDescriptor;
|
||||||
@@ -26,6 +27,7 @@ import org.jetbrains.kotlin.resolve.OverloadUtil;
|
|||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||||
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform;
|
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.utils.ScopeUtilsKt;
|
||||||
import org.jetbrains.kotlin.test.ConfigurationKind;
|
import org.jetbrains.kotlin.test.ConfigurationKind;
|
||||||
import org.jetbrains.kotlin.test.KotlinLiteFixture;
|
import org.jetbrains.kotlin.test.KotlinLiteFixture;
|
||||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||||
@@ -170,7 +172,7 @@ public class KotlinOverloadTest extends KotlinLiteFixture {
|
|||||||
|
|
||||||
private FunctionDescriptor makeFunction(String funDecl) {
|
private FunctionDescriptor makeFunction(String funDecl) {
|
||||||
KtNamedFunction function = KtPsiFactoryKt.KtPsiFactory(getProject()).createFunction(funDecl);
|
KtNamedFunction function = KtPsiFactoryKt.KtPsiFactory(getProject()).createFunction(funDecl);
|
||||||
LexicalScope scope = TypeTestUtilsKt.asLexicalScope(JvmPlatform.INSTANCE$.getBuiltIns().getBuiltInsPackageScope());
|
LexicalScope scope = TypeTestUtilsKt.builtInPackageAsLexicalScope(JvmPlatform.INSTANCE$.getBuiltIns());
|
||||||
return functionDescriptorResolver.resolveFunctionDescriptor(root, scope, function, KotlinTestUtils.DUMMY_TRACE, DataFlowInfo.EMPTY);
|
return functionDescriptorResolver.resolveFunctionDescriptor(root, scope, function, KotlinTestUtils.DUMMY_TRACE, DataFlowInfo.EMPTY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ public class KotlinOverridingTest extends KotlinLiteFixture {
|
|||||||
|
|
||||||
private FunctionDescriptor makeFunction(String funDecl) {
|
private FunctionDescriptor makeFunction(String funDecl) {
|
||||||
KtNamedFunction function = KtPsiFactoryKt.KtPsiFactory(getProject()).createFunction(funDecl);
|
KtNamedFunction function = KtPsiFactoryKt.KtPsiFactory(getProject()).createFunction(funDecl);
|
||||||
LexicalScope scope = TypeTestUtilsKt.asLexicalScope(root.getBuiltIns().getBuiltInsPackageScope());
|
LexicalScope scope = TypeTestUtilsKt.builtInPackageAsLexicalScope(root.getBuiltIns());
|
||||||
return functionDescriptorResolver.resolveFunctionDescriptor(root, scope, function,
|
return functionDescriptorResolver.resolveFunctionDescriptor(root, scope, function,
|
||||||
KotlinTestUtils.DUMMY_TRACE, DataFlowInfo.EMPTY);
|
KotlinTestUtils.DUMMY_TRACE, DataFlowInfo.EMPTY);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import org.jetbrains.kotlin.psi.KtTypeProjection;
|
|||||||
import org.jetbrains.kotlin.psi.KtTypeReference;
|
import org.jetbrains.kotlin.psi.KtTypeReference;
|
||||||
import org.jetbrains.kotlin.resolve.TypeResolver;
|
import org.jetbrains.kotlin.resolve.TypeResolver;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.*;
|
import org.jetbrains.kotlin.resolve.scopes.*;
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.utils.ScopeUtilsKt;
|
||||||
import org.jetbrains.kotlin.test.ConfigurationKind;
|
import org.jetbrains.kotlin.test.ConfigurationKind;
|
||||||
import org.jetbrains.kotlin.test.KotlinLiteFixture;
|
import org.jetbrains.kotlin.test.KotlinLiteFixture;
|
||||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||||
@@ -200,7 +201,7 @@ public class TypeUnifierTest extends KotlinLiteFixture {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TypeProjection makeTypeProjection(MemberScope scope, String typeStr) {
|
private TypeProjection makeTypeProjection(MemberScope scope, String typeStr) {
|
||||||
LexicalScope withX = new LexicalScopeImpl(TypeTestUtilsKt.asLexicalScope(scope), scope.getOwnerDescriptor(),
|
LexicalScope withX = new LexicalScopeImpl(ScopeUtilsKt.memberScopeAsImportingScope(scope), builtIns.getBuiltInsModule(),
|
||||||
false, null, "With X", RedeclarationHandler.DO_NOTHING,
|
false, null, "With X", RedeclarationHandler.DO_NOTHING,
|
||||||
new Function1<LexicalScopeImpl.InitializeHandler, Unit>() {
|
new Function1<LexicalScopeImpl.InitializeHandler, Unit>() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -16,17 +16,12 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.types
|
package org.jetbrains.kotlin.types
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||||
import org.jetbrains.kotlin.resolve.scopes.BaseLexicalScope
|
import org.jetbrains.kotlin.resolve.scopes.BaseLexicalScope
|
||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||||
import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsImportingScope
|
import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsImportingScope
|
||||||
import org.jetbrains.kotlin.utils.Printer
|
import org.jetbrains.kotlin.utils.Printer
|
||||||
|
|
||||||
public fun MemberScope.asLexicalScope(): LexicalScope {
|
fun KotlinBuiltIns.builtInPackageAsLexicalScope()
|
||||||
val importingScope = memberScopeAsImportingScope()
|
= LexicalScope.empty(getBuiltInsPackageScope().memberScopeAsImportingScope(), getBuiltInsModule())
|
||||||
return object : BaseLexicalScope(importingScope, ownerDescriptor) {
|
|
||||||
override fun printStructure(p: Printer) {
|
|
||||||
p.println("Util scope for tests")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
-1
@@ -362,6 +362,6 @@ public abstract class LazyJavaScope(
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected fun recordLookup(name: Name, from: LookupLocation) {
|
protected fun recordLookup(name: Name, from: LookupLocation) {
|
||||||
c.components.lookupTracker.record(from, this, name)
|
c.components.lookupTracker.record(from, ownerDescriptor, this, name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package org.jetbrains.kotlin.incremental
|
package org.jetbrains.kotlin.incremental
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||||
@@ -26,19 +27,17 @@ import org.jetbrains.kotlin.name.Name
|
|||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||||
|
|
||||||
public fun LookupTracker.record(from: LookupLocation, inScope: MemberScope, name: Name) {
|
public fun LookupTracker.record(from: LookupLocation, scopeOwner: DeclarationDescriptor, inScope: MemberScope, name: Name) {
|
||||||
if (this == LookupTracker.DO_NOTHING || from is NoLookupLocation) return
|
if (this == LookupTracker.DO_NOTHING || from is NoLookupLocation) return
|
||||||
|
|
||||||
val location = from.location ?: return
|
val location = from.location ?: return
|
||||||
|
|
||||||
val scopeContainingDeclaration = inScope.ownerDescriptor
|
|
||||||
|
|
||||||
val scopeKind =
|
val scopeKind =
|
||||||
when (scopeContainingDeclaration) {
|
when (scopeOwner) {
|
||||||
is ClassifierDescriptor -> ScopeKind.CLASSIFIER
|
is ClassifierDescriptor -> ScopeKind.CLASSIFIER
|
||||||
is PackageFragmentDescriptor -> ScopeKind.PACKAGE
|
is PackageFragmentDescriptor -> ScopeKind.PACKAGE
|
||||||
else -> throw AssertionError("Unexpected containing declaration type: ${scopeContainingDeclaration.javaClass}")
|
else -> throw AssertionError("Unexpected containing declaration type: ${scopeOwner.javaClass}")
|
||||||
}
|
}
|
||||||
|
|
||||||
record(location, scopeContainingDeclaration.fqNameUnsafe.asString(), scopeKind, name.asString())
|
record(location, scopeOwner.fqNameUnsafe.asString(), scopeKind, name.asString())
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -187,6 +187,6 @@ public abstract class DeserializedMemberScope protected constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun recordLookup(name: Name, from: LookupLocation) {
|
private fun recordLookup(name: Name, from: LookupLocation) {
|
||||||
c.components.lookupTracker.record(from, this, name)
|
c.components.lookupTracker.record(from, ownerDescriptor, this, name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -198,19 +198,21 @@ public abstract class AbstractRenameTest : KotlinMultiFileTestCase() {
|
|||||||
private fun renameKotlinFunctionTest(renameParamsObject: JsonObject, context: TestContext) {
|
private fun renameKotlinFunctionTest(renameParamsObject: JsonObject, context: TestContext) {
|
||||||
val oldMethodName = Name.identifier(renameParamsObject.getString("oldName"))
|
val oldMethodName = Name.identifier(renameParamsObject.getString("oldName"))
|
||||||
|
|
||||||
doRenameInKotlinClassOrPackage(renameParamsObject, context) { it.getContributedFunctions(oldMethodName, NoLookupLocation.FROM_TEST).first() }
|
doRenameInKotlinClassOrPackage(renameParamsObject, context) {
|
||||||
|
declaration, scope -> scope.getContributedFunctions(oldMethodName, NoLookupLocation.FROM_TEST).first() }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renameKotlinPropertyTest(renameParamsObject: JsonObject, context: TestContext) {
|
private fun renameKotlinPropertyTest(renameParamsObject: JsonObject, context: TestContext) {
|
||||||
val oldPropertyName = Name.identifier(renameParamsObject.getString("oldName"))
|
val oldPropertyName = Name.identifier(renameParamsObject.getString("oldName"))
|
||||||
|
|
||||||
doRenameInKotlinClassOrPackage(renameParamsObject, context) { it.getContributedVariables(oldPropertyName, NoLookupLocation.FROM_TEST).first() }
|
doRenameInKotlinClassOrPackage(renameParamsObject, context) {
|
||||||
|
declaration, scope -> scope.getContributedVariables(oldPropertyName, NoLookupLocation.FROM_TEST).first() }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renameKotlinClassTest(renameParamsObject: JsonObject, context: TestContext) {
|
private fun renameKotlinClassTest(renameParamsObject: JsonObject, context: TestContext) {
|
||||||
renameParamsObject.getString("classId") //assertion
|
renameParamsObject.getString("classId") //assertion
|
||||||
|
|
||||||
doRenameInKotlinClassOrPackage(renameParamsObject, context) { scope -> scope.ownerDescriptor as ClassDescriptor }
|
doRenameInKotlinClassOrPackage(renameParamsObject, context) { declaration, scope -> declaration as ClassDescriptor }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renameKotlinPackageTest(renameParamsObject: JsonObject, context: TestContext) {
|
private fun renameKotlinPackageTest(renameParamsObject: JsonObject, context: TestContext) {
|
||||||
@@ -263,7 +265,7 @@ public abstract class AbstractRenameTest : KotlinMultiFileTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun doRenameInKotlinClassOrPackage(
|
private fun doRenameInKotlinClassOrPackage(
|
||||||
renameParamsObject: JsonObject, context: TestContext, findDescriptorToRename: (MemberScope) -> DeclarationDescriptor
|
renameParamsObject: JsonObject, context: TestContext, findDescriptorToRename: (DeclarationDescriptor, MemberScope) -> DeclarationDescriptor
|
||||||
) {
|
) {
|
||||||
val classIdStr = renameParamsObject.getNullableString("classId")
|
val classIdStr = renameParamsObject.getNullableString("classId")
|
||||||
val packageFqnStr = renameParamsObject.getNullableString("packageFqn")
|
val packageFqnStr = renameParamsObject.getNullableString("packageFqn")
|
||||||
@@ -284,13 +286,13 @@ public abstract class AbstractRenameTest : KotlinMultiFileTestCase() {
|
|||||||
|
|
||||||
val module = jetFile.analyzeFullyAndGetResult().moduleDescriptor
|
val module = jetFile.analyzeFullyAndGetResult().moduleDescriptor
|
||||||
|
|
||||||
val scopeToSearch = if (classIdStr != null) {
|
val (declaration, scopeToSearch) = if (classIdStr != null) {
|
||||||
module.findClassAcrossModuleDependencies(classIdStr.toClassId())!!.getDefaultType().getMemberScope()
|
module.findClassAcrossModuleDependencies(classIdStr.toClassId())!!.let { it to it.defaultType.memberScope }
|
||||||
} else {
|
} else {
|
||||||
module.getPackage(FqName(packageFqnStr!!)).memberScope
|
module.getPackage(FqName(packageFqnStr!!)).let { it to it.memberScope }
|
||||||
}
|
}
|
||||||
|
|
||||||
val psiElement = DescriptorToSourceUtils.descriptorToDeclaration(findDescriptorToRename(scopeToSearch))!!
|
val psiElement = DescriptorToSourceUtils.descriptorToDeclaration(findDescriptorToRename(declaration, scopeToSearch))!!
|
||||||
|
|
||||||
val substitution = RenamePsiElementProcessor.forElement(psiElement).substituteElementToRename(psiElement, null)
|
val substitution = RenamePsiElementProcessor.forElement(psiElement).substituteElementToRename(psiElement, null)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user