use of org.jetbrains.kotlin.resolve.scopes.MemberScope in project kotlin by JetBrains.
the class ResolveSessionUtils method findClassByRelativePath.
@Nullable
public static ClassDescriptor findClassByRelativePath(@NotNull MemberScope packageScope, @NotNull FqName path) {
if (path.isRoot())
return null;
MemberScope scope = packageScope;
ClassifierDescriptor classifier = null;
for (Name name : path.pathSegments()) {
classifier = scope.getContributedClassifier(name, NoLookupLocation.WHEN_FIND_BY_FQNAME);
if (!(classifier instanceof ClassDescriptor))
return null;
scope = ((ClassDescriptor) classifier).getUnsubstitutedInnerClassesScope();
}
return (ClassDescriptor) classifier;
}
use of org.jetbrains.kotlin.resolve.scopes.MemberScope in project kotlin by JetBrains.
the class JetTestFunctionDetector method getTestFunctions.
@NotNull
private static List<FunctionDescriptor> getTestFunctions(@NotNull BindingContext bindingContext, @NotNull List<KtDeclaration> declarations) {
List<FunctionDescriptor> answer = Lists.newArrayList();
for (KtDeclaration declaration : declarations) {
MemberScope scope = null;
if (declaration instanceof KtClass) {
KtClass klass = (KtClass) declaration;
ClassDescriptor classDescriptor = BindingUtils.getClassDescriptor(bindingContext, klass);
if (classDescriptor.getModality() != Modality.ABSTRACT) {
scope = classDescriptor.getDefaultType().getMemberScope();
}
}
if (scope != null) {
Collection<DeclarationDescriptor> allDescriptors = DescriptorUtils.getAllDescriptors(scope);
List<FunctionDescriptor> testFunctions = ContainerUtil.mapNotNull(allDescriptors, new Function<DeclarationDescriptor, FunctionDescriptor>() {
@Override
public FunctionDescriptor fun(DeclarationDescriptor descriptor) {
if (descriptor instanceof FunctionDescriptor) {
FunctionDescriptor functionDescriptor = (FunctionDescriptor) descriptor;
if (isTest(functionDescriptor))
return functionDescriptor;
}
return null;
}
});
answer.addAll(testFunctions);
}
}
return answer;
}
Aggregations