use of org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor in project kotlin by JetBrains.
the class BuiltInsReferenceResolverTest method getAllStandardDescriptors.
private static Collection<DeclarationDescriptor> getAllStandardDescriptors() {
final List<DeclarationDescriptor> descriptors = new ArrayList<DeclarationDescriptor>();
PackageFragmentDescriptor builtinsPackageFragment = DefaultBuiltIns.getInstance().getBuiltInsPackageFragment();
for (DeclarationDescriptor packageMember : DescriptorUtils.getAllDescriptors(builtinsPackageFragment.getMemberScope())) {
packageMember.acceptVoid(new DeclarationDescriptorVisitorEmptyBodies<Void, Void>() {
@Override
public Void visitClassDescriptor(ClassDescriptor descriptor, Void data) {
descriptors.add(descriptor);
for (DeclarationDescriptor classMember : DescriptorUtils.getAllDescriptors(descriptor.getDefaultType().getMemberScope())) {
classMember.acceptVoid(this);
}
return null;
}
@Override
public Void visitDeclarationDescriptor(DeclarationDescriptor descriptor, Void data) {
descriptors.add(descriptor);
return null;
}
});
}
return descriptors;
}
use of org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor in project kotlin by JetBrains.
the class LoadBuiltinsTest method testBuiltIns.
public void testBuiltIns() throws Exception {
RecursiveDescriptorComparator.Configuration configuration = RecursiveDescriptorComparator.RECURSIVE_ALL.includeMethodsOfKotlinAny(false).withRenderer(DescriptorRenderer.Companion.withOptions(new Function1<DescriptorRendererOptions, Unit>() {
@Override
public Unit invoke(DescriptorRendererOptions options) {
options.setWithDefinedIn(false);
options.setOverrideRenderingPolicy(OverrideRenderingPolicy.RENDER_OPEN_OVERRIDE);
options.setVerbose(true);
options.setAnnotationArgumentsRenderingPolicy(AnnotationArgumentsRenderingPolicy.UNLESS_EMPTY);
options.setModifiers(DescriptorRendererModifier.ALL);
return Unit.INSTANCE;
}
}));
PackageFragmentProvider packageFragmentProvider = createBuiltInsPackageFragmentProvider();
List<KtFile> files = KotlinTestUtils.loadToJetFiles(getEnvironment(), ContainerUtil.concat(allFilesUnder("core/builtins/native"), allFilesUnder("core/builtins/src")));
ModuleDescriptor module = LazyResolveTestUtilsKt.createResolveSessionForFiles(getEnvironment().getProject(), files, false).getModuleDescriptor();
for (FqName packageFqName : CollectionsKt.listOf(BUILT_INS_PACKAGE_FQ_NAME, COLLECTIONS_PACKAGE_FQ_NAME, RANGES_PACKAGE_FQ_NAME)) {
PackageFragmentDescriptor fromLazyResolve = CollectionsKt.single(module.getPackage(packageFqName).getFragments());
if (fromLazyResolve instanceof LazyPackageDescriptor) {
PackageFragmentDescriptor deserialized = CollectionsKt.single(packageFragmentProvider.getPackageFragments(packageFqName));
RecursiveDescriptorComparator.validateAndCompareDescriptors(fromLazyResolve, deserialized, configuration, new File("compiler/testData/builtin-classes/default/" + packageFqName.asString().replace('.', '-') + ".txt"));
}
}
}
Aggregations