Refactor DeserializedPackageFragment and subclasses

Push loadResource and loadResourceSure down to KotlinJavascriptPackageFragment,
as it's no longer needed in BuiltInsPackageFragment
This commit is contained in:
Alexander Udalov
2016-11-16 12:12:19 +03:00
parent 19520bf29c
commit c0b5fd193a
5 changed files with 13 additions and 13 deletions
@@ -30,8 +30,8 @@ class KotlinJavascriptPackageFragment(
fqName: FqName,
storageManager: StorageManager,
module: ModuleDescriptor,
loadResource: (path: String) -> InputStream?
) : DeserializedPackageFragment(fqName, storageManager, module, loadResource) {
private val loadResource: (path: String) -> InputStream?
) : DeserializedPackageFragment(fqName, storageManager, module) {
private val nameResolver =
loadResourceSure(KotlinJavascriptSerializedResourcePaths.getStringTableFilePath(fqName)).use { stream ->
NameResolverImpl.read(stream)
@@ -53,4 +53,7 @@ class KotlinJavascriptPackageFragment(
val classesProto = JsProtoBuf.Classes.parseFrom(classesStream, JsSerializerProtocol.extensionRegistry)
classesProto.classNameList?.map { id -> nameResolver.getName(id) } ?: listOf()
}
private fun loadResourceSure(path: String): InputStream =
loadResource(path) ?: throw IllegalStateException("Resource not found in classpath: $path")
}