Removed usages KtScope.getAllDescriptors

This commit is contained in:
Stanislav Erokhin
2015-11-02 16:07:19 +03:00
parent 21fdd2ffc3
commit 0b5de434fa
37 changed files with 82 additions and 57 deletions
@@ -93,7 +93,7 @@ public final class WhenChecker {
assert isEnumClass(enumClassDescriptor) :
"isWhenOnEnumExhaustive should be called with an enum class descriptor";
Set<ClassDescriptor> entryDescriptors = new HashSet<ClassDescriptor>();
for (DeclarationDescriptor descriptor : enumClassDescriptor.getUnsubstitutedInnerClassesScope().getAllDescriptors()) {
for (DeclarationDescriptor descriptor : DescriptorUtils.getAllDescriptors(enumClassDescriptor.getUnsubstitutedInnerClassesScope())) {
if (isEnumEntry(descriptor)) {
entryDescriptors.add((ClassDescriptor) descriptor);
}
@@ -106,7 +106,7 @@ public final class WhenChecker {
@NotNull ClassDescriptor currentDescriptor,
@NotNull Set<ClassDescriptor> subclasses
) {
for (DeclarationDescriptor descriptor : currentDescriptor.getUnsubstitutedInnerClassesScope().getAllDescriptors()) {
for (DeclarationDescriptor descriptor : DescriptorUtils.getAllDescriptors(currentDescriptor.getUnsubstitutedInnerClassesScope())) {
if (descriptor instanceof ClassDescriptor) {
ClassDescriptor memberClassDescriptor = (ClassDescriptor) descriptor;
if (DescriptorUtils.isDirectSubclass(memberClassDescriptor, baseDescriptor)) {
@@ -53,7 +53,7 @@ public class DeclarationResolver(
public fun checkRedeclarations(c: TopDownAnalysisContext) {
for (classDescriptor in c.getDeclaredClasses().values()) {
val descriptorMap = HashMultimap.create<Name, DeclarationDescriptor>()
for (desc in classDescriptor.getUnsubstitutedMemberScope().getOwnDeclaredDescriptors()) {
for (desc in classDescriptor.getUnsubstitutedMemberScope().getDescriptors()) {
if (desc is ClassDescriptor || desc is PropertyDescriptor) {
descriptorMap.put(desc.getName(), desc)
}
@@ -38,6 +38,8 @@ import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.CallResolverUtilKt;
import org.jetbrains.kotlin.resolve.dataClassUtils.DataClassUtilsKt;
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter;
import org.jetbrains.kotlin.resolve.scopes.KtScope;
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
import org.jetbrains.kotlin.types.*;
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
@@ -243,7 +245,7 @@ public class OverrideResolver {
private static List<CallableMemberDescriptor> getCallableMembersFromType(KotlinType type) {
List<CallableMemberDescriptor> r = Lists.newArrayList();
for (DeclarationDescriptor decl : type.getMemberScope().getAllDescriptors()) {
for (DeclarationDescriptor decl : type.getMemberScope().getDescriptors(DescriptorKindFilter.CALLABLES, KtScope.Companion.getALL_NAME_FILTER())) {
if (decl instanceof PropertyDescriptor || decl instanceof SimpleFunctionDescriptor) {
r.add((CallableMemberDescriptor) decl);
}
@@ -305,7 +307,8 @@ public class OverrideResolver {
@NotNull Set<CallableMemberDescriptor> abstractInBaseClassNoImpl,
@NotNull Set<CallableMemberDescriptor> conflictingInterfaceOverrides
) {
for (DeclarationDescriptor member : classDescriptor.getDefaultType().getMemberScope().getAllDescriptors()) {
for (DeclarationDescriptor member : classDescriptor.getDefaultType().getMemberScope()
.getDescriptors(DescriptorKindFilter.CALLABLES, KtScope.Companion.getALL_NAME_FILTER())) {
if (member instanceof CallableMemberDescriptor) {
collectMissingImplementations((CallableMemberDescriptor) member,
abstractNoImpl, manyImpl,
@@ -812,7 +815,8 @@ public class OverrideResolver {
private void checkParameterOverridesForAllClasses(@NotNull TopDownAnalysisContext c) {
for (ClassDescriptorWithResolutionScopes classDescriptor : c.getDeclaredClasses().values()) {
for (DeclarationDescriptor member : classDescriptor.getDefaultType().getMemberScope().getAllDescriptors()) {
for (DeclarationDescriptor member : classDescriptor.getDefaultType().getMemberScope()
.getDescriptors(DescriptorKindFilter.CALLABLES, KtScope.Companion.getALL_NAME_FILTER())) {
if (member instanceof CallableMemberDescriptor) {
checkOverridesForParameters((CallableMemberDescriptor) member);
}
@@ -22,6 +22,7 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.annotations.AnnotationWithTarget;
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.scopes.KtScope;
import org.jetbrains.kotlin.types.*;
@@ -38,7 +39,7 @@ public class ForceResolveUtil {
}
public static void forceResolveAllContents(@NotNull KtScope scope) {
forceResolveAllContents(scope.getAllDescriptors());
forceResolveAllContents(DescriptorUtils.getAllDescriptors(scope));
}
public static void forceResolveAllContents(@NotNull Iterable<? extends DeclarationDescriptor> descriptors) {
@@ -46,6 +46,7 @@ import org.jetbrains.kotlin.resolve.lazy.data.JetClassLikeInfo;
import org.jetbrains.kotlin.resolve.lazy.data.JetClassOrObjectInfo;
import org.jetbrains.kotlin.resolve.lazy.data.JetObjectInfo;
import org.jetbrains.kotlin.resolve.lazy.declarations.ClassMemberDeclarationProvider;
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter;
import org.jetbrains.kotlin.resolve.scopes.KtScope;
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
import org.jetbrains.kotlin.resolve.scopes.StaticScopeForKotlinClass;
@@ -287,7 +288,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
public Collection<CallableMemberDescriptor> getDeclaredCallableMembers() {
//noinspection unchecked
return (Collection) CollectionsKt.filter(
unsubstitutedMemberScope.getAllDescriptors(),
DescriptorUtils.getAllDescriptors(unsubstitutedMemberScope),
new Function1<DeclarationDescriptor, Boolean>() {
@Override
public Boolean invoke(DeclarationDescriptor descriptor) {
@@ -474,7 +475,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
getOriginal();
getScopeForClassHeaderResolution();
getScopeForMemberDeclarationResolution();
getUnsubstitutedMemberScope().getAllDescriptors();
getUnsubstitutedMemberScope().getDescriptors(DescriptorKindFilter.ALL, KtScope.Companion.getALL_NAME_FILTER());
getScopeForInitializerResolution();
getUnsubstitutedInnerClassesScope();
getTypeConstructor().getSupertypes();
@@ -39,7 +39,7 @@ public class LexicalChainedScope @JvmOverloads constructor(
private val scopeChain = memberScopes.clone()
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean)
= getFromAllScopes(scopeChain) { it.getAllDescriptors() }
= getFromAllScopes(scopeChain) { it.getDescriptors() }
override fun getContributedClassifier(name: Name, location: LookupLocation) = getFirstMatch(scopeChain) { it.getClassifier(name, location) }