use of org.jetbrains.kotlin.resolve.scopes.MemberScope in project kotlin by JetBrains.
the class AbstractAnnotationDescriptorResolveTest method getFunctionDescriptor.
@NotNull
private static FunctionDescriptor getFunctionDescriptor(@NotNull ClassDescriptor classDescriptor, @NotNull String name) {
Name functionName = Name.identifier(name);
MemberScope memberScope = classDescriptor.getMemberScope(Collections.<TypeProjection>emptyList());
Collection<SimpleFunctionDescriptor> functions = memberScope.getContributedFunctions(functionName, NoLookupLocation.FROM_TEST);
assert functions.size() == 1 : "Failed to find function " + functionName + " in class" + "." + classDescriptor.getName();
return functions.iterator().next();
}
use of org.jetbrains.kotlin.resolve.scopes.MemberScope in project kotlin by JetBrains.
the class AbstractAnnotationDescriptorResolveTest method getInnerClassDescriptor.
@NotNull
private static ClassDescriptor getInnerClassDescriptor(@NotNull ClassDescriptor classDescriptor, @NotNull String name) {
Name propertyName = Name.identifier(name);
MemberScope memberScope = classDescriptor.getMemberScope(Collections.<TypeProjection>emptyList());
ClassifierDescriptor innerClass = memberScope.getContributedClassifier(propertyName, NoLookupLocation.FROM_TEST);
assert innerClass instanceof ClassDescriptor : "Failed to find inner class " + propertyName + " in class " + classDescriptor.getName();
return (ClassDescriptor) innerClass;
}
use of org.jetbrains.kotlin.resolve.scopes.MemberScope in project kotlin by JetBrains.
the class AbstractAnnotationDescriptorResolveTest method getFunctionDescriptor.
@NotNull
protected static FunctionDescriptor getFunctionDescriptor(@NotNull PackageFragmentDescriptor packageView, @NotNull String name) {
Name functionName = Name.identifier(name);
MemberScope memberScope = packageView.getMemberScope();
Collection<SimpleFunctionDescriptor> functions = memberScope.getContributedFunctions(functionName, NoLookupLocation.FROM_TEST);
assert functions.size() == 1 : "Failed to find function " + functionName + " in class" + "." + packageView.getName();
return functions.iterator().next();
}
use of org.jetbrains.kotlin.resolve.scopes.MemberScope in project kotlin by JetBrains.
the class AbstractAnnotationDescriptorResolveTest method getPropertyDescriptor.
@Nullable
protected static PropertyDescriptor getPropertyDescriptor(@NotNull PackageFragmentDescriptor packageView, @NotNull String name, boolean failOnMissing) {
Name propertyName = Name.identifier(name);
MemberScope memberScope = packageView.getMemberScope();
Collection<PropertyDescriptor> properties = memberScope.getContributedVariables(propertyName, NoLookupLocation.FROM_TEST);
if (properties.isEmpty()) {
for (DeclarationDescriptor descriptor : DescriptorUtils.getAllDescriptors(memberScope)) {
if (descriptor instanceof ClassDescriptor) {
Collection<PropertyDescriptor> classProperties = ((ClassDescriptor) descriptor).getMemberScope(Collections.<TypeProjection>emptyList()).getContributedVariables(propertyName, NoLookupLocation.FROM_TEST);
if (!classProperties.isEmpty()) {
properties = classProperties;
break;
}
}
}
}
if (failOnMissing) {
assert properties.size() == 1 : "Failed to find property " + propertyName + " in class " + packageView.getName();
} else if (properties.size() != 1) {
return null;
}
return properties.iterator().next();
}
use of org.jetbrains.kotlin.resolve.scopes.MemberScope in project kotlin by JetBrains.
the class RecursiveDescriptorComparator method getPackageScopeInModule.
@NotNull
private MemberScope getPackageScopeInModule(@NotNull PackageViewDescriptor descriptor, @NotNull ModuleDescriptor module) {
// See LazyPackageViewDescriptorImpl#memberScope
List<MemberScope> scopes = new ArrayList<MemberScope>();
for (PackageFragmentDescriptor fragment : descriptor.getFragments()) {
if (isFromModule(fragment, module)) {
scopes.add(fragment.getMemberScope());
}
}
scopes.add(new SubpackagesScope(module, descriptor.getFqName()));
return ChainedMemberScope.Companion.create("test", scopes);
}
Aggregations