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
@@ -120,7 +120,7 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
tmpdir, getTestRootDisposable(), TestJdkKind.MOCK_JDK, configurationKind, true
).first;
for (DeclarationDescriptor descriptor : packageFromBinary.getMemberScope().getAllDescriptors()) {
for (DeclarationDescriptor descriptor : DescriptorUtils.getAllDescriptors(packageFromBinary.getMemberScope())) {
if (descriptor instanceof ClassDescriptor) {
assert descriptor instanceof DeserializedClassDescriptor : DescriptorUtils.getFqName(descriptor) + " is loaded as " + descriptor.getClass();
}
@@ -156,7 +156,7 @@ public abstract class AbstractSdkAnnotationsValidityTest extends UsefulTestCase
}
private Void visitDeclarationRecursively(@NotNull DeclarationDescriptor descriptor, @NotNull KtScope memberScope) {
for (DeclarationDescriptor member : memberScope.getAllDescriptors()) {
for (DeclarationDescriptor member : DescriptorUtils.getAllDescriptors(memberScope)) {
member.acceptVoid(this);
}
return visitDeclaration(descriptor);
@@ -35,6 +35,7 @@ import org.jetbrains.kotlin.config.CompilerConfiguration;
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
import org.jetbrains.kotlin.descriptors.PackageViewDescriptor;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.lazy.JvmResolveUtil;
import org.jetbrains.kotlin.test.*;
import org.jetbrains.kotlin.test.util.DescriptorValidator;
@@ -107,7 +108,7 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
@NotNull
private Collection<DeclarationDescriptor> analyzeAndGetAllDescriptors(@NotNull File... extraClassPath) throws IOException {
return analyzeFileToPackageView(extraClassPath).getMemberScope().getAllDescriptors();
return DescriptorUtils.getAllDescriptors(analyzeFileToPackageView(extraClassPath).getMemberScope());
}
@NotNull
@@ -37,7 +37,7 @@ class DeserializedScopeValidationVisitor : ValidationVisitor() {
private fun validateDeserializedScope(scope: KtScope) {
val isPackageViewScope = scope.safeGetContainingDeclaration() is PackageViewDescriptor
if (scope is DeserializedMemberScope || isPackageViewScope) {
val relevantDescriptors = scope.getAllDescriptors().filter { member ->
val relevantDescriptors = scope.getDescriptors().filter { member ->
member is CallableMemberDescriptor && member.getKind().isReal() || (!isPackageViewScope && member is ClassDescriptor)
}
checkSorted(relevantDescriptors, scope.getContainingDeclaration())
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.load.java.JavaBindingContext;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
import org.jetbrains.kotlin.resolve.scopes.KtScope;
@@ -96,7 +97,7 @@ public class ExpectedLoadErrorsUtil {
}
private Void visitDeclarationRecursively(@NotNull DeclarationDescriptor descriptor, @NotNull KtScope memberScope) {
for (DeclarationDescriptor member : memberScope.getAllDescriptors()) {
for (DeclarationDescriptor member : DescriptorUtils.getAllDescriptors(memberScope)) {
member.acceptVoid(this);
}
@@ -33,6 +33,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor;
import org.jetbrains.kotlin.descriptors.ModuleDescriptor;
import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
import org.jetbrains.kotlin.resolve.lazy.LazyResolveTestUtil;
import org.jetbrains.kotlin.test.ConfigurationKind;
@@ -214,7 +215,7 @@ public class ResolveDescriptorsFromExternalLibraries {
if (clazz == null) {
throw new IllegalStateException("class not found by name " + className + " in " + libDescription);
}
clazz.getDefaultType().getMemberScope().getAllDescriptors();
DescriptorUtils.getAllDescriptors(clazz.getDefaultType().getMemberScope());
}
catch (Exception e) {
System.err.println("failed to resolve " + className);
@@ -41,6 +41,7 @@ import org.jetbrains.kotlin.renderer.DescriptorRendererModifier;
import org.jetbrains.kotlin.renderer.DescriptorRendererOptions;
import org.jetbrains.kotlin.renderer.NameShortness;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.scopes.KtScope;
import org.jetbrains.kotlin.test.KotlinLiteFixture;
import org.jetbrains.kotlin.test.KotlinTestUtils;
@@ -188,7 +189,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends KotlinLite
KtScope memberScope = packageView.getMemberScope();
Collection<PropertyDescriptor> properties = memberScope.getProperties(propertyName, NoLookupLocation.FROM_TEST);
if (properties.isEmpty()) {
for (DeclarationDescriptor descriptor : memberScope.getAllDescriptors()) {
for (DeclarationDescriptor descriptor : DescriptorUtils.getAllDescriptors(memberScope)) {
if (descriptor instanceof ClassDescriptor) {
Collection<PropertyDescriptor> classProperties =
((ClassDescriptor) descriptor).getMemberScope(Collections.<TypeProjection>emptyList())
@@ -24,6 +24,7 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.scopes.KtScope;
import org.jetbrains.kotlin.types.KotlinType;
import org.junit.Assert;
@@ -84,7 +85,7 @@ public class DescriptorValidator {
}
protected void validateScope(@NotNull KtScope scope, @NotNull DiagnosticCollector collector) {
for (DeclarationDescriptor descriptor : scope.getAllDescriptors()) {
for (DeclarationDescriptor descriptor : DescriptorUtils.getAllDescriptors(scope)) {
if (recursiveFilter.apply(descriptor)) {
descriptor.accept(new ScopeValidatorVisitor(collector), scope);
}
@@ -129,7 +129,7 @@ public class RecursiveDescriptorComparator {
appendSubDescriptors(descriptor, module,
klass.getDefaultType().getMemberScope(), klass.getConstructors(), printer);
KtScope staticScope = klass.getStaticScope();
if (!staticScope.getAllDescriptors().isEmpty()) {
if (!DescriptorUtils.getAllDescriptors(staticScope).isEmpty()) {
printer.println();
printer.println("// Static members");
appendSubDescriptors(descriptor, module, staticScope, Collections.<DeclarationDescriptor>emptyList(), printer);
@@ -196,7 +196,7 @@ public class RecursiveDescriptorComparator {
List<DeclarationDescriptor> subDescriptors = Lists.newArrayList();
subDescriptors.addAll(memberScope.getAllDescriptors());
subDescriptors.addAll(DescriptorUtils.getAllDescriptors(memberScope));
subDescriptors.addAll(extraSubDescriptors);
Collections.sort(subDescriptors, MemberComparator.INSTANCE);
@@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import java.util.Collection;
@@ -68,13 +69,13 @@ public class RecursiveDescriptorProcessor {
@Override
public Boolean visitPackageFragmentDescriptor(PackageFragmentDescriptor descriptor, D data) {
return applyWorker(descriptor, data)
&& visitChildren(descriptor.getMemberScope().getAllDescriptors(), data);
&& visitChildren(DescriptorUtils.getAllDescriptors(descriptor.getMemberScope()), data);
}
@Override
public Boolean visitPackageViewDescriptor(PackageViewDescriptor descriptor, D data) {
return applyWorker(descriptor, data)
&& visitChildren(descriptor.getMemberScope().getAllDescriptors(), data);
&& visitChildren(DescriptorUtils.getAllDescriptors(descriptor.getMemberScope()), data);
}
@Override
@@ -105,7 +106,7 @@ public class RecursiveDescriptorProcessor {
&& visitChildren(descriptor.getThisAsReceiverParameter(), data)
&& visitChildren(descriptor.getConstructors(), data)
&& visitChildren(descriptor.getTypeConstructor().getParameters(), data)
&& visitChildren(descriptor.getDefaultType().getMemberScope().getAllDescriptors(), data);
&& visitChildren(DescriptorUtils.getAllDescriptors(descriptor.getDefaultType().getMemberScope()), data);
}
@Override