use of org.jetbrains.kotlin.descriptors.PackageFragmentProvider in project kotlin by JetBrains.
the class JsConfig method createModuleDescriptor.
private JsModuleDescriptor<ModuleDescriptorImpl> createModuleDescriptor(KotlinJavascriptMetadata metadata) {
assert metadata.getVersion().isCompatible() : "Expected JS metadata version " + JsMetadataVersion.INSTANCE + ", but actual metadata version is " + metadata.getVersion();
ModuleDescriptorImpl moduleDescriptor = new ModuleDescriptorImpl(Name.special("<" + metadata.getModuleName() + ">"), storageManager, JsPlatform.INSTANCE.getBuiltIns());
JsModuleDescriptor<PackageFragmentProvider> rawDescriptor = KotlinJavascriptSerializationUtil.readModule(metadata.getBody(), storageManager, moduleDescriptor, new CompilerDeserializationConfiguration(CommonConfigurationKeysKt.getLanguageVersionSettings(configuration)));
PackageFragmentProvider provider = rawDescriptor.getData();
moduleDescriptor.initialize(provider != null ? provider : PackageFragmentProvider.Empty.INSTANCE);
return rawDescriptor.copy(moduleDescriptor);
}
use of org.jetbrains.kotlin.descriptors.PackageFragmentProvider in project kotlin by JetBrains.
the class LoadBuiltinsTest method createBuiltInsPackageFragmentProvider.
@NotNull
private static PackageFragmentProvider createBuiltInsPackageFragmentProvider() {
LockBasedStorageManager storageManager = new LockBasedStorageManager();
ModuleDescriptorImpl builtInsModule = new ModuleDescriptorImpl(KotlinBuiltIns.BUILTINS_MODULE_NAME, storageManager, DefaultBuiltIns.getInstance());
PackageFragmentProvider packageFragmentProvider = createBuiltInPackageFragmentProvider(storageManager, builtInsModule, BUILT_INS_PACKAGE_FQ_NAMES, Collections.singletonList(new BuiltInFictitiousFunctionClassFactory(storageManager, builtInsModule)), PlatformDependentDeclarationFilter.All.INSTANCE, AdditionalClassPartsProvider.None.INSTANCE, new Function1<String, InputStream>() {
@Override
public InputStream invoke(String path) {
return ForTestCompileRuntime.runtimeJarClassLoader().getResourceAsStream(path);
}
});
builtInsModule.initialize(packageFragmentProvider);
builtInsModule.setDependencies(builtInsModule);
return packageFragmentProvider;
}
use of org.jetbrains.kotlin.descriptors.PackageFragmentProvider 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