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