Renamed methods in MemberScope from getSmth to getContributedSmth

This commit is contained in:
Stanislav Erokhin
2015-11-04 14:46:59 +03:00
parent 6f9d9759ce
commit 2c3f58eeb7
104 changed files with 289 additions and 288 deletions
@@ -50,7 +50,7 @@ public class CodegenUtil {
@NotNull ClassifierDescriptor returnedClassifier,
@NotNull ClassifierDescriptor... valueParameterClassifiers
) {
Collection<FunctionDescriptor> functions = owner.getDefaultType().getMemberScope().getFunctions(name, NoLookupLocation.FROM_BACKEND);
Collection<FunctionDescriptor> functions = owner.getDefaultType().getMemberScope().getContributedFunctions(name, NoLookupLocation.FROM_BACKEND);
for (FunctionDescriptor function : functions) {
if (!CallResolverUtilKt.isOrOverridesSynthesized(function)
&& function.getTypeParameters().isEmpty()
@@ -42,7 +42,7 @@ public object CodegenUtilKt {
): Map<CallableMemberDescriptor, CallableDescriptor> {
if (delegateExpressionType?.isDynamic() ?: false) return mapOf();
return descriptor.getDefaultType().getMemberScope().getDescriptors().asSequence()
return descriptor.getDefaultType().getMemberScope().getContributedDescriptors().asSequence()
.filterIsInstance<CallableMemberDescriptor>()
.filter { it.getKind() == CallableMemberDescriptor.Kind.DELEGATION }
.asIterable()
@@ -58,7 +58,7 @@ public object CodegenUtilKt {
val name = overriddenDescriptor.getName()
// this is the actual member of delegateExpressionType that we are delegating to
(scope.getFunctions(name, NoLookupLocation.FROM_BACKEND) + scope.getProperties(name, NoLookupLocation.FROM_BACKEND))
(scope.getContributedFunctions(name, NoLookupLocation.FROM_BACKEND) + scope.getContributedVariables(name, NoLookupLocation.FROM_BACKEND))
.first {
(listOf(it) + DescriptorUtils.getAllOverriddenDescriptors(it)).map { it.getOriginal() }.contains(overriddenDescriptor.getOriginal())
}
@@ -469,6 +469,6 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
? DescriptorUtilsKt.getBuiltIns(elementDescriptor).getFunction(arity)
: DescriptorUtilsKt.getBuiltIns(elementDescriptor).getExtensionFunction(arity);
MemberScope scope = elementClass.getDefaultType().getMemberScope();
return scope.getFunctions(OperatorNameConventions.INVOKE, NoLookupLocation.FROM_BACKEND).iterator().next();
return scope.getContributedFunctions(OperatorNameConventions.INVOKE, NoLookupLocation.FROM_BACKEND).iterator().next();
}
}
@@ -1086,7 +1086,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
Type asmLoopRangeType = asmType(loopRangeType);
Collection<PropertyDescriptor> incrementProp =
loopRangeType.getMemberScope().getProperties(Name.identifier("increment"), NoLookupLocation.FROM_BACKEND);
loopRangeType.getMemberScope().getContributedVariables(Name.identifier("increment"), NoLookupLocation.FROM_BACKEND);
assert incrementProp.size() == 1 : loopRangeType + " " + incrementProp.size();
incrementType = asmType(incrementProp.iterator().next().getType());
@@ -412,7 +412,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
private boolean isGenericToArrayPresent() {
Collection<FunctionDescriptor> functions =
descriptor.getDefaultType().getMemberScope().getFunctions(Name.identifier("toArray"), NoLookupLocation.FROM_BACKEND);
descriptor.getDefaultType().getMemberScope().getContributedFunctions(Name.identifier("toArray"), NoLookupLocation.FROM_BACKEND);
for (FunctionDescriptor function : functions) {
if (CallResolverUtilKt.isOrOverridesSynthesized(function)) {
continue;
@@ -794,7 +794,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
Type type = typeMapper.mapType(DescriptorUtilsKt.getBuiltIns(descriptor).getArrayType(INVARIANT, descriptor.getDefaultType()));
VariableDescriptor valuesProperty =
CollectionsKt.single(descriptor.getStaticScope().getProperties(ENUM_VALUES, NoLookupLocation.FROM_BACKEND), new Function1<VariableDescriptor, Boolean>() {
CollectionsKt.single(descriptor.getStaticScope().getContributedVariables(ENUM_VALUES, NoLookupLocation.FROM_BACKEND), new Function1<VariableDescriptor, Boolean>() {
@Override
public Boolean invoke(VariableDescriptor descriptor) {
return CodegenUtil.isEnumValuesProperty(descriptor);
@@ -814,7 +814,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
private void generateEnumValueOfMethod() {
FunctionDescriptor valueOfFunction =
CollectionsKt.single(descriptor.getStaticScope().getFunctions(ENUM_VALUE_OF, NoLookupLocation.FROM_BACKEND), new Function1<FunctionDescriptor, Boolean>() {
CollectionsKt.single(descriptor.getStaticScope().getContributedFunctions(ENUM_VALUE_OF, NoLookupLocation.FROM_BACKEND), new Function1<FunctionDescriptor, Boolean>() {
@Override
public Boolean invoke(FunctionDescriptor descriptor) {
return CodegenUtil.isEnumValueOfMethod(descriptor);
@@ -70,7 +70,7 @@ public class InterfaceImplBodyCodegen(
}
override fun generateSyntheticParts() {
for (memberDescriptor in descriptor.getDefaultType().getMemberScope().getDescriptors()) {
for (memberDescriptor in descriptor.getDefaultType().getMemberScope().getContributedDescriptors()) {
if (memberDescriptor !is CallableMemberDescriptor) continue
if (memberDescriptor.getKind().isReal()) continue
@@ -70,7 +70,7 @@ public class MultifileClassCodegen(
getDeserializedCallables(compiledPackageFragment)
private fun getDeserializedCallables(compiledPackageFragment: PackageFragmentDescriptor) =
compiledPackageFragment.getMemberScope().getDescriptors(DescriptorKindFilter.CALLABLES, MemberScope.ALL_NAME_FILTER).filterIsInstance<DeserializedCallableMemberDescriptor>()
compiledPackageFragment.getMemberScope().getContributedDescriptors(DescriptorKindFilter.CALLABLES, MemberScope.ALL_NAME_FILTER).filterIsInstance<DeserializedCallableMemberDescriptor>()
public val packageParts = PackageParts(facadeFqName.parent().asString())
@@ -147,7 +147,7 @@ public class SamWrapperCodegen {
(ClassDescriptor) erasedInterfaceFunction.getContainingDeclaration(), OwnerKind.IMPLEMENTATION, state), cv, state, parentCodegen);
FunctionDescriptor invokeFunction =
functionJetType.getMemberScope().getFunctions(OperatorNameConventions.INVOKE, NoLookupLocation.FROM_BACKEND).iterator().next().getOriginal();
functionJetType.getMemberScope().getContributedFunctions(OperatorNameConventions.INVOKE, NoLookupLocation.FROM_BACKEND).iterator().next().getOriginal();
StackValue functionField = StackValue.field(functionType, ownerType, FUNCTION_FIELD_NAME, false, StackValue.none());
codegen.genDelegate(erasedInterfaceFunction, invokeFunction, functionField);
@@ -158,9 +158,9 @@ class BuilderFactoryForDuplicateSignatureDiagnostics(
}
}
descriptor.defaultType.memberScope.getDescriptors().forEach(::processMember)
descriptor.defaultType.memberScope.getContributedDescriptors().forEach(::processMember)
descriptor.getParentJavaStaticClassScope()?.run {
getDescriptors(DescriptorKindFilter.FUNCTIONS)
getContributedDescriptors(DescriptorKindFilter.FUNCTIONS)
.filter {
it is FunctionDescriptor && Visibilities.isVisible(ReceiverValue.IRRELEVANT_RECEIVER, it, descriptor)
}
@@ -118,7 +118,7 @@ public class BuiltInsSerializer(private val dependOnOldBuiltIns: Boolean) {
// TODO: perform some kind of validation? At the moment not possible because DescriptorValidator is in compiler-tests
// DescriptorValidator.validate(packageView)
val classifierDescriptors = DescriptorSerializer.sort(packageView.memberScope.getDescriptors(DescriptorKindFilter.CLASSIFIERS))
val classifierDescriptors = DescriptorSerializer.sort(packageView.memberScope.getContributedDescriptors(DescriptorKindFilter.CLASSIFIERS))
val extension = BuiltInsSerializerExtension()
serializeClasses(classifierDescriptors, extension) {
@@ -160,7 +160,7 @@ public class BuiltInsSerializer(private val dependOnOldBuiltIns: Boolean) {
val classProto = DescriptorSerializer.createTopLevel(serializer).classProto(classDescriptor).build()
writeClass(classDescriptor, classProto)
serializeClasses(classDescriptor.unsubstitutedInnerClassesScope.getDescriptors(), serializer, writeClass)
serializeClasses(classDescriptor.unsubstitutedInnerClassesScope.getContributedDescriptors(), serializer, writeClass)
}
private fun serializeClasses(
@@ -38,7 +38,7 @@ public class BuiltInsSerializerExtension : SerializerExtension() {
override fun serializePackage(packageFragments: Collection<PackageFragmentDescriptor>, proto: ProtoBuf.Package.Builder) {
val classes = packageFragments.flatMap {
it.getMemberScope().getDescriptors(DescriptorKindFilter.CLASSIFIERS).filterIsInstance<ClassDescriptor>()
it.getMemberScope().getContributedDescriptors(DescriptorKindFilter.CLASSIFIERS).filterIsInstance<ClassDescriptor>()
}
for (descriptor in DescriptorSerializer.sort(classes)) {
@@ -127,7 +127,7 @@ public class CliLightClassGenerationSupport(project: Project) : LightClassGenera
override fun getSubPackages(fqn: FqName, scope: GlobalSearchScope): Collection<FqName> {
val packageView = module.getPackage(fqn)
val members = packageView.memberScope.getDescriptors(DescriptorKindFilter.PACKAGES, MemberScope.ALL_NAME_FILTER)
val members = packageView.memberScope.getContributedDescriptors(DescriptorKindFilter.PACKAGES, MemberScope.ALL_NAME_FILTER)
return ContainerUtil.mapNotNull(members, object : Function<DeclarationDescriptor, FqName> {
override fun `fun`(member: DeclarationDescriptor): FqName? {
if (member is PackageViewDescriptor) {
@@ -37,7 +37,7 @@ import java.util.*
public object SamConversionResolverImpl : SamConversionResolver {
override fun resolveSamConstructor(name: Name, scope: MemberScope, location: LookupLocation): SamConstructorDescriptor? {
val classifier = scope.getClassifier(name, location) as? LazyJavaClassDescriptor ?: return null
val classifier = scope.getContributedClassifier(name, location) as? LazyJavaClassDescriptor ?: return null
if (classifier.getFunctionTypeForSamInterface() == null) return null
return SingleAbstractMethodUtils.createSamConstructorFunction(scope.getContainingDeclaration(), classifier)
}
@@ -305,7 +305,7 @@ public class SignaturesPropagationData {
Name name = method.getName();
JvmMethodSignature autoSignature = SIGNATURE_MAPPER.mapToJvmMethodSignature(autoMethodDescriptor);
for (KotlinType supertype : containingClass.getTypeConstructor().getSupertypes()) {
Collection<FunctionDescriptor> superFunctionCandidates = supertype.getMemberScope().getFunctions(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS);
Collection<FunctionDescriptor> superFunctionCandidates = supertype.getMemberScope().getContributedFunctions(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS);
for (FunctionDescriptor candidate : superFunctionCandidates) {
JvmMethodSignature candidateSignature = SIGNATURE_MAPPER.mapToJvmMethodSignature(candidate);
if (KotlinToJvmSignatureMapperKt.erasedSignaturesEqualIgnoringReturnTypes(autoSignature, candidateSignature)) {
@@ -51,7 +51,7 @@ private val DEFAULT_IMPORTS_FOR_JVM = ArrayList<ImportPath>().apply {
add(ImportPath("kotlin.io.*"))
fun addAllClassifiersFromScope(scope: MemberScope) {
for (descriptor in scope.getDescriptors(DescriptorKindFilter.CLASSIFIERS, MemberScope.ALL_NAME_FILTER)) {
for (descriptor in scope.getContributedDescriptors(DescriptorKindFilter.CLASSIFIERS, MemberScope.ALL_NAME_FILTER)) {
add(ImportPath(DescriptorUtils.getFqNameSafe(descriptor), false))
}
}
@@ -111,14 +111,14 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager, private val l
val possibleGetMethodNames = possibleGetMethodNames(name)
val getMethod = possibleGetMethodNames
.flatMap { memberScope.getFunctions(it, NoLookupLocation.FROM_SYNTHETIC_SCOPE) }
.flatMap { memberScope.getContributedFunctions(it, NoLookupLocation.FROM_SYNTHETIC_SCOPE) }
.singleOrNull {
isGoodGetMethod(it) && it.hasJavaOriginInHierarchy()
} ?: return result(null, possibleGetMethodNames)
val setMethodName = setMethodName(getMethod.name)
val setMethod = memberScope.getFunctions(setMethodName, NoLookupLocation.FROM_SYNTHETIC_SCOPE)
val setMethod = memberScope.getContributedFunctions(setMethodName, NoLookupLocation.FROM_SYNTHETIC_SCOPE)
.singleOrNull { isGoodSetMethod(it, getMethod) }
val propertyType = getMethod.returnType!!
@@ -203,7 +203,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager, private val l
val classifier = type.declarationDescriptor
if (classifier is ClassDescriptor) {
for (descriptor in classifier.getUnsubstitutedMemberScope().getDescriptors(DescriptorKindFilter.FUNCTIONS)) {
for (descriptor in classifier.getUnsubstitutedMemberScope().getContributedDescriptors(DescriptorKindFilter.FUNCTIONS)) {
if (descriptor is FunctionDescriptor) {
val propertyName = SyntheticJavaPropertyDescriptor.propertyNameByGetMethodName(descriptor.getName()) ?: continue
addIfNotNull(syntheticPropertyInClass(Pair(classifier, propertyName)).descriptor)
@@ -57,7 +57,7 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : BaseImportingSc
override fun getContributedSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
var result: SmartList<FunctionDescriptor>? = null
for (type in receiverTypes) {
for (function in type.memberScope.getFunctions(name, location)) {
for (function in type.memberScope.getContributedFunctions(name, location)) {
val extension = extensionForFunction(function.original)
if (extension != null) {
if (result == null) {
@@ -76,7 +76,7 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : BaseImportingSc
override fun getContributedSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>): Collection<FunctionDescriptor> {
return receiverTypes.flatMapTo(LinkedHashSet<FunctionDescriptor>()) { type ->
type.memberScope.getDescriptors(DescriptorKindFilter.FUNCTIONS)
type.memberScope.getContributedDescriptors(DescriptorKindFilter.FUNCTIONS)
.filterIsInstance<FunctionDescriptor>()
.map { extensionForFunction(it.original) }
.filterNotNull()
@@ -37,16 +37,16 @@ class AllUnderImportsScope(descriptor: DeclarationDescriptor) : BaseImportingSco
}
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean)
= scopes.flatMap { it.getDescriptors(kindFilter, nameFilter) }
= scopes.flatMap { it.getContributedDescriptors(kindFilter, nameFilter) }
override fun getContributedClassifier(name: Name, location: LookupLocation)
= scopes.asSequence().map { it.getClassifier(name, location) }.filterNotNull().singleOrNull()
= scopes.asSequence().map { it.getContributedClassifier(name, location) }.filterNotNull().singleOrNull()
override fun getContributedVariables(name: Name, location: LookupLocation)
= scopes.flatMap { it.getProperties(name, location) }
= scopes.flatMap { it.getContributedVariables(name, location) }
override fun getContributedFunctions(name: Name, location: LookupLocation)
= scopes.flatMap { it.getFunctions(name, location) }
= scopes.flatMap { it.getContributedFunctions(name, location) }
override fun printStructure(p: Printer) {
p.println(javaClass.simpleName)
@@ -53,7 +53,7 @@ public class DeclarationResolver(
public fun checkRedeclarations(c: TopDownAnalysisContext) {
for (classDescriptor in c.getDeclaredClasses().values()) {
val descriptorMap = HashMultimap.create<Name, DeclarationDescriptor>()
for (desc in classDescriptor.getUnsubstitutedMemberScope().getDescriptors()) {
for (desc in classDescriptor.getUnsubstitutedMemberScope().getContributedDescriptors()) {
if (desc is ClassDescriptor || desc is PropertyDescriptor) {
descriptorMap.put(desc.getName(), desc)
}
@@ -28,10 +28,10 @@ class NoSubpackagesInPackageScope(packageDescriptor: PackageViewDescriptor) : Ab
override fun getPackage(name: Name): PackageViewDescriptor? = null
override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
val modifiedFilter = kindFilter.withoutKinds(DescriptorKindFilter.PACKAGES_MASK)
if (modifiedFilter.kindMask == 0) return listOf()
return workerScope.getDescriptors(modifiedFilter, nameFilter).filter { it !is PackageViewDescriptor }
return workerScope.getContributedDescriptors(modifiedFilter, nameFilter).filter { it !is PackageViewDescriptor }
}
}
@@ -88,12 +88,12 @@ object OverloadUtil {
collectModulePackageMembersWithSameName(packageMembersByName, c.functions.values) {
scope, name ->
scope.getFunctions(name, NoLookupLocation.WHEN_CHECK_REDECLARATIONS)
scope.getContributedFunctions(name, NoLookupLocation.WHEN_CHECK_REDECLARATIONS)
}
collectModulePackageMembersWithSameName(packageMembersByName, c.properties.values) {
scope, name ->
scope.getProperties(name, NoLookupLocation.WHEN_CHECK_REDECLARATIONS).filterIsInstance<CallableMemberDescriptor>()
scope.getContributedVariables(name, NoLookupLocation.WHEN_CHECK_REDECLARATIONS).filterIsInstance<CallableMemberDescriptor>()
}
// TODO handle constructor redeclarations in modules. See also: https://youtrack.jetbrains.com/issue/KT-3632
@@ -794,9 +794,9 @@ public class OverrideResolver {
) {
for (KotlinType supertype : declaringClass.getTypeConstructor().getSupertypes()) {
Set<CallableMemberDescriptor> all = Sets.newLinkedHashSet();
all.addAll(supertype.getMemberScope().getFunctions(declared.getName(), NoLookupLocation.WHEN_CHECK_OVERRIDES));
all.addAll(supertype.getMemberScope().getContributedFunctions(declared.getName(), NoLookupLocation.WHEN_CHECK_OVERRIDES));
//noinspection unchecked
all.addAll((Collection) supertype.getMemberScope().getProperties(declared.getName(), NoLookupLocation.WHEN_CHECK_OVERRIDES));
all.addAll((Collection) supertype.getMemberScope().getContributedVariables(declared.getName(), NoLookupLocation.WHEN_CHECK_OVERRIDES));
for (CallableMemberDescriptor fromSuper : all) {
if (OverridingUtil.DEFAULT.isOverridableBy(fromSuper, declared).getResult() == OVERRIDABLE) {
if (Visibilities.isVisible(ReceiverValue.IRRELEVANT_RECEIVER, fromSuper, declared)) {
@@ -80,8 +80,8 @@ public class QualifiedExpressionResolver(val symbolUsageValidator: SymbolUsageVa
val lastPart = qualifierPartList.last()
val classifier = when (qualifier) {
is PackageViewDescriptor -> qualifier.memberScope.getClassifier(lastPart.name, lastPart.location)
is ClassDescriptor -> qualifier.unsubstitutedInnerClassesScope.getClassifier(lastPart.name, lastPart.location)
is PackageViewDescriptor -> qualifier.memberScope.getContributedClassifier(lastPart.name, lastPart.location)
is ClassDescriptor -> qualifier.unsubstitutedInnerClassesScope.getContributedClassifier(lastPart.name, lastPart.location)
else -> null
}
storeResult(trace, lastPart.expression, classifier, scope.ownerDescriptor, inImport = false, isQualifier = false)
@@ -183,24 +183,24 @@ public class QualifiedExpressionResolver(val symbolUsageValidator: SymbolUsageVa
when (packageOrClassDescriptor) {
is PackageViewDescriptor -> {
val packageScope = packageOrClassDescriptor.memberScope
descriptors.addIfNotNull(packageScope.getClassifier(lastName, location))
descriptors.addAll(packageScope.getProperties(lastName, location))
descriptors.addAll(packageScope.getFunctions(lastName, location))
descriptors.addIfNotNull(packageScope.getContributedClassifier(lastName, location))
descriptors.addAll(packageScope.getContributedVariables(lastName, location))
descriptors.addAll(packageScope.getContributedFunctions(lastName, location))
}
is ClassDescriptor -> {
descriptors.addIfNotNull(
packageOrClassDescriptor.unsubstitutedInnerClassesScope.getClassifier(lastName, location)
packageOrClassDescriptor.unsubstitutedInnerClassesScope.getContributedClassifier(lastName, location)
)
val staticClassScope = packageOrClassDescriptor.staticScope
descriptors.addAll(staticClassScope.getFunctions(lastName, location))
descriptors.addAll(staticClassScope.getProperties(lastName, location))
descriptors.addAll(staticClassScope.getContributedFunctions(lastName, location))
descriptors.addAll(staticClassScope.getContributedVariables(lastName, location))
if (packageOrClassDescriptor.kind == ClassKind.OBJECT) {
descriptors.addAll(packageOrClassDescriptor.unsubstitutedMemberScope.getFunctions(lastName, location).map {
descriptors.addAll(packageOrClassDescriptor.unsubstitutedMemberScope.getContributedFunctions(lastName, location).map {
FunctionImportedFromObject(it)
})
val properties = packageOrClassDescriptor.unsubstitutedMemberScope.getProperties(lastName, location)
val properties = packageOrClassDescriptor.unsubstitutedMemberScope.getContributedVariables(lastName, location)
.filterIsInstance<PropertyDescriptor>().map { PropertyImportedFromObject(it) }
descriptors.addAll(properties)
}
@@ -230,8 +230,8 @@ public class QualifiedExpressionResolver(val symbolUsageValidator: SymbolUsageVa
is ClassDescriptor -> {
val memberScope = packageOrClassDescriptor.unsubstitutedMemberScope
descriptors.addAll(memberScope.getFunctions(lastName, lastPart.location))
descriptors.addAll(memberScope.getProperties(lastName, lastPart.location))
descriptors.addAll(memberScope.getContributedFunctions(lastName, lastPart.location))
descriptors.addAll(memberScope.getContributedVariables(lastName, lastPart.location))
if (descriptors.isNotEmpty()) {
trace.report(Errors.CANNOT_BE_IMPORTED.on(lastPart.expression, lastName))
}
@@ -304,7 +304,7 @@ public class QualifiedExpressionResolver(val symbolUsageValidator: SymbolUsageVa
val nextDescriptor = when (descriptor) {
// TODO: support inner classes which captured type parameter from outer class
is ClassDescriptor ->
descriptor.unsubstitutedInnerClassesScope.getClassifier(qualifierPart.name, qualifierPart.location)
descriptor.unsubstitutedInnerClassesScope.getContributedClassifier(qualifierPart.name, qualifierPart.location)
is PackageViewDescriptor -> {
val packageView = if (qualifierPart.typeArguments == null) {
moduleDescriptor.getPackage(descriptor.fqName.child(qualifierPart.name))
@@ -314,7 +314,7 @@ public class QualifiedExpressionResolver(val symbolUsageValidator: SymbolUsageVa
if (packageView != null && !packageView.isEmpty()) {
packageView
} else {
descriptor.memberScope.getClassifier(qualifierPart.name, qualifierPart.location)
descriptor.memberScope.getContributedClassifier(qualifierPart.name, qualifierPart.location)
}
}
else -> null
@@ -105,7 +105,7 @@ private object FunctionCollector : CallableDescriptorCollector<FunctionDescripto
override fun getMembersByName(receiver: KotlinType, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
val receiverScope = receiver.memberScope
val members = receiverScope.getFunctions(name, location)
val members = receiverScope.getContributedFunctions(name, location)
val constructors = getConstructors(receiverScope.memberScopeAsImportingScope(), name, location, { !isStaticNestedClass(it) })
if (name == OperatorNameConventions.INVOKE && KotlinBuiltIns.isExtensionFunctionType(receiver)) {
@@ -194,7 +194,7 @@ private object VariableCollector : CallableDescriptorCollector<VariableDescripto
override fun getMembersByName(receiver: KotlinType, name: Name, location: LookupLocation): Collection<VariableDescriptor> {
val memberScope = receiver.memberScope
val properties = memberScope.getProperties(name, location)
val properties = memberScope.getContributedVariables(name, location)
val fakeDescriptor = getFakeDescriptorForObject(memberScope.memberScopeAsImportingScope(), name, location)
return if (fakeDescriptor != null) properties + fakeDescriptor else properties
}
@@ -50,7 +50,7 @@ class DynamicCallableDescriptors(private val builtIns: KotlinBuiltIns) {
p.println(javaClass.getSimpleName(), ": dynamic candidates for " + call)
}
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
override fun getContributedFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
if (isAugmentedAssignmentConvention(name)) return listOf()
if (call.getCallType() == Call.CallType.INVOKE
&& call.getValueArgumentList() == null && call.getFunctionLiteralArguments().isEmpty()) {
@@ -78,7 +78,7 @@ class DynamicCallableDescriptors(private val builtIns: KotlinBuiltIns) {
return false
}
override fun getProperties(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
return if (call.getValueArgumentList() == null && call.getValueArguments().isEmpty()) {
listOf(createDynamicProperty(owner, name, call))
}
@@ -72,7 +72,7 @@ public class LazyDeclarationResolver {
// class A {} class A { fun foo(): A<completion here>}
// and if we find the class by name only, we may b-not get the right one.
// This call is only needed to make sure the classes are written to trace
ClassifierDescriptor scopeDescriptor = scope.getClassifier(classOrObject.getNameAsSafeName(), location);
ClassifierDescriptor scopeDescriptor = scope.getContributedClassifier(classOrObject.getNameAsSafeName(), location);
DeclarationDescriptor descriptor = getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, classOrObject);
if (descriptor == null) {
@@ -148,7 +148,7 @@ public class LazyDeclarationResolver {
public DeclarationDescriptor visitNamedFunction(@NotNull KtNamedFunction function, Void data) {
LookupLocation location = lookupLocationFor(function, function.isTopLevel());
MemberScope scopeForDeclaration = getMemberScopeDeclaredIn(function, location);
scopeForDeclaration.getFunctions(function.getNameAsSafeName(), location);
scopeForDeclaration.getContributedFunctions(function.getNameAsSafeName(), location);
return getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, function);
}
@@ -160,7 +160,7 @@ public class LazyDeclarationResolver {
// This is a primary constructor parameter
ClassDescriptor classDescriptor = getClassDescriptor(jetClass, lookupLocationFor(jetClass, false));
if (parameter.hasValOrVar()) {
classDescriptor.getDefaultType().getMemberScope().getProperties(parameter.getNameAsSafeName(), lookupLocationFor(parameter, false));
classDescriptor.getDefaultType().getMemberScope().getContributedVariables(parameter.getNameAsSafeName(), lookupLocationFor(parameter, false));
return getBindingContext().get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, parameter);
}
else {
@@ -204,7 +204,7 @@ public class LazyDeclarationResolver {
public DeclarationDescriptor visitProperty(@NotNull KtProperty property, Void data) {
LookupLocation location = lookupLocationFor(property, property.isTopLevel());
MemberScope scopeForDeclaration = getMemberScopeDeclaredIn(property, location);
scopeForDeclaration.getProperties(property.getNameAsSafeName(), location);
scopeForDeclaration.getContributedVariables(property.getNameAsSafeName(), location);
return getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, property);
}
@@ -288,7 +288,7 @@ public class ResolveSession implements KotlinCodeAnalyzer, LazyClassContext {
public ClassDescriptor getClassDescriptorForScript(@NotNull KtScript script) {
MemberScope memberScope = lazyDeclarationResolver.getMemberScopeDeclaredIn(script, NoLookupLocation.FOR_SCRIPT);
FqName fqName = ScriptNameUtil.classNameForScript(script);
ClassifierDescriptor classifier = memberScope.getClassifier(fqName.shortName(), NoLookupLocation.FOR_SCRIPT);
ClassifierDescriptor classifier = memberScope.getContributedClassifier(fqName.shortName(), NoLookupLocation.FOR_SCRIPT);
assert classifier != null : "No descriptor for " + fqName + " in file " + script.getContainingFile();
return (ClassDescriptor) classifier;
}
@@ -81,7 +81,7 @@ public class ResolveSessionUtils {
MemberScope scope = outerScope;
for (Name name : path.pathSegments()) {
ClassifierDescriptor classifier = scope.getClassifier(name, NoLookupLocation.WHEN_FIND_BY_FQNAME);
ClassifierDescriptor classifier = scope.getContributedClassifier(name, NoLookupLocation.WHEN_FIND_BY_FQNAME);
if (!(classifier instanceof ClassDescriptor)) return null;
scope = ((ClassDescriptor) classifier).getUnsubstitutedInnerClassesScope();
}
@@ -61,12 +61,12 @@ protected constructor(
override fun getContainingDeclaration() = thisDescriptor
override fun getClassifier(name: Name, location: LookupLocation): ClassDescriptor? {
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassDescriptor? {
recordLookup(name, location)
return classDescriptors(name).firstOrNull()
}
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
override fun getContributedFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
recordLookup(name, location)
return functionDescriptors(name)
}
@@ -94,7 +94,7 @@ protected constructor(
protected abstract fun getNonDeclaredFunctions(name: Name, result: MutableSet<FunctionDescriptor>)
override fun getProperties(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
recordLookup(name, location)
return propertyDescriptors(name)
}
@@ -138,19 +138,19 @@ protected constructor(
else if (declaration is KtFunction) {
val name = declaration.nameAsSafeName
if (nameFilter(name)) {
result.addAll(getFunctions(name, location))
result.addAll(getContributedFunctions(name, location))
}
}
else if (declaration is KtProperty) {
val name = declaration.nameAsSafeName
if (nameFilter(name)) {
result.addAll(getProperties(name, location))
result.addAll(getContributedVariables(name, location))
}
}
else if (declaration is KtParameter) {
val name = declaration.nameAsSafeName
if (nameFilter(name)) {
result.addAll(getProperties(name, location))
result.addAll(getContributedVariables(name, location))
}
}
else if (declaration is KtScript) {
@@ -361,7 +361,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
}
Name name = ((JetClassOrObjectInfo) companionObjectInfo).getName();
assert name != null;
getUnsubstitutedMemberScope().getClassifier(name, NoLookupLocation.WHEN_GET_COMPANION_OBJECT);
getUnsubstitutedMemberScope().getContributedClassifier(name, NoLookupLocation.WHEN_GET_COMPANION_OBJECT);
ClassDescriptor companionObjectDescriptor = c.getTrace().get(BindingContext.CLASS, companionObject);
if (companionObjectDescriptor instanceof LazyClassDescriptor) {
assert DescriptorUtils.isCompanionObject(companionObjectDescriptor) : "Not a companion object: " + companionObjectDescriptor;
@@ -57,8 +57,8 @@ public open class LazyClassMemberScope(
computeExtraDescriptors(NoLookupLocation.FOR_ALREADY_TRACKED)
}
override fun getDescriptors(kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
val result = LinkedHashSet(descriptorsFromDeclaredElements())
result.addAll(extraDescriptors())
return result
@@ -67,12 +67,12 @@ public open class LazyClassMemberScope(
protected open fun computeExtraDescriptors(location: LookupLocation): Collection<DeclarationDescriptor> {
val result = ArrayList<DeclarationDescriptor>()
for (supertype in thisDescriptor.typeConstructor.supertypes) {
for (descriptor in supertype.memberScope.getDescriptors()) {
for (descriptor in supertype.memberScope.getContributedDescriptors()) {
if (descriptor is FunctionDescriptor) {
result.addAll(getFunctions(descriptor.name, location))
result.addAll(getContributedFunctions(descriptor.name, location))
}
else if (descriptor is PropertyDescriptor) {
result.addAll(getProperties(descriptor.name, location))
result.addAll(getContributedVariables(descriptor.name, location))
}
// Nothing else is inherited
}
@@ -115,9 +115,9 @@ public open class LazyClassMemberScope(
OverrideResolver.resolveUnknownVisibilities(result, trace)
}
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
override fun getContributedFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
// TODO: this should be handled by lazy function descriptors
val functions = super.getFunctions(name, location)
val functions = super.getContributedFunctions(name, location)
resolveUnknownVisibilitiesForMembers(functions)
return functions
}
@@ -127,7 +127,7 @@ public open class LazyClassMemberScope(
val fromSupertypes = Lists.newArrayList<FunctionDescriptor>()
for (supertype in thisDescriptor.typeConstructor.supertypes) {
fromSupertypes.addAll(supertype.memberScope.getFunctions(name, location))
fromSupertypes.addAll(supertype.memberScope.getContributedFunctions(name, location))
}
result.addAll(generateDelegatingDescriptors(name, EXTRACT_FUNCTIONS, result))
generateDataClassMethods(result, name, location)
@@ -149,7 +149,7 @@ public open class LazyClassMemberScope(
if (parameter.getType().isError()) continue
if (!primaryConstructorParameters.get(parameter.index).hasValOrVar()) continue
val properties = getProperties(parameter.name, location)
val properties = getContributedVariables(parameter.name, location)
if (properties.isEmpty()) continue
val property = properties.iterator().next()
@@ -167,7 +167,7 @@ public open class LazyClassMemberScope(
if (name == DescriptorResolver.COPY_METHOD_NAME) {
for (parameter in constructor.getValueParameters()) {
// force properties resolution to fill BindingContext.VALUE_PARAMETER_AS_PROPERTY slice
getProperties(parameter.name, location)
getContributedVariables(parameter.name, location)
}
val copyFunctionDescriptor = DescriptorResolver.createCopyFunctionDescriptor(constructor.getValueParameters(), thisDescriptor, trace)
@@ -175,9 +175,9 @@ public open class LazyClassMemberScope(
}
}
override fun getProperties(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
// TODO: this should be handled by lazy property descriptors
val properties = super.getProperties(name, location)
val properties = super.getContributedVariables(name, location)
resolveUnknownVisibilitiesForMembers(properties as Collection<CallableMemberDescriptor>)
return properties
}
@@ -197,7 +197,7 @@ public open class LazyClassMemberScope(
// Members from supertypes
val fromSupertypes = ArrayList<PropertyDescriptor>()
for (supertype in thisDescriptor.typeConstructor.supertypes) {
fromSupertypes.addAll(supertype.memberScope.getProperties(name, NoLookupLocation.FOR_ALREADY_TRACKED))
fromSupertypes.addAll(supertype.memberScope.getContributedVariables(name, NoLookupLocation.FOR_ALREADY_TRACKED))
}
result.addAll(generateDelegatingDescriptors(name, EXTRACT_PROPERTIES, result))
generateFakeOverrides(name, fromSupertypes, result, javaClass<PropertyDescriptor>())
@@ -249,14 +249,14 @@ public open class LazyClassMemberScope(
var n = 1
while (true) {
val componentName = createComponentName(n)
val functions = getFunctions(componentName, location)
val functions = getContributedFunctions(componentName, location)
if (functions.isEmpty()) break
result.addAll(functions)
n++
}
result.addAll(getFunctions(Name.identifier("copy"), location))
result.addAll(getContributedFunctions(Name.identifier("copy"), location))
}
override fun getPackage(name: Name): PackageViewDescriptor? = null
@@ -315,13 +315,13 @@ public open class LazyClassMemberScope(
companion object {
private val EXTRACT_FUNCTIONS: MemberExtractor<FunctionDescriptor> = object : MemberExtractor<FunctionDescriptor> {
override fun extract(extractFrom: KotlinType, name: Name): Collection<FunctionDescriptor> {
return extractFrom.memberScope.getFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED)
return extractFrom.memberScope.getContributedFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED)
}
}
private val EXTRACT_PROPERTIES: MemberExtractor<PropertyDescriptor> = object : MemberExtractor<PropertyDescriptor> {
override fun extract(extractFrom: KotlinType, name: Name): Collection<PropertyDescriptor> {
return extractFrom.memberScope.getProperties(name, NoLookupLocation.FOR_ALREADY_TRACKED)
return extractFrom.memberScope.getContributedVariables(name, NoLookupLocation.FOR_ALREADY_TRACKED)
}
}
}
@@ -30,7 +30,7 @@ public class LazyPackageMemberScope(
thisPackage: PackageFragmentDescriptor)
: AbstractLazyMemberScope<PackageFragmentDescriptor, PackageMemberDeclarationProvider>(resolveSession, declarationProvider, thisPackage, resolveSession.trace) {
override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
return computeDescriptorsFromDeclaredElements(kindFilter, nameFilter, NoLookupLocation.WHEN_GET_ALL_DESCRIPTORS)
}
@@ -44,11 +44,11 @@ public class LazyScriptClassMemberScope protected constructor(
override fun computeExtraDescriptors(location: LookupLocation): Collection<DeclarationDescriptor> {
return (super.computeExtraDescriptors(location)
+ getProperties(Name.identifier(ScriptDescriptor.LAST_EXPRESSION_VALUE_FIELD_NAME), location)
+ getContributedVariables(Name.identifier(ScriptDescriptor.LAST_EXPRESSION_VALUE_FIELD_NAME), location)
+ getPropertiesForScriptParameters()).toReadOnlyList()
}
private fun getPropertiesForScriptParameters() = getPrimaryConstructor()!!.valueParameters.flatMap { getProperties(it.name, NoLookupLocation.FOR_SCRIPT) }
private fun getPropertiesForScriptParameters() = getPrimaryConstructor()!!.valueParameters.flatMap { getContributedVariables(it.name, NoLookupLocation.FOR_SCRIPT) }
override fun getNonDeclaredProperties(name: Name, result: MutableSet<PropertyDescriptor>) {
super.getNonDeclaredProperties(name, result)
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.utils.Printer
public class FilteringScope(private val workerScope: MemberScope, private val predicate: (DeclarationDescriptor) -> Boolean) : MemberScope {
override fun getFunctions(name: Name, location: LookupLocation) = workerScope.getFunctions(name, location).filter(predicate)
override fun getContributedFunctions(name: Name, location: LookupLocation) = workerScope.getContributedFunctions(name, location).filter(predicate)
override fun getContainingDeclaration() = workerScope.getContainingDeclaration()
@@ -32,12 +32,12 @@ public class FilteringScope(private val workerScope: MemberScope, private val pr
override fun getPackage(name: Name) = filterDescriptor(workerScope.getPackage(name))
override fun getClassifier(name: Name, location: LookupLocation) = filterDescriptor(workerScope.getClassifier(name, location))
override fun getContributedClassifier(name: Name, location: LookupLocation) = filterDescriptor(workerScope.getContributedClassifier(name, location))
override fun getProperties(name: Name, location: LookupLocation) = workerScope.getProperties(name, location).filter(predicate)
override fun getContributedVariables(name: Name, location: LookupLocation) = workerScope.getContributedVariables(name, location).filter(predicate)
override fun getDescriptors(kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean) = workerScope.getDescriptors(kindFilter, nameFilter).filter(predicate)
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean) = workerScope.getContributedDescriptors(kindFilter, nameFilter).filter(predicate)
override fun printScopeStructure(p: Printer) {
p.println(javaClass.getSimpleName(), " {")
@@ -39,13 +39,13 @@ public class LexicalChainedScope @JvmOverloads constructor(
private val scopeChain = memberScopes.clone()
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean)
= getFromAllScopes(scopeChain) { it.getDescriptors() }
= getFromAllScopes(scopeChain) { it.getContributedDescriptors() }
override fun getContributedClassifier(name: Name, location: LookupLocation) = getFirstMatch(scopeChain) { it.getClassifier(name, location) }
override fun getContributedClassifier(name: Name, location: LookupLocation) = getFirstMatch(scopeChain) { it.getContributedClassifier(name, location) }
override fun getContributedVariables(name: Name, location: LookupLocation) = getFromAllScopes(scopeChain) { it.getProperties(name, location) }
override fun getContributedVariables(name: Name, location: LookupLocation) = getFromAllScopes(scopeChain) { it.getContributedVariables(name, location) }
override fun getContributedFunctions(name: Name, location: LookupLocation) = getFromAllScopes(scopeChain) { it.getFunctions(name, location) }
override fun getContributedFunctions(name: Name, location: LookupLocation) = getFromAllScopes(scopeChain) { it.getContributedFunctions(name, location) }
override fun toString(): String = debugName
@@ -134,13 +134,13 @@ private class MemberScopeToImportingScopeAdapter(override val parent: ImportingS
= emptyList<FunctionDescriptor>()
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean)
= memberScope.getDescriptors(kindFilter, nameFilter)
= memberScope.getContributedDescriptors(kindFilter, nameFilter)
override fun getContributedClassifier(name: Name, location: LookupLocation) = memberScope.getClassifier(name, location)
override fun getContributedClassifier(name: Name, location: LookupLocation) = memberScope.getContributedClassifier(name, location)
override fun getContributedVariables(name: Name, location: LookupLocation) = memberScope.getProperties(name, location)
override fun getContributedVariables(name: Name, location: LookupLocation) = memberScope.getContributedVariables(name, location)
override fun getContributedFunctions(name: Name, location: LookupLocation) = memberScope.getFunctions(name, location)
override fun getContributedFunctions(name: Name, location: LookupLocation) = memberScope.getContributedFunctions(name, location)
override fun equals(other: Any?) = other is MemberScopeToImportingScopeAdapter && other.memberScope == memberScope
@@ -135,10 +135,10 @@ private inline fun resolveSupertypesByMembers(
}
private fun getFunctionMembers(type: KotlinType, name: Name, location: LookupLocation): Collection<MemberDescriptor> =
type.memberScope.getFunctions(name, location)
type.memberScope.getContributedFunctions(name, location)
private fun getPropertyMembers(type: KotlinType, name: Name, location: LookupLocation): Collection<MemberDescriptor> =
type.memberScope.getProperties(name, location).filterIsInstanceTo(SmartList<MemberDescriptor>())
type.memberScope.getContributedVariables(name, location).filterIsInstanceTo(SmartList<MemberDescriptor>())
private fun isConcreteMember(supertype: KotlinType, memberDescriptor: MemberDescriptor): Boolean {
// "Concrete member" is a function or a property that is not abstract,
@@ -37,7 +37,7 @@ class DeserializedScopeValidationVisitor : ValidationVisitor() {
private fun validateDeserializedScope(scope: MemberScope) {
val isPackageViewScope = scope.safeGetContainingDeclaration() is PackageViewDescriptor
if (scope is DeserializedMemberScope || isPackageViewScope) {
val relevantDescriptors = scope.getDescriptors().filter { member ->
val relevantDescriptors = scope.getContributedDescriptors().filter { member ->
member is CallableMemberDescriptor && member.getKind().isReal() || (!isPackageViewScope && member is ClassDescriptor)
}
checkSorted(relevantDescriptors, scope.getContainingDeclaration())
@@ -118,12 +118,12 @@ public class MultiModuleJavaAnalysisCustomTest : UsefulTestCase() {
private fun checkClassInPackage(moduleDescriptor: ModuleDescriptor, packageName: String, className: String) {
val kotlinPackage = moduleDescriptor.getPackage(FqName(packageName))
val kotlinClassName = Name.identifier(className)
val kotlinClass = kotlinPackage.memberScope.getClassifier(kotlinClassName, NoLookupLocation.FROM_TEST) as ClassDescriptor
val kotlinClass = kotlinPackage.memberScope.getContributedClassifier(kotlinClassName, NoLookupLocation.FROM_TEST) as ClassDescriptor
checkClass(kotlinClass)
}
private fun checkClass(classDescriptor: ClassDescriptor) {
classDescriptor.getDefaultType().getMemberScope().getDescriptors().filterIsInstance<CallableDescriptor>().forEach {
classDescriptor.getDefaultType().getMemberScope().getContributedDescriptors().filterIsInstance<CallableDescriptor>().forEach {
checkCallable(it)
}
@@ -228,9 +228,9 @@ public abstract class AbstractJvmRuntimeDescriptorLoaderTest : TestCaseWithTmpdi
}
}
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? = classifierMap[name]
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? = classifierMap[name]
override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> = classifierMap.values
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> = classifierMap.values
override fun printScopeStructure(p: Printer) {
p.println("runtime descriptor loader test")
@@ -169,7 +169,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends KotlinLite
protected static FunctionDescriptor getFunctionDescriptor(@NotNull PackageFragmentDescriptor packageView, @NotNull String name) {
Name functionName = Name.identifier(name);
MemberScope memberScope = packageView.getMemberScope();
Collection<FunctionDescriptor> functions = memberScope.getFunctions(functionName, NoLookupLocation.FROM_TEST);
Collection<FunctionDescriptor> functions = memberScope.getContributedFunctions(functionName, NoLookupLocation.FROM_TEST);
assert functions.size() == 1 : "Failed to find function " + functionName + " in class" + "." + packageView.getName();
return functions.iterator().next();
}
@@ -178,7 +178,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends KotlinLite
private static FunctionDescriptor getFunctionDescriptor(@NotNull ClassDescriptor classDescriptor, @NotNull String name) {
Name functionName = Name.identifier(name);
MemberScope memberScope = classDescriptor.getMemberScope(Collections.<TypeProjection>emptyList());
Collection<FunctionDescriptor> functions = memberScope.getFunctions(functionName, NoLookupLocation.FROM_TEST);
Collection<FunctionDescriptor> functions = memberScope.getContributedFunctions(functionName, NoLookupLocation.FROM_TEST);
assert functions.size() == 1 : "Failed to find function " + functionName + " in class" + "." + classDescriptor.getName();
return functions.iterator().next();
}
@@ -187,13 +187,13 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends KotlinLite
protected static PropertyDescriptor getPropertyDescriptor(@NotNull PackageFragmentDescriptor packageView, @NotNull String name, boolean failOnMissing) {
Name propertyName = Name.identifier(name);
MemberScope memberScope = packageView.getMemberScope();
Collection<PropertyDescriptor> properties = memberScope.getProperties(propertyName, NoLookupLocation.FROM_TEST);
Collection<PropertyDescriptor> properties = memberScope.getContributedVariables(propertyName, NoLookupLocation.FROM_TEST);
if (properties.isEmpty()) {
for (DeclarationDescriptor descriptor : DescriptorUtils.getAllDescriptors(memberScope)) {
if (descriptor instanceof ClassDescriptor) {
Collection<PropertyDescriptor> classProperties =
((ClassDescriptor) descriptor).getMemberScope(Collections.<TypeProjection>emptyList())
.getProperties(propertyName, NoLookupLocation.FROM_TEST);
.getContributedVariables(propertyName, NoLookupLocation.FROM_TEST);
if (!classProperties.isEmpty()) {
properties = classProperties;
break;
@@ -214,7 +214,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends KotlinLite
private static PropertyDescriptor getPropertyDescriptor(@NotNull ClassDescriptor classDescriptor, @NotNull String name) {
Name propertyName = Name.identifier(name);
MemberScope memberScope = classDescriptor.getMemberScope(Collections.<TypeProjection>emptyList());
Collection<PropertyDescriptor> properties = memberScope.getProperties(propertyName, NoLookupLocation.FROM_TEST);
Collection<PropertyDescriptor> properties = memberScope.getContributedVariables(propertyName, NoLookupLocation.FROM_TEST);
assert properties.size() == 1 : "Failed to find property " + propertyName + " in class " + classDescriptor.getName();
return properties.iterator().next();
}
@@ -222,7 +222,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends KotlinLite
@NotNull
protected static ClassDescriptor getClassDescriptor(@NotNull PackageFragmentDescriptor packageView, @NotNull String name) {
Name className = Name.identifier(name);
ClassifierDescriptor aClass = packageView.getMemberScope().getClassifier(className, NoLookupLocation.FROM_TEST);
ClassifierDescriptor aClass = packageView.getMemberScope().getContributedClassifier(className, NoLookupLocation.FROM_TEST);
assertNotNull("Failed to find class: " + packageView.getName() + "." + className, aClass);
assert aClass instanceof ClassDescriptor : "Not a class: " + aClass;
return (ClassDescriptor) aClass;
@@ -232,7 +232,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends KotlinLite
private static ClassDescriptor getInnerClassDescriptor(@NotNull ClassDescriptor classDescriptor, @NotNull String name) {
Name propertyName = Name.identifier(name);
MemberScope memberScope = classDescriptor.getMemberScope(Collections.<TypeProjection>emptyList());
ClassifierDescriptor innerClass = memberScope.getClassifier(propertyName, NoLookupLocation.FROM_TEST);
ClassifierDescriptor innerClass = memberScope.getContributedClassifier(propertyName, NoLookupLocation.FROM_TEST);
assert innerClass instanceof ClassDescriptor : "Failed to find inner class " +
propertyName +
" in class " +
@@ -412,7 +412,7 @@ public class DescriptorValidator {
public Void visitVariableDescriptor(
VariableDescriptor descriptor, MemberScope scope
) {
assertFound(scope, descriptor, scope.getProperties(descriptor.getName(), NoLookupLocation.FROM_TEST));
assertFound(scope, descriptor, scope.getContributedVariables(descriptor.getName(), NoLookupLocation.FROM_TEST));
return null;
}
@@ -420,7 +420,7 @@ public class DescriptorValidator {
public Void visitFunctionDescriptor(
FunctionDescriptor descriptor, MemberScope scope
) {
assertFound(scope, descriptor, scope.getFunctions(descriptor.getName(), NoLookupLocation.FROM_TEST));
assertFound(scope, descriptor, scope.getContributedFunctions(descriptor.getName(), NoLookupLocation.FROM_TEST));
return null;
}
@@ -428,7 +428,7 @@ public class DescriptorValidator {
public Void visitTypeParameterDescriptor(
TypeParameterDescriptor descriptor, MemberScope scope
) {
assertFound(scope, descriptor, scope.getClassifier(descriptor.getName(), NoLookupLocation.FROM_TEST), true);
assertFound(scope, descriptor, scope.getContributedClassifier(descriptor.getName(), NoLookupLocation.FROM_TEST), true);
return null;
}
@@ -436,7 +436,7 @@ public class DescriptorValidator {
public Void visitClassDescriptor(
ClassDescriptor descriptor, MemberScope scope
) {
assertFound(scope, descriptor, scope.getClassifier(descriptor.getName(), NoLookupLocation.FROM_TEST), true);
assertFound(scope, descriptor, scope.getContributedClassifier(descriptor.getName(), NoLookupLocation.FROM_TEST), true);
return null;
}
@@ -73,7 +73,7 @@ public class BoundsSubstitutorTest extends KotlinTestWithEnvironment {
KtFile jetFile = KtPsiFactoryKt.KtPsiFactory(getProject()).createFile("fun.kt", text);
ModuleDescriptor module = LazyResolveTestUtil.resolveLazily(Collections.singletonList(jetFile), getEnvironment());
Collection<FunctionDescriptor> functions =
module.getPackage(FqName.ROOT).getMemberScope().getFunctions(Name.identifier("f"), NoLookupLocation.FROM_TEST);
module.getPackage(FqName.ROOT).getMemberScope().getContributedFunctions(Name.identifier("f"), NoLookupLocation.FROM_TEST);
assert functions.size() == 1 : "Many functions defined";
FunctionDescriptor function = ContainerUtil.getFirstItem(functions);
@@ -65,7 +65,7 @@ public class LazyJavaPackageFragmentProvider(
javaClass.outerClass?.let { outerClass ->
val outerClassScope = resolveClass(outerClass)?.unsubstitutedInnerClassesScope
return outerClassScope?.getClassifier(javaClass.name, NoLookupLocation.FROM_JAVA_LOADER) as? ClassDescriptor
return outerClassScope?.getContributedClassifier(javaClass.name, NoLookupLocation.FROM_JAVA_LOADER) as? ClassDescriptor
}
val kotlinResult = c.resolveKotlinBinaryClass(c.components.kotlinClassFinder.findKotlinClass(javaClass))
@@ -129,7 +129,7 @@ class LazyJavaAnnotationDescriptor(
//TODO: (module refactoring) moduleClassResolver should be used here
val enumClass = c.javaClassResolver.resolveClass(containingJavaClass) ?: return null
val classifier = enumClass.getUnsubstitutedInnerClassesScope().getClassifier(element.getName(), NoLookupLocation.FROM_JAVA_LOADER)
val classifier = enumClass.getUnsubstitutedInnerClassesScope().getContributedClassifier(element.getName(), NoLookupLocation.FROM_JAVA_LOADER)
if (classifier !is ClassDescriptor) return null
return factory.createEnumValue(classifier)
@@ -302,7 +302,7 @@ public class LazyJavaClassMemberScope(
private fun getFunctionsFromSupertypes(name: Name): Set<SimpleFunctionDescriptor> {
return getContainingDeclaration().typeConstructor.supertypes.flatMap {
it.memberScope.getFunctions(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS).map { f -> f as SimpleFunctionDescriptor }
it.memberScope.getContributedFunctions(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS).map { f -> f as SimpleFunctionDescriptor }
}.toSet()
}
@@ -414,7 +414,7 @@ public class LazyJavaClassMemberScope(
private fun getPropertiesFromSupertypes(name: Name): Set<PropertyDescriptor> {
return getContainingDeclaration().typeConstructor.supertypes.flatMap {
it.memberScope.getProperties(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS).map { p -> p }
it.memberScope.getContributedVariables(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS).map { p -> p }
}.toSet()
}
@@ -615,7 +615,7 @@ public class LazyJavaClassMemberScope(
override fun getDispatchReceiverParameter(): ReceiverParameterDescriptor? =
DescriptorUtils.getDispatchReceiverParameterIfNeeded(getContainingDeclaration())
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
recordLookup(name, location)
return nestedClasses(name)
}
@@ -628,7 +628,7 @@ public class LazyJavaClassMemberScope(
return memberIndex().getAllFieldNames() +
getContainingDeclaration().getTypeConstructor().getSupertypes().flatMapTo(LinkedHashSet<Name>()) { supertype ->
supertype.getMemberScope().getDescriptors(kindFilter, nameFilter).map { variable ->
supertype.getMemberScope().getContributedDescriptors(kindFilter, nameFilter).map { variable ->
variable.getName()
}
}
@@ -99,29 +99,29 @@ public class LazyJavaPackageScope(
}
}
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
if (!SpecialNames.isSafeIdentifier(name)) return null
recordLookup(name, location)
return classes(name)
}
override fun getProperties(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
// We should track lookups here because this scope can be used for kotlin packages too (if it doesn't contain toplevel properties nor functions).
recordLookup(name, location)
return deserializedPackageScope().getProperties(name, NoLookupLocation.FOR_ALREADY_TRACKED)
return deserializedPackageScope().getContributedVariables(name, NoLookupLocation.FOR_ALREADY_TRACKED)
}
override fun getFunctions(name: Name, location: LookupLocation): List<FunctionDescriptor> {
override fun getContributedFunctions(name: Name, location: LookupLocation): List<FunctionDescriptor> {
// We should track lookups here because this scope can be used for kotlin packages too (if it doesn't contain toplevel properties nor functions).
recordLookup(name, location)
return deserializedPackageScope().getFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED) + super.getFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED)
return deserializedPackageScope().getContributedFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED) + super.getContributedFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED)
}
override fun addExtraDescriptors(result: MutableSet<DeclarationDescriptor>,
kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean) {
result.addAll(deserializedPackageScope().getDescriptors(kindFilter, nameFilter))
result.addAll(deserializedPackageScope().getContributedDescriptors(kindFilter, nameFilter))
}
override fun computeMemberIndex(): MemberIndex = object : MemberIndex by EMPTY_MEMBER_INDEX {
@@ -162,7 +162,7 @@ public class LazyJavaPackageScope(
override fun getPropertyNames(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean) = listOf<Name>()
// we don't use implementation from super which caches all descriptors and does not use filters
override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
return computeDescriptors(kindFilter, nameFilter, NoLookupLocation.WHEN_GET_ALL_DESCRIPTORS)
}
}
@@ -214,7 +214,7 @@ public abstract class LazyJavaScope(
return ResolvedValueParameters(descriptors, synthesizedNames)
}
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
override fun getContributedFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
recordLookup(name, location)
return functions(name)
}
@@ -298,13 +298,13 @@ public abstract class LazyJavaScope(
return propertyType
}
override fun getProperties(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
recordLookup(name, location)
return properties(name)
}
override fun getDescriptors(kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean) = allDescriptors()
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean) = allDescriptors()
protected fun computeDescriptors(
kindFilter: DescriptorKindFilter,
@@ -317,7 +317,7 @@ public abstract class LazyJavaScope(
for (name in getClassNames(kindFilter, nameFilter)) {
if (nameFilter(name)) {
// Null signifies that a class found in Java is not present in Kotlin (e.g. package class)
result.addIfNotNull(getClassifier(name, location))
result.addIfNotNull(getContributedClassifier(name, location))
}
}
}
@@ -325,7 +325,7 @@ public abstract class LazyJavaScope(
if (kindFilter.acceptsKinds(DescriptorKindFilter.FUNCTIONS_MASK) && !kindFilter.excludes.contains(NonExtensions)) {
for (name in getFunctionNames(kindFilter, nameFilter)) {
if (nameFilter(name)) {
result.addAll(getFunctions(name, location))
result.addAll(getContributedFunctions(name, location))
}
}
}
@@ -333,7 +333,7 @@ public abstract class LazyJavaScope(
if (kindFilter.acceptsKinds(DescriptorKindFilter.VARIABLES_MASK) && !kindFilter.excludes.contains(NonExtensions)) {
for (name in getPropertyNames(kindFilter, nameFilter)) {
if (nameFilter(name)) {
result.addAll(getProperties(name, location))
result.addAll(getContributedVariables(name, location))
}
}
}
@@ -63,7 +63,8 @@ public class LazyJavaStaticClassScope(
memberIndex().getAllFieldNames() + (if (jClass.isEnum) listOf(DescriptorUtils.ENUM_VALUES) else emptyList())
override fun getClassNames(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<Name> = listOf()
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
// We don't need to track lookups here because we find nested/inner classes in LazyJavaClassMemberScope
return null
}
@@ -113,7 +114,7 @@ public class LazyJavaStaticClassScope(
private fun getStaticFunctionsFromJavaSuperClasses(name: Name, descriptor: ClassDescriptor): Set<SimpleFunctionDescriptor> {
val staticScope = descriptor.getParentJavaStaticClassScope() ?: return emptySet()
return staticScope.getFunctions(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS).map { it as SimpleFunctionDescriptor }.toSet()
return staticScope.getContributedFunctions(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS).map { it as SimpleFunctionDescriptor }.toSet()
}
private fun getStaticPropertiesFromJavaSupertypes(name: Name, descriptor: ClassDescriptor): Set<PropertyDescriptor> {
@@ -125,7 +126,7 @@ public class LazyJavaStaticClassScope(
if (staticScope !is LazyJavaStaticClassScope) return getStaticPropertiesFromJavaSupertypes(name, superTypeDescriptor)
return staticScope.getProperties(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS).map { it }
return staticScope.getContributedVariables(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS).map { it }
}
return descriptor.typeConstructor.supertypes.flatMap(::getStaticProperties).toSet()
@@ -152,7 +152,7 @@ public class BinaryClassAnnotationAndConstantLoaderImpl(
private fun enumEntryValue(enumClassId: ClassId, name: Name): ConstantValue<*> {
val enumClass = resolveClass(enumClassId)
if (enumClass.getKind() == ClassKind.ENUM_CLASS) {
val classifier = enumClass.getUnsubstitutedInnerClassesScope().getClassifier(name, NoLookupLocation.FROM_JAVA_LOADER)
val classifier = enumClass.getUnsubstitutedInnerClassesScope().getContributedClassifier(name, NoLookupLocation.FROM_JAVA_LOADER)
if (classifier is ClassDescriptor) {
return factory.createEnumValue(classifier)
}
@@ -219,8 +219,8 @@ public abstract class KotlinBuiltIns {
@NotNull
public ClassDescriptor getAnnotationClassByName(@NotNull Name simpleName) {
ClassifierDescriptor classifier = annotationPackageFragment.getMemberScope().getClassifier(simpleName,
NoLookupLocation.FROM_BUILTINS);
ClassifierDescriptor classifier = annotationPackageFragment.getMemberScope().getContributedClassifier(simpleName,
NoLookupLocation.FROM_BUILTINS);
assert classifier instanceof ClassDescriptor : "Must be a class descriptor " + simpleName + ", but was " +
(classifier == null ? "null" : classifier.toString());
return (ClassDescriptor) classifier;
@@ -235,8 +235,8 @@ public abstract class KotlinBuiltIns {
@Nullable
public ClassDescriptor getBuiltInClassByNameNullable(@NotNull Name simpleName) {
ClassifierDescriptor classifier = getBuiltInsPackageFragment().getMemberScope().getClassifier(simpleName,
NoLookupLocation.FROM_BUILTINS);
ClassifierDescriptor classifier = getBuiltInsPackageFragment().getMemberScope().getContributedClassifier(simpleName,
NoLookupLocation.FROM_BUILTINS);
assert classifier == null ||
classifier instanceof ClassDescriptor : "Must be a class descriptor " + simpleName + ", but was " + classifier;
return (ClassDescriptor) classifier;
@@ -405,7 +405,7 @@ public abstract class KotlinBuiltIns {
@Nullable
public ClassDescriptor getAnnotationTargetEnumEntry(@NotNull KotlinTarget target) {
ClassifierDescriptor result = getAnnotationTargetEnum().getUnsubstitutedInnerClassesScope().getClassifier(
ClassifierDescriptor result = getAnnotationTargetEnum().getUnsubstitutedInnerClassesScope().getContributedClassifier(
Name.identifier(target.name()), NoLookupLocation.FROM_BUILTINS
);
return result instanceof ClassDescriptor ? (ClassDescriptor) result : null;
@@ -418,7 +418,7 @@ public abstract class KotlinBuiltIns {
@Nullable
public ClassDescriptor getAnnotationRetentionEnumEntry(@NotNull KotlinRetention retention) {
ClassifierDescriptor result = getAnnotationRetentionEnum().getUnsubstitutedInnerClassesScope().getClassifier(
ClassifierDescriptor result = getAnnotationRetentionEnum().getUnsubstitutedInnerClassesScope().getContributedClassifier(
Name.identifier(retention.name()), NoLookupLocation.FROM_BUILTINS
);
return result instanceof ClassDescriptor ? (ClassDescriptor) result : null;
@@ -1072,7 +1072,7 @@ public abstract class KotlinBuiltIns {
@NotNull
public FunctionDescriptor getIdentityEquals() {
return first(getBuiltInsPackageFragment().getMemberScope().getFunctions(Name.identifier("identityEquals"),
NoLookupLocation.FROM_BUILTINS));
return first(getBuiltInsPackageFragment().getMemberScope().getContributedFunctions(Name.identifier("identityEquals"),
NoLookupLocation.FROM_BUILTINS));
}
}
@@ -38,7 +38,7 @@ public class ReflectionTypes(private val module: ModuleDescriptor) {
fun find(className: String): ClassDescriptor {
val name = Name.identifier(className)
return kotlinReflectScope.getClassifier(name, NoLookupLocation.FROM_REFLECTION) as? ClassDescriptor
return kotlinReflectScope.getContributedClassifier(name, NoLookupLocation.FROM_REFLECTION) as? ClassDescriptor
?: ErrorUtils.createErrorClass(KOTLIN_REFLECT_FQ_NAME.child(name).asString())
}
@@ -111,7 +111,7 @@ public class FunctionClassDescriptor(
val result = ArrayList<KotlinType>(2)
fun add(packageFragment: PackageFragmentDescriptor, name: Name) {
val descriptor = packageFragment.getMemberScope().getClassifier(name, NoLookupLocation.FROM_BUILTINS) as? ClassDescriptor
val descriptor = packageFragment.getMemberScope().getContributedClassifier(name, NoLookupLocation.FROM_BUILTINS) as? ClassDescriptor
?: error("Class $name not found in $packageFragment")
val typeConstructor = descriptor.getTypeConstructor()
@@ -43,23 +43,23 @@ class FunctionClassScope(
override fun getContainingDeclaration() = functionClass
override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
if (!kindFilter.acceptsKinds(DescriptorKindFilter.CALLABLES.kindMask)) return listOf()
return allDescriptors()
}
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
override fun getContributedFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
return allDescriptors().filterIsInstance<FunctionDescriptor>().filter { it.getName() == name }
}
override fun getProperties(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
return allDescriptors().filterIsInstance<PropertyDescriptor>().filter { it.getName() == name }
}
private fun createFakeOverrides(invoke: FunctionDescriptor?): List<DeclarationDescriptor> {
val result = ArrayList<DeclarationDescriptor>(3)
val allSuperDescriptors = functionClass.getTypeConstructor().getSupertypes()
.flatMap { it.getMemberScope().getDescriptors() }
.flatMap { it.getMemberScope().getContributedDescriptors() }
.filterIsInstance<CallableMemberDescriptor>()
for ((name, group) in allSuperDescriptors.groupBy { it.getName() }) {
for ((isFunction, descriptors) in group.groupBy { it is FunctionDescriptor }) {
@@ -201,25 +201,25 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
@NotNull
@Override
public Collection<PropertyDescriptor> getProperties(@NotNull Name name, @NotNull LookupLocation location) {
public Collection<PropertyDescriptor> getContributedVariables(@NotNull Name name, @NotNull LookupLocation location) {
return properties.invoke(name);
}
@NotNull
@SuppressWarnings("unchecked")
private Collection<PropertyDescriptor> computeProperties(@NotNull Name name) {
return resolveFakeOverrides(name, (Collection) getSupertypeScope().getProperties(name, NoLookupLocation.FOR_NON_TRACKED_SCOPE));
return resolveFakeOverrides(name, (Collection) getSupertypeScope().getContributedVariables(name, NoLookupLocation.FOR_NON_TRACKED_SCOPE));
}
@NotNull
@Override
public Collection<FunctionDescriptor> getFunctions(@NotNull Name name, @NotNull LookupLocation location) {
public Collection<FunctionDescriptor> getContributedFunctions(@NotNull Name name, @NotNull LookupLocation location) {
return functions.invoke(name);
}
@NotNull
private Collection<FunctionDescriptor> computeFunctions(@NotNull Name name) {
return resolveFakeOverrides(name, getSupertypeScope().getFunctions(name, NoLookupLocation.FOR_NON_TRACKED_SCOPE));
return resolveFakeOverrides(name, getSupertypeScope().getContributedFunctions(name, NoLookupLocation.FOR_NON_TRACKED_SCOPE));
}
@NotNull
@@ -264,7 +264,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
@NotNull
@Override
public Collection<DeclarationDescriptor> getDescriptors(
public Collection<DeclarationDescriptor> getContributedDescriptors(
@NotNull DescriptorKindFilter kindFilter,
@NotNull Function1<? super Name, ? extends Boolean> nameFilter
) {
@@ -275,8 +275,8 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
private Collection<DeclarationDescriptor> computeAllDeclarations() {
Collection<DeclarationDescriptor> result = new HashSet<DeclarationDescriptor>();
for (Name name : enumMemberNames.invoke()) {
result.addAll(getFunctions(name, NoLookupLocation.FOR_NON_TRACKED_SCOPE));
result.addAll(getProperties(name, NoLookupLocation.FOR_NON_TRACKED_SCOPE));
result.addAll(getContributedFunctions(name, NoLookupLocation.FOR_NON_TRACKED_SCOPE));
result.addAll(getContributedVariables(name, NoLookupLocation.FOR_NON_TRACKED_SCOPE));
}
return result;
}
@@ -45,8 +45,8 @@ public class SubpackagesScope(private val moduleDescriptor: ModuleDescriptor, pr
return packageViewDescriptor
}
override fun getDescriptors(kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
if (!kindFilter.acceptsKinds(DescriptorKindFilter.PACKAGES_MASK)) return listOf()
if (fqName.isRoot() && kindFilter.excludes.contains(DescriptorKindExclude.TopLevelPackages)) return listOf()
@@ -383,7 +383,7 @@ public class DescriptorUtils {
@Nullable
public static ClassDescriptor getInnerClassByName(@NotNull ClassDescriptor classDescriptor, @NotNull String innerClassName, @NotNull LookupLocation location) {
ClassifierDescriptor classifier =
classDescriptor.getDefaultType().getMemberScope().getClassifier(Name.identifier(innerClassName), location);
classDescriptor.getDefaultType().getMemberScope().getContributedClassifier(Name.identifier(innerClassName), location);
assert classifier instanceof ClassDescriptor :
"Inner class " + innerClassName + " in " + classDescriptor + " should be instance of ClassDescriptor, but was: "
+ (classifier == null ? "null" : classifier.getClass());
@@ -551,6 +551,6 @@ public class DescriptorUtils {
@NotNull
public static Collection<DeclarationDescriptor> getAllDescriptors(@NotNull MemberScope scope) {
return scope.getDescriptors(DescriptorKindFilter.ALL, MemberScope.Companion.getALL_NAME_FILTER());
return scope.getContributedDescriptors(DescriptorKindFilter.ALL, MemberScope.Companion.getALL_NAME_FILTER());
}
}
@@ -56,7 +56,7 @@ public val DeclarationDescriptor.module: ModuleDescriptor
public fun ModuleDescriptor.resolveTopLevelClass(topLevelClassFqName: FqName, location: LookupLocation): ClassDescriptor? {
assert(!topLevelClassFqName.isRoot())
return getPackage(topLevelClassFqName.parent()).memberScope.getClassifier(topLevelClassFqName.shortName(), location) as? ClassDescriptor
return getPackage(topLevelClassFqName.parent()).memberScope.getContributedClassifier(topLevelClassFqName.shortName(), location) as? ClassDescriptor
}
public val ClassDescriptor.classId: ClassId
@@ -33,29 +33,29 @@ public abstract class AbstractScopeAdapter : MemberScope {
else
workerScope
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
return workerScope.getFunctions(name, location)
override fun getContributedFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
return workerScope.getContributedFunctions(name, location)
}
override fun getPackage(name: Name): PackageViewDescriptor? {
return workerScope.getPackage(name)
}
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
return workerScope.getClassifier(name, location)
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
return workerScope.getContributedClassifier(name, location)
}
override fun getProperties(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
return workerScope.getProperties(name, location)
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
return workerScope.getContributedVariables(name, location)
}
override fun getContainingDeclaration(): DeclarationDescriptor {
return workerScope.getContainingDeclaration()
}
override fun getDescriptors(kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
return workerScope.getDescriptors(kindFilter, nameFilter)
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
return workerScope.getContributedDescriptors(kindFilter, nameFilter)
}
override fun printScopeStructure(p: Printer) {
@@ -30,22 +30,22 @@ public open class ChainedScope(
) : MemberScope {
private val scopeChain = scopes.clone()
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor?
= getFirstMatch(scopeChain) { it.getClassifier(name, location) }
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor?
= getFirstMatch(scopeChain) { it.getContributedClassifier(name, location) }
override fun getPackage(name: Name): PackageViewDescriptor?
= getFirstMatch(scopeChain) { it.getPackage(name) }
override fun getProperties(name: Name, location: LookupLocation): Collection<PropertyDescriptor>
= getFromAllScopes(scopeChain) { it.getProperties(name, location) }
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor>
= getFromAllScopes(scopeChain) { it.getContributedVariables(name, location) }
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor>
= getFromAllScopes(scopeChain) { it.getFunctions(name, location) }
override fun getContributedFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor>
= getFromAllScopes(scopeChain) { it.getContributedFunctions(name, location) }
override fun getContainingDeclaration(): DeclarationDescriptor = containingDeclaration!!
override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean)
= getFromAllScopes(scopeChain) { it.getDescriptors(kindFilter, nameFilter) }
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean)
= getFromAllScopes(scopeChain) { it.getContributedDescriptors(kindFilter, nameFilter) }
override fun toString() = debugName
@@ -27,11 +27,11 @@ public class InnerClassesScopeWrapper(val workerScope: MemberScope) : MemberScop
return workerScope.getContainingDeclaration()
}
override fun getClassifier(name: Name, location: LookupLocation) = workerScope.getClassifier(name, location) as? ClassDescriptor
override fun getContributedClassifier(name: Name, location: LookupLocation) = workerScope.getContributedClassifier(name, location) as? ClassDescriptor
override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): List<ClassDescriptor> {
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): List<ClassDescriptor> {
val restrictedFilter = kindFilter.restrictedToKindsOrNull(DescriptorKindFilter.CLASSIFIERS_MASK) ?: return listOf()
return workerScope.getDescriptors(restrictedFilter, nameFilter).filterIsInstance<ClassDescriptor>()
return workerScope.getContributedDescriptors(restrictedFilter, nameFilter).filterIsInstance<ClassDescriptor>()
}
override fun printScopeStructure(p: Printer) {
@@ -25,14 +25,14 @@ import java.lang.reflect.Modifier
public interface MemberScope {
public fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor?
public fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor?
@Deprecated("Should be removed soon")
public fun getPackage(name: Name): PackageViewDescriptor?
public fun getProperties(name: Name, location: LookupLocation): Collection<PropertyDescriptor>
public fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor>
public fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor>
public fun getContributedFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor>
public fun getContainingDeclaration(): DeclarationDescriptor
@@ -40,7 +40,7 @@ public interface MemberScope {
* All visible descriptors from current scope possibly filtered by the given name and kind filters
* (that means that the implementation is not obliged to use the filters but may do so when it gives any performance advantage).
*/
public fun getDescriptors(
public fun getContributedDescriptors(
kindFilter: DescriptorKindFilter = DescriptorKindFilter.ALL,
nameFilter: (Name) -> Boolean = ALL_NAME_FILTER
): Collection<DeclarationDescriptor>
@@ -75,7 +75,7 @@ public fun MemberScope.getDescriptorsFiltered(
nameFilter: (Name) -> Boolean = { true }
): Collection<DeclarationDescriptor> {
if (kindFilter.kindMask == 0) return listOf()
return getDescriptors(kindFilter, nameFilter).filter { kindFilter.accepts(it) && nameFilter(it.getName()) }
return getContributedDescriptors(kindFilter, nameFilter).filter { kindFilter.accepts(it) && nameFilter(it.getName()) }
}
public class DescriptorKindFilter(
@@ -22,16 +22,16 @@ import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.utils.Printer
abstract class MemberScopeImpl : MemberScope {
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? = null
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? = null
override fun getProperties(name: Name, location: LookupLocation): Collection<PropertyDescriptor> = emptyList()
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor> = emptyList()
override fun getPackage(name: Name): PackageViewDescriptor? = null
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> = emptyList()
override fun getContributedFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> = emptyList()
override fun getDescriptors(kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> = emptyList()
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> = emptyList()
// This method should not be implemented here by default: every scope class has its unique structure pattern
abstract override fun printScopeStructure(p: Printer)
@@ -30,7 +30,7 @@ import java.util.*
public class StaticScopeForKotlinClass(
private val containingClass: ClassDescriptor
) : MemberScopeImpl() {
override fun getClassifier(name: Name, location: LookupLocation) = null // TODO
override fun getContributedClassifier(name: Name, location: LookupLocation) = null // TODO
private val functions: List<FunctionDescriptor> by lazy {
if (containingClass.getKind() != ClassKind.ENUM_CLASS) {
@@ -50,12 +50,12 @@ public class StaticScopeForKotlinClass(
}
}
override fun getDescriptors(kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean) = functions + properties
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean) = functions + properties
override fun getProperties(name: Name, location: LookupLocation) = properties.filterTo(ArrayList(1)) { it.name == name }
override fun getContributedVariables(name: Name, location: LookupLocation) = properties.filterTo(ArrayList(1)) { it.name == name }
override fun getFunctions(name: Name, location: LookupLocation) = functions.filterTo(ArrayList<FunctionDescriptor>(2)) { it.getName() == name }
override fun getContributedFunctions(name: Name, location: LookupLocation) = functions.filterTo(ArrayList<FunctionDescriptor>(2)) { it.getName() == name }
override fun getContainingDeclaration() = containingClass
@@ -28,7 +28,7 @@ public class SubstitutingScope(private val workerScope: MemberScope, private val
private var substitutedDescriptors: MutableMap<DeclarationDescriptor, DeclarationDescriptor?>? = null
private val _allDescriptors by lazy { substitute(workerScope.getDescriptors()) }
private val _allDescriptors by lazy { substitute(workerScope.getContributedDescriptors()) }
private fun <D : DeclarationDescriptor> substitute(descriptor: D?): D? {
if (descriptor == null) return null
@@ -59,18 +59,18 @@ public class SubstitutingScope(private val workerScope: MemberScope, private val
return result
}
override fun getProperties(name: Name, location: LookupLocation) = substitute(workerScope.getProperties(name, location))
override fun getContributedVariables(name: Name, location: LookupLocation) = substitute(workerScope.getContributedVariables(name, location))
override fun getClassifier(name: Name, location: LookupLocation) = substitute(workerScope.getClassifier(name, location))
override fun getContributedClassifier(name: Name, location: LookupLocation) = substitute(workerScope.getContributedClassifier(name, location))
override fun getFunctions(name: Name, location: LookupLocation) = substitute(workerScope.getFunctions(name, location))
override fun getContributedFunctions(name: Name, location: LookupLocation) = substitute(workerScope.getContributedFunctions(name, location))
override fun getPackage(name: Name) = workerScope.getPackage(name)
override fun getContainingDeclaration() = workerScope.getContainingDeclaration()
override fun getDescriptors(kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean) = _allDescriptors
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean) = _allDescriptors
override fun printScopeStructure(p: Printer) {
p.println(javaClass.getSimpleName(), " {")
@@ -169,13 +169,13 @@ public class ErrorUtils {
@Nullable
@Override
public ClassifierDescriptor getClassifier(@NotNull Name name, @NotNull LookupLocation location) {
public ClassifierDescriptor getContributedClassifier(@NotNull Name name, @NotNull LookupLocation location) {
return createErrorClass(name.asString());
}
@NotNull
@Override
public Set<PropertyDescriptor> getProperties(@NotNull Name name, @NotNull LookupLocation location) {
public Set<PropertyDescriptor> getContributedVariables(@NotNull Name name, @NotNull LookupLocation location) {
return ERROR_PROPERTY_GROUP;
}
@@ -186,7 +186,7 @@ public class ErrorUtils {
@NotNull
@Override
public Set<FunctionDescriptor> getFunctions(@NotNull Name name, @NotNull LookupLocation location) {
public Set<FunctionDescriptor> getContributedFunctions(@NotNull Name name, @NotNull LookupLocation location) {
return Collections.<FunctionDescriptor>singleton(createErrorFunction(this));
}
@@ -198,7 +198,7 @@ public class ErrorUtils {
@NotNull
@Override
public Collection<DeclarationDescriptor> getDescriptors(
public Collection<DeclarationDescriptor> getContributedDescriptors(
@NotNull DescriptorKindFilter kindFilter, @NotNull Function1<? super Name, ? extends Boolean> nameFilter
) {
return Collections.emptyList();
@@ -224,7 +224,7 @@ public class ErrorUtils {
@Nullable
@Override
public ClassifierDescriptor getClassifier(@NotNull Name name, @NotNull LookupLocation location) {
public ClassifierDescriptor getContributedClassifier(@NotNull Name name, @NotNull LookupLocation location) {
throw new IllegalStateException();
}
@@ -236,13 +236,13 @@ public class ErrorUtils {
@NotNull
@Override
public Collection<PropertyDescriptor> getProperties(@NotNull Name name, @NotNull LookupLocation location) {
public Collection<PropertyDescriptor> getContributedVariables(@NotNull Name name, @NotNull LookupLocation location) {
throw new IllegalStateException();
}
@NotNull
@Override
public Collection<FunctionDescriptor> getFunctions(@NotNull Name name, @NotNull LookupLocation location) {
public Collection<FunctionDescriptor> getContributedFunctions(@NotNull Name name, @NotNull LookupLocation location) {
throw new IllegalStateException();
}
@@ -254,7 +254,7 @@ public class ErrorUtils {
@NotNull
@Override
public Collection<DeclarationDescriptor> getDescriptors(
public Collection<DeclarationDescriptor> getContributedDescriptors(
@NotNull DescriptorKindFilter kindFilter, @NotNull Function1<? super Name, ? extends Boolean> nameFilter
) {
throw new IllegalStateException();
@@ -135,7 +135,7 @@ public class AnnotationDeserializer(private val module: ModuleDescriptor) {
private fun resolveEnumValue(enumClassId: ClassId, enumEntryName: Name): ConstantValue<*> {
val enumClass = resolveClass(enumClassId)
if (enumClass.getKind() == ClassKind.ENUM_CLASS) {
val enumEntry = enumClass.getUnsubstitutedInnerClassesScope().getClassifier(enumEntryName, NoLookupLocation.FROM_DESERIALIZATION)
val enumEntry = enumClass.getUnsubstitutedInnerClassesScope().getContributedClassifier(enumEntryName, NoLookupLocation.FROM_DESERIALIZATION)
if (enumEntry is ClassDescriptor) {
return factory.createEnumValue(enumEntry)
}
@@ -130,7 +130,7 @@ public class DeserializedClassDescriptor(
if (!classProto.hasCompanionObjectName()) return null
val companionObjectName = c.nameResolver.getName(classProto.getCompanionObjectName())
return memberScope.getClassifier(companionObjectName, NoLookupLocation.FROM_DESERIALIZATION) as? ClassDescriptor
return memberScope.getContributedClassifier(companionObjectName, NoLookupLocation.FROM_DESERIALIZATION) as? ClassDescriptor
}
override fun getCompanionObjectDescriptor(): ClassDescriptor? = companionObjectDescriptor()
@@ -192,13 +192,13 @@ public class DeserializedClassDescriptor(
computeDescriptors(DescriptorKindFilter.ALL, MemberScope.ALL_NAME_FILTER, NoLookupLocation.WHEN_GET_ALL_DESCRIPTORS)
}
override fun getDescriptors(kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> = allDescriptors()
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> = allDescriptors()
override fun computeNonDeclaredFunctions(name: Name, functions: MutableCollection<FunctionDescriptor>) {
val fromSupertypes = ArrayList<FunctionDescriptor>()
for (supertype in classDescriptor.getTypeConstructor().supertypes) {
fromSupertypes.addAll(supertype.memberScope.getFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED))
fromSupertypes.addAll(supertype.memberScope.getContributedFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED))
}
generateFakeOverrides(name, fromSupertypes, functions)
}
@@ -206,7 +206,7 @@ public class DeserializedClassDescriptor(
override fun computeNonDeclaredProperties(name: Name, descriptors: MutableCollection<PropertyDescriptor>) {
val fromSupertypes = ArrayList<PropertyDescriptor>()
for (supertype in classDescriptor.getTypeConstructor().supertypes) {
fromSupertypes.addAll(supertype.memberScope.getProperties(name, NoLookupLocation.FOR_ALREADY_TRACKED))
fromSupertypes.addAll(supertype.memberScope.getContributedVariables(name, NoLookupLocation.FOR_ALREADY_TRACKED))
}
generateFakeOverrides(name, fromSupertypes, descriptors)
}
@@ -229,12 +229,12 @@ public class DeserializedClassDescriptor(
override fun addNonDeclaredDescriptors(result: MutableCollection<DeclarationDescriptor>, location: LookupLocation) {
for (supertype in classDescriptor.getTypeConstructor().supertypes) {
for (descriptor in supertype.memberScope.getDescriptors()) {
for (descriptor in supertype.memberScope.getContributedDescriptors()) {
if (descriptor is FunctionDescriptor) {
result.addAll(getFunctions(descriptor.name, location))
result.addAll(getContributedFunctions(descriptor.name, location))
}
else if (descriptor is PropertyDescriptor) {
result.addAll(getProperties(descriptor.name, location))
result.addAll(getContributedVariables(descriptor.name, location))
}
// Nothing else is inherited
}
@@ -312,7 +312,7 @@ public class DeserializedClassDescriptor(
val result = HashSet<Name>()
for (supertype in getTypeConstructor().getSupertypes()) {
for (descriptor in supertype.getMemberScope().getDescriptors()) {
for (descriptor in supertype.getMemberScope().getContributedDescriptors()) {
if (descriptor is SimpleFunctionDescriptor || descriptor is PropertyDescriptor) {
result.add(descriptor.getName())
}
@@ -82,7 +82,7 @@ public abstract class DeserializedMemberScope protected constructor(
protected open fun computeNonDeclaredFunctions(name: Name, functions: MutableCollection<FunctionDescriptor>) {
}
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
override fun getContributedFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
recordLookup(name, location)
return functions(name)
}
@@ -102,12 +102,12 @@ public abstract class DeserializedMemberScope protected constructor(
protected open fun computeNonDeclaredProperties(name: Name, descriptors: MutableCollection<PropertyDescriptor>) {
}
override fun getProperties(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
recordLookup(name, location)
return properties.invoke(name)
}
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
recordLookup(name, location)
return getClassDescriptor(name)
}
@@ -150,12 +150,12 @@ public abstract class DeserializedMemberScope protected constructor(
) {
if (kindFilter.acceptsKinds(DescriptorKindFilter.VARIABLES_MASK)) {
val keys = propertyProtos().keySet().filter { nameFilter(it.name) }
addMembers(result, keys) { getProperties(it, location) }
addMembers(result, keys) { getContributedVariables(it, location) }
}
if (kindFilter.acceptsKinds(DescriptorKindFilter.FUNCTIONS_MASK)) {
val keys = functionProtos().keySet().filter { nameFilter(it.name) }
addMembers(result, keys) { getFunctions(it, location) }
addMembers(result, keys) { getContributedFunctions(it, location) }
}
}
@@ -46,7 +46,7 @@ public open class DeserializedPackageMemberScope(
internal val classNames by c.storageManager.createLazyValue { classNames().toSet() }
override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean)
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean)
= computeDescriptors(kindFilter, nameFilter, NoLookupLocation.WHEN_GET_ALL_DESCRIPTORS)
override fun getClassDescriptor(name: Name): ClassDescriptor? =
@@ -24,10 +24,10 @@ import org.jetbrains.kotlin.name.ClassId
public fun ModuleDescriptor.findClassAcrossModuleDependencies(classId: ClassId): ClassDescriptor? {
val packageViewDescriptor = getPackage(classId.packageFqName)
val segments = classId.relativeClassName.pathSegments()
val topLevelClass = packageViewDescriptor.memberScope.getClassifier(segments.first(), NoLookupLocation.FROM_DESERIALIZATION) as? ClassDescriptor ?: return null
val topLevelClass = packageViewDescriptor.memberScope.getContributedClassifier(segments.first(), NoLookupLocation.FROM_DESERIALIZATION) as? ClassDescriptor ?: return null
var result = topLevelClass
for (name in segments.subList(1, segments.size())) {
result = result.unsubstitutedInnerClassesScope.getClassifier(name, NoLookupLocation.FROM_DESERIALIZATION) as? ClassDescriptor ?: return null
result = result.unsubstitutedInnerClassesScope.getContributedClassifier(name, NoLookupLocation.FROM_DESERIALIZATION) as? ClassDescriptor ?: return null
}
return result
}
@@ -75,12 +75,12 @@ internal class KClassImpl<T : Any>(override val jClass: Class<T>) : KDeclaration
@Suppress("UNCHECKED_CAST")
override fun getProperties(name: Name): Collection<PropertyDescriptor> =
(memberScope.getProperties(name, NoLookupLocation.FROM_REFLECTION) +
staticScope.getProperties(name, NoLookupLocation.FROM_REFLECTION)) as Collection<PropertyDescriptor>
(memberScope.getContributedVariables(name, NoLookupLocation.FROM_REFLECTION) +
staticScope.getContributedVariables(name, NoLookupLocation.FROM_REFLECTION)) as Collection<PropertyDescriptor>
override fun getFunctions(name: Name): Collection<FunctionDescriptor> =
memberScope.getFunctions(name, NoLookupLocation.FROM_REFLECTION) +
staticScope.getFunctions(name, NoLookupLocation.FROM_REFLECTION)
memberScope.getContributedFunctions(name, NoLookupLocation.FROM_REFLECTION) +
staticScope.getContributedFunctions(name, NoLookupLocation.FROM_REFLECTION)
override val simpleName: String? get() {
if (jClass.isAnonymousClass()) return null
@@ -120,7 +120,7 @@ internal class KClassImpl<T : Any>(override val jClass: Class<T>) : KDeclaration
}
override val nestedClasses: Collection<KClass<*>>
get() = descriptor.unsubstitutedInnerClassesScope.getDescriptors().map { nestedClass ->
get() = descriptor.unsubstitutedInnerClassesScope.getContributedDescriptors().map { nestedClass ->
val source = (nestedClass as DeclarationDescriptorWithSource).source
when (source) {
is KotlinJvmBinarySourceElement ->
@@ -78,7 +78,7 @@ internal abstract class KDeclarationContainerImpl : ClassBasedDeclarationContain
}
}
return scope.getDescriptors().asSequence()
return scope.getContributedDescriptors().asSequence()
.filter { descriptor ->
descriptor !is MemberDescriptor || descriptor.getVisibility() != Visibilities.INVISIBLE_FAKE
}
@@ -45,10 +45,10 @@ internal class KPackageImpl(override val jClass: Class<*>, val moduleName: Strin
@Suppress("UNCHECKED_CAST")
override fun getProperties(name: Name): Collection<PropertyDescriptor> =
scope.getProperties(name, NoLookupLocation.FROM_REFLECTION) as Collection<PropertyDescriptor>
scope.getContributedVariables(name, NoLookupLocation.FROM_REFLECTION) as Collection<PropertyDescriptor>
override fun getFunctions(name: Name): Collection<FunctionDescriptor> =
scope.getFunctions(name, NoLookupLocation.FROM_REFLECTION)
scope.getContributedFunctions(name, NoLookupLocation.FROM_REFLECTION)
override fun equals(other: Any?): Boolean =
other is KPackageImpl && jClass == other.jClass
@@ -52,12 +52,12 @@ fun generate(): String {
val builtIns = TargetPlatform.Default.builtIns
@Suppress("UNCHECKED_CAST")
val allPrimitiveTypes = builtIns.getBuiltInsPackageScope().getDescriptors()
val allPrimitiveTypes = builtIns.getBuiltInsPackageScope().getContributedDescriptors()
.filter { it is ClassDescriptor && KotlinBuiltIns.isPrimitiveType(it.getDefaultType()) } as List<ClassDescriptor>
for (descriptor in allPrimitiveTypes + builtIns.getString()) {
@Suppress("UNCHECKED_CAST")
val functions = descriptor.getMemberScope(listOf()).getDescriptors()
val functions = descriptor.getMemberScope(listOf()).getContributedDescriptors()
.filter { it is CallableDescriptor && !EXCLUDED_FUNCTIONS.contains(it.getName().asString()) } as List<CallableDescriptor>
for (function in functions) {
@@ -42,17 +42,17 @@ public fun LexicalScope.getAllAccessibleVariables(name: Name): Collection<Variab
}
public fun LexicalScope.getAllAccessibleFunctions(name: Name): Collection<FunctionDescriptor> {
return getImplicitReceiversWithInstance().flatMap { it.type.memberScope.getFunctions(name, NoLookupLocation.FROM_IDE) } +
collectFunctions(name, NoLookupLocation.FROM_IDE)
return getImplicitReceiversWithInstance().flatMap { it.type.memberScope.getContributedFunctions(name, NoLookupLocation.FROM_IDE) } +
collectFunctions(name, NoLookupLocation.FROM_IDE)
}
public fun LexicalScope.getVariablesFromImplicitReceivers(name: Name): Collection<VariableDescriptor> = getImplicitReceiversWithInstance().flatMap {
it.type.memberScope.getProperties(name, NoLookupLocation.FROM_IDE)
it.type.memberScope.getContributedVariables(name, NoLookupLocation.FROM_IDE)
}
public fun LexicalScope.getVariableFromImplicitReceivers(name: Name): VariableDescriptor? {
getImplicitReceiversWithInstance().forEach {
it.type.memberScope.getProperties(name, NoLookupLocation.FROM_IDE).singleOrNull()?.let { return it }
it.type.memberScope.getContributedVariables(name, NoLookupLocation.FROM_IDE).singleOrNull()?.let { return it }
}
return null
}
@@ -61,7 +61,7 @@ public fun descriptorsEqualWithSubstitution(descriptor1: DeclarationDescriptor?,
public fun ClassDescriptor.findCallableMemberBySignature(signature: CallableMemberDescriptor): CallableMemberDescriptor? {
val descriptorKind = if (signature is FunctionDescriptor) DescriptorKindFilter.FUNCTIONS else DescriptorKindFilter.VARIABLES
return getDefaultType().getMemberScope()
.getDescriptors(descriptorKind)
.getContributedDescriptors(descriptorKind)
.filterIsInstance<CallableMemberDescriptor>()
.firstOrNull {
it.getContainingDeclaration() == this
@@ -239,14 +239,14 @@ public class IDELightClassGenerationSupport(private val project: Project) : Ligh
for (declaration in file.declarations) {
if (declaration is KtFunction) {
val name = declaration.nameAsSafeName
val functions = packageDescriptor.memberScope.getFunctions(name, NoLookupLocation.FROM_IDE)
val functions = packageDescriptor.memberScope.getContributedFunctions(name, NoLookupLocation.FROM_IDE)
for (descriptor in functions) {
ForceResolveUtil.forceResolveAllContents(descriptor)
}
}
else if (declaration is KtProperty) {
val name = declaration.nameAsSafeName
val properties = packageDescriptor.memberScope.getProperties(name, NoLookupLocation.FROM_IDE)
val properties = packageDescriptor.memberScope.getContributedVariables(name, NoLookupLocation.FROM_IDE)
for (descriptor in properties) {
ForceResolveUtil.forceResolveAllContents(descriptor)
}
@@ -67,7 +67,7 @@ fun PsiMember.getJavaMemberDescriptor(): DeclarationDescriptor? {
}
public fun JavaDescriptorResolver.resolveMethod(method: JavaMethod): FunctionDescriptor? {
return getContainingScope(method)?.getFunctions(method.name, NoLookupLocation.FROM_IDE)?.findByJavaElement(method)
return getContainingScope(method)?.getContributedFunctions(method.name, NoLookupLocation.FROM_IDE)?.findByJavaElement(method)
}
public fun JavaDescriptorResolver.resolveConstructor(constructor: JavaConstructor): ConstructorDescriptor? {
@@ -75,7 +75,7 @@ public fun JavaDescriptorResolver.resolveConstructor(constructor: JavaConstructo
}
public fun JavaDescriptorResolver.resolveField(field: JavaField): PropertyDescriptor? {
return getContainingScope(field)?.getProperties(field.name, NoLookupLocation.FROM_IDE)?.findByJavaElement(field) as? PropertyDescriptor
return getContainingScope(field)?.getContributedVariables(field.name, NoLookupLocation.FROM_IDE)?.findByJavaElement(field) as? PropertyDescriptor
}
private fun JavaDescriptorResolver.getContainingScope(member: JavaMember): MemberScope? {
@@ -199,7 +199,7 @@ public fun buildDecompiledText(
}
}
val allDescriptors = descriptor.secondaryConstructors + descriptor.defaultType.memberScope.getDescriptors()
val allDescriptors = descriptor.secondaryConstructors + descriptor.defaultType.memberScope.getContributedDescriptors()
val (enumEntries, members) = allDescriptors.partition(::isEnumEntry)
for ((index, enumEntry) in enumEntries.withIndex()) {
@@ -77,7 +77,7 @@ public class DeserializerForClassfileDecompiler(
val membersScope = DeserializedPackageMemberScope(
createDummyPackageFragment(packageFqName), packageProto, nameResolver, deserializationComponents
) { emptyList() }
return membersScope.getDescriptors()
return membersScope.getContributedDescriptors()
}
companion object {
@@ -75,7 +75,7 @@ public class KotlinJavaScriptDeserializerForDecompiler(
val membersScope = DeserializedPackageMemberScope(
createDummyPackageFragment(packageFqName), packageProto, nameResolver, deserializationComponents
) { emptyList() }
return membersScope.getDescriptors()
return membersScope.getContributedDescriptors()
}
companion object {
@@ -49,7 +49,7 @@ private class ScopeWithMissingDependencies(val fqName: FqName, val containing: D
p.println("Special scope for decompiler, containing class with any name")
}
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
return MissingDependencyErrorClassDescriptor(getContainingDeclaration(), fqName.child(name))
}
}
@@ -108,7 +108,7 @@ public class BuiltInsReferenceResolver(val project: Project, val startupManager:
containingDeclaration.getConstructors()
}
else {
memberScope.getDescriptors()
memberScope.getContributedDescriptors()
}
return descriptors.firstOrNull { renderedOriginal == DescriptorRenderer.FQ_NAMES_IN_TYPES.render(it) }
@@ -45,7 +45,7 @@ public class KotlinInheritedMembersNodeProvider: InheritedMembersNodeProvider<Tr
val children = ArrayList<TreeElement>()
val defaultType = descriptor.getDefaultType()
for (memberDescriptor in defaultType.getMemberScope().getDescriptors()) {
for (memberDescriptor in defaultType.getMemberScope().getContributedDescriptors()) {
if (memberDescriptor !is CallableMemberDescriptor) continue
when (memberDescriptor.getKind()) {
@@ -54,7 +54,7 @@ object PackageDirectiveCompletion {
val packageMemberScope = resolutionFacade.moduleDescriptor.getPackage(file.packageFqName.parent()).memberScope
val variants = packageMemberScope.getDescriptors(DescriptorKindFilter.PACKAGES, prefixMatcher.asNameFilter())
val variants = packageMemberScope.getContributedDescriptors(DescriptorKindFilter.PACKAGES, prefixMatcher.asNameFilter())
val lookupElementFactory = BasicLookupElementFactory(resolutionFacade.project, InsertHandlerProvider(callType = CallType.PACKAGE_DIRECTIVE, expectedInfosCalculator = { emptyList() }))
for (variant in variants) {
val lookupElement = lookupElementFactory.createLookupElement(variant)
@@ -90,16 +90,16 @@ class StaticMembers(
}
}
classDescriptor.getStaticScope().getDescriptors().forEach(::processMember)
classDescriptor.getStaticScope().getContributedDescriptors().forEach(::processMember)
val companionObject = classDescriptor.getCompanionObjectDescriptor()
if (companionObject != null) {
companionObject.getDefaultType().getMemberScope().getDescriptors()
companionObject.getDefaultType().getMemberScope().getContributedDescriptors()
.filter { !it.isExtension }
.forEach(::processMember)
}
var members = classDescriptor.getDefaultType().getMemberScope().getDescriptors()
var members = classDescriptor.getDefaultType().getMemberScope().getContributedDescriptors()
if (classDescriptor.getKind() != ClassKind.ENUM_CLASS) {
members = members.filter { DescriptorUtils.isNonCompanionObject(it) }
}
@@ -278,7 +278,7 @@ class TypeInstantiationItems(
is ClassDescriptor -> container.getStaticScope()
else -> return
}
val samConstructor = scope.getFunctions(`class`.name, NoLookupLocation.FROM_IDE)
val samConstructor = scope.getContributedFunctions(`class`.name, NoLookupLocation.FROM_IDE)
.filterIsInstance<SamConstructorDescriptor>()
.singleOrNull() ?: return
lookupElementFactory.createLookupElementsInSmartCompletion(samConstructor, bindingContext, useReceiverTypes = false)
@@ -53,7 +53,7 @@ class TypesWithContainsDetector(
private fun hasContainsNoCache(type: FuzzyType): Boolean {
return type.nullability() != TypeNullability.NULLABLE &&
type.type.memberScope.getFunctions(containsName, NoLookupLocation.FROM_IDE).any { isGoodContainsFunction(it, type.freeParameters) }
type.type.memberScope.getContributedFunctions(containsName, NoLookupLocation.FROM_IDE).any { isGoodContainsFunction(it, type.freeParameters) }
|| typesWithExtensionContains.any { type.checkIsSubtypeOf(it) != null }
}
@@ -79,7 +79,7 @@ public class IterableTypesDetection(
}
private fun canBeIterable(type: FuzzyType): Boolean {
return type.type.memberScope.getFunctions(iteratorName, NoLookupLocation.FROM_IDE).isNotEmpty() ||
return type.type.memberScope.getContributedFunctions(iteratorName, NoLookupLocation.FROM_IDE).isNotEmpty() ||
typesWithExtensionIterator.any { type.checkIsSubtypeOf(it) != null }
}
}
@@ -26,7 +26,7 @@ import java.util.*
public class OverrideMembersHandler : OverrideImplementMembersHandler() {
override fun collectMembersToGenerate(descriptor: ClassDescriptor, project: Project): Collection<OverrideMemberChooserObject> {
val result = ArrayList<OverrideMemberChooserObject>()
for (member in descriptor.unsubstitutedMemberScope.getDescriptors()) {
for (member in descriptor.unsubstitutedMemberScope.getContributedDescriptors()) {
if (member is CallableMemberDescriptor
&& (member.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE || member.kind == CallableMemberDescriptor.Kind.DELEGATION)) {
val overridden = member.overriddenDescriptors
@@ -56,7 +56,7 @@ private tailrec fun ClassDescriptor.findDeclaredFunction (
filter: (FunctionDescriptor) -> Boolean
): FunctionDescriptor? {
unsubstitutedMemberScope
.getFunctions(Name.identifier(name), NoLookupLocation.FROM_IDE)
.getContributedFunctions(Name.identifier(name), NoLookupLocation.FROM_IDE)
.firstOrNull { it.containingDeclaration == this && it.kind == CallableMemberDescriptor.Kind.DECLARATION && filter(it) }
?.let { return it }
@@ -174,7 +174,7 @@ public class RedundantSamConstructorInspection : AbstractKotlinInspection() {
val containingClass = originalFunctionDescriptor.containingDeclaration as? ClassDescriptor ?: return emptyList()
// SAM adapters for static functions
for (staticFunWithSameName in containingClass.staticScope.getFunctions(functionResolvedCall.resultingDescriptor.name, NoLookupLocation.FROM_IDE)) {
for (staticFunWithSameName in containingClass.staticScope.getContributedFunctions(functionResolvedCall.resultingDescriptor.name, NoLookupLocation.FROM_IDE)) {
if (staticFunWithSameName is SamAdapterDescriptor<*>) {
if (isSamAdapterSuitableForCall(staticFunWithSameName, originalFunctionDescriptor, samConstructorCallArguments.size())) {
return samConstructorCallArguments.check { canBeReplaced(functionCall, it) } ?: emptyList()
@@ -179,7 +179,7 @@ class ChangeMemberFunctionSignatureFix private constructor(
val name = functionDescriptor.name
return containingClass.defaultType.supertypes()
.flatMap { supertype -> supertype.memberScope.getFunctions(name, NoLookupLocation.FROM_IDE) }
.flatMap { supertype -> supertype.memberScope.getContributedFunctions(name, NoLookupLocation.FROM_IDE) }
.filter { it.kind.isReal && it.modality.isOverridable }
}
}
@@ -126,7 +126,7 @@ object MissingIteratorExclExclFixFactory : KotlinSingleIntentionActionFactory()
if (descriptor !is ClassDescriptor) return false
val memberScope = descriptor.unsubstitutedMemberScope
val functions = memberScope.getFunctions(OperatorNameConventions.ITERATOR, NoLookupLocation.FROM_IDE)
val functions = memberScope.getContributedFunctions(OperatorNameConventions.ITERATOR, NoLookupLocation.FROM_IDE)
return functions.any { it.isOperator() && OperatorChecks.canBeOperator(it) }
}
@@ -237,7 +237,7 @@ public class ImportInsertHelperImpl(private val project: Project) : ImportInsert
val topLevelScope = resolutionFacade.getFileResolutionScope(file)
val conflictCandidates: List<ClassifierDescriptor> = classNamesToImport
.flatMap {
importedScopes.map { scope -> scope.getClassifier(it, NoLookupLocation.FROM_IDE) }.filterNotNull()
importedScopes.map { scope -> scope.getContributedClassifier(it, NoLookupLocation.FROM_IDE) }.filterNotNull()
}
.filter { importedClass ->
isVisible(importedClass)
@@ -272,7 +272,7 @@ public class ImportInsertHelperImpl(private val project: Project) : ImportInsert
}
val parentScope = getMemberScope(fqName.parent(), moduleDescriptor) ?: return null
val classifier = parentScope.getClassifier(fqName.shortName(), NoLookupLocation.FROM_IDE)
val classifier = parentScope.getContributedClassifier(fqName.shortName(), NoLookupLocation.FROM_IDE)
val classDescriptor = classifier as? ClassDescriptor ?: return null
return classDescriptor.getDefaultType().getMemberScope()
}
@@ -79,7 +79,7 @@ public abstract class TextConsistencyBaseTest : KotlinLightCodeInsightFixtureTes
module.resolveTopLevelClass(classId.asSingleFqName(), NoLookupLocation.FROM_TEST)
override fun resolveDeclarationsInFacade(facadeFqName: FqName): Collection<DeclarationDescriptor> =
module.getPackage(facadeFqName.parent()).memberScope.getDescriptors().filter {
module.getPackage(facadeFqName.parent()).memberScope.getContributedDescriptors().filter {
it is CallableMemberDescriptor &&
it.module != module.builtIns.builtInsModule &&
isFromFacade(it, facadeFqName)
@@ -43,7 +43,7 @@ public class KDocFinderTest() : LightPlatformCodeInsightFixtureTestCase() {
myFixture.configureByFile(getTestName(false) + ".kt")
val declaration = (myFixture.getFile() as KtFile).getDeclarations().single { it.getName() == "Bar" }
val descriptor = declaration.resolveToDescriptor() as ClassDescriptor
val overriddenFunctionDescriptor = descriptor.defaultType.memberScope.getFunctions(Name.identifier("xyzzy"), NoLookupLocation.FROM_TEST).single()
val overriddenFunctionDescriptor = descriptor.defaultType.memberScope.getContributedFunctions(Name.identifier("xyzzy"), NoLookupLocation.FROM_TEST).single()
val doc = KDocFinder.findKDoc(overriddenFunctionDescriptor)
Assert.assertEquals("Doc for method xyzzy", doc!!.getContent())
}
@@ -52,7 +52,7 @@ public class KDocFinderTest() : LightPlatformCodeInsightFixtureTestCase() {
myFixture.configureByFile(getTestName(false) + ".kt")
val declaration = (myFixture.getFile() as KtFile).getDeclarations().single { it.getName() == "Bar" }
val descriptor = declaration.resolveToDescriptor() as ClassDescriptor
val overriddenFunctionDescriptor = descriptor.defaultType.memberScope.getFunctions(Name.identifier("xyzzy"), NoLookupLocation.FROM_TEST).single()
val overriddenFunctionDescriptor = descriptor.defaultType.memberScope.getContributedFunctions(Name.identifier("xyzzy"), NoLookupLocation.FROM_TEST).single()
val doc = KDocFinder.findKDoc(overriddenFunctionDescriptor)
Assert.assertEquals("Doc for method xyzzy", doc!!.getContent())
}
@@ -61,7 +61,7 @@ public class KDocFinderTest() : LightPlatformCodeInsightFixtureTestCase() {
myFixture.configureByFile(getTestName(false) + ".kt")
val declaration = (myFixture.getFile() as KtFile).getDeclarations().single { it.getName() == "Foo" }
val descriptor = declaration.resolveToDescriptor() as ClassDescriptor
val propertyDescriptor = descriptor.defaultType.memberScope.getProperties(Name.identifier("xyzzy"), NoLookupLocation.FROM_TEST).single()
val propertyDescriptor = descriptor.defaultType.memberScope.getContributedVariables(Name.identifier("xyzzy"), NoLookupLocation.FROM_TEST).single()
val doc = KDocFinder.findKDoc(propertyDescriptor)
Assert.assertEquals("Doc for property xyzzy", doc!!.getContent())
}
@@ -198,13 +198,13 @@ public abstract class AbstractRenameTest : KotlinMultiFileTestCase() {
private fun renameKotlinFunctionTest(renameParamsObject: JsonObject, context: TestContext) {
val oldMethodName = Name.identifier(renameParamsObject.getString("oldName"))
doRenameInKotlinClassOrPackage(renameParamsObject, context) { it.getFunctions(oldMethodName, NoLookupLocation.FROM_TEST).first() }
doRenameInKotlinClassOrPackage(renameParamsObject, context) { it.getContributedFunctions(oldMethodName, NoLookupLocation.FROM_TEST).first() }
}
private fun renameKotlinPropertyTest(renameParamsObject: JsonObject, context: TestContext) {
val oldPropertyName = Name.identifier(renameParamsObject.getString("oldName"))
doRenameInKotlinClassOrPackage(renameParamsObject, context) { it.getProperties(oldPropertyName, NoLookupLocation.FROM_TEST).first() }
doRenameInKotlinClassOrPackage(renameParamsObject, context) { it.getContributedVariables(oldPropertyName, NoLookupLocation.FROM_TEST).first() }
}
private fun renameKotlinClassTest(renameParamsObject: JsonObject, context: TestContext) {
@@ -32,7 +32,7 @@ public object ClassSerializationUtil {
val classProto = serializer.classProto(classDescriptor).build() ?: error("Class not serialized: $classDescriptor")
sink.writeClass(classDescriptor, classProto)
serializeClasses(classDescriptor.getUnsubstitutedInnerClassesScope().getDescriptors(), serializer, sink, skip)
serializeClasses(classDescriptor.getUnsubstitutedInnerClassesScope().getContributedDescriptors(), serializer, sink, skip)
}
public fun serializeClasses(descriptors: Collection<DeclarationDescriptor>, serializer: DescriptorSerializer, sink: Sink, skip: (DeclarationDescriptor) -> Boolean) {

Some files were not shown because too many files have changed in this diff Show More