use of org.jetbrains.kotlin.psi.KtClass 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