Rename everything non-Native specific to Klib
This commit is contained in:
committed by
Dmitriy Dolovov
parent
b6d811c69c
commit
987e1019a8
@@ -5,14 +5,11 @@
|
||||
|
||||
package org.jetbrains.kotlin.ide.konan
|
||||
|
||||
import com.intellij.ide.highlighter.ArchiveFileType
|
||||
import com.intellij.openapi.fileTypes.FileTypeConsumer
|
||||
import com.intellij.openapi.fileTypes.FileTypeFactory
|
||||
import org.jetbrains.kotlin.library.KLIB_FILE_EXTENSION
|
||||
|
||||
class KotlinNativeFileTypeFactory : FileTypeFactory() {
|
||||
override fun createFileTypes(consumer: FileTypeConsumer) {
|
||||
consumer.consume(ArchiveFileType.INSTANCE, KLIB_FILE_EXTENSION)
|
||||
consumer.consume(NativeDefinitionsFileType, KOTLIN_NATIVE_DEFINITIONS_FILE_EXTENSION)
|
||||
}
|
||||
}
|
||||
@@ -15,19 +15,16 @@ import com.intellij.psi.impl.PsiFileFactoryImpl
|
||||
import com.intellij.psi.stubs.PsiFileStub
|
||||
import com.intellij.testFramework.LightVirtualFile
|
||||
import com.intellij.util.PathUtil
|
||||
import org.jetbrains.kotlin.ide.konan.decompiler.KotlinNativeLoadingMetadataCache
|
||||
import org.jetbrains.kotlin.ide.konan.decompiler.KlibLoadingMetadataCache
|
||||
import org.jetbrains.kotlin.idea.KotlinFileType
|
||||
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||
import org.jetbrains.kotlin.idea.decompiler.textBuilder.LoggingErrorReporter
|
||||
import org.jetbrains.kotlin.library.*
|
||||
import org.jetbrains.kotlin.library.impl.BuiltInsPlatform
|
||||
import org.jetbrains.kotlin.library.impl.KotlinLibraryImpl
|
||||
import org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf
|
||||
import org.jetbrains.kotlin.library.metadata.PackageAccessHandler
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes
|
||||
import java.io.IOException
|
||||
import java.util.*
|
||||
import org.jetbrains.kotlin.konan.file.File as KFile
|
||||
|
||||
fun createFileStub(project: Project, text: String): PsiFileStub<*> {
|
||||
@@ -67,7 +64,7 @@ internal object CachingIdeKonanLibraryMetadataLoader : PackageAccessHandler {
|
||||
}
|
||||
|
||||
private val cache
|
||||
get() = KotlinNativeLoadingMetadataCache.getInstance()
|
||||
get() = KlibLoadingMetadataCache.getInstance()
|
||||
|
||||
private val KotlinLibrary.moduleHeaderFile
|
||||
get() = (this as KotlinLibraryImpl).metadata.access.layout.moduleHeaderFile
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.idea.decompiler.KotlinDecompiledFileViewProvider
|
||||
import org.jetbrains.kotlin.idea.decompiler.KtDecompiledFile
|
||||
import org.jetbrains.kotlin.idea.decompiler.textBuilder.DecompiledText
|
||||
|
||||
class KotlinNativeDecompiledFile(
|
||||
class KlibDecompiledFile(
|
||||
provider: KotlinDecompiledFileViewProvider,
|
||||
text: (VirtualFile) -> DecompiledText
|
||||
) : KtDecompiledFile(provider, text)
|
||||
+3
-3
@@ -19,12 +19,12 @@ import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion
|
||||
import java.io.IOException
|
||||
import java.util.*
|
||||
|
||||
class KotlinNativeLoadingMetadataCache : BaseComponent {
|
||||
class KlibLoadingMetadataCache : BaseComponent {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun getInstance(): KotlinNativeLoadingMetadataCache =
|
||||
ApplicationManager.getApplication().getComponent(KotlinNativeLoadingMetadataCache::class.java)
|
||||
fun getInstance(): KlibLoadingMetadataCache =
|
||||
ApplicationManager.getApplication().getComponent(KlibLoadingMetadataCache::class.java)
|
||||
}
|
||||
|
||||
// Use special CacheKey class instead of VirtualFile for cache keys. Certain types of VirtualFiles (for example, obtained from JarFileSystem)
|
||||
+1
-1
@@ -6,4 +6,4 @@ package org.jetbrains.kotlin.ide.konan.decompiler
|
||||
|
||||
import org.jetbrains.kotlin.idea.util.KotlinBinaryExtension
|
||||
|
||||
class KotlinNativeMetaBinary : KotlinBinaryExtension(KotlinNativeMetaFileType)
|
||||
class KlibMetaBinary : KotlinBinaryExtension(KlibMetaFileType)
|
||||
+1
-1
@@ -10,7 +10,7 @@ import com.intellij.openapi.vfs.VirtualFile
|
||||
import org.jetbrains.kotlin.ide.konan.KotlinNativeBundle
|
||||
import org.jetbrains.kotlin.library.KLIB_METADATA_FILE_EXTENSION
|
||||
|
||||
object KotlinNativeMetaFileType : FileType {
|
||||
object KlibMetaFileType : FileType {
|
||||
override fun getName() = "KNM"
|
||||
override fun getDescription() = KotlinNativeBundle.message("kotlin.native.metadata.short")
|
||||
override fun getDefaultExtension() = KLIB_METADATA_FILE_EXTENSION
|
||||
+5
-5
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.serialization.deserialization.getClassId
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import java.io.IOException
|
||||
|
||||
abstract class KotlinNativeMetadataDecompilerBase<out V : BinaryVersion>(
|
||||
abstract class KlibMetadataDecompiler<out V : BinaryVersion>(
|
||||
private val fileType: FileType,
|
||||
private val serializerProtocol: () -> SerializerExtensionProtocol,
|
||||
private val flexibleTypeDeserializer: FlexibleTypeDeserializer,
|
||||
@@ -37,8 +37,8 @@ abstract class KotlinNativeMetadataDecompilerBase<out V : BinaryVersion>(
|
||||
stubVersion: Int
|
||||
) : ClassFileDecompilers.Full() {
|
||||
|
||||
private val metadataStubBuilder: KotlinNativeMetadataStubBuilder =
|
||||
KotlinNativeMetadataStubBuilder(
|
||||
private val metadataStubBuilder: KlibMetadataStubBuilder =
|
||||
KlibMetadataStubBuilder(
|
||||
stubVersion,
|
||||
fileType,
|
||||
serializerProtocol,
|
||||
@@ -57,7 +57,7 @@ abstract class KotlinNativeMetadataDecompilerBase<out V : BinaryVersion>(
|
||||
|
||||
override fun createFileViewProvider(file: VirtualFile, manager: PsiManager, physical: Boolean) =
|
||||
KotlinDecompiledFileViewProvider(manager, file, physical) { provider ->
|
||||
KotlinNativeDecompiledFile(
|
||||
KlibDecompiledFile(
|
||||
provider,
|
||||
::buildDecompiledText
|
||||
)
|
||||
@@ -121,7 +121,7 @@ fun decompiledText(
|
||||
renderer: DescriptorRenderer
|
||||
): DecompiledText {
|
||||
val packageFqName = file.packageFqName
|
||||
val resolver = KotlinNativeMetadataDeserializerForDecompiler(
|
||||
val resolver = KlibMetadataDeserializerForDecompiler(
|
||||
packageFqName, file.proto, file.nameResolver,
|
||||
serializerProtocol, flexibleTypeDeserializer
|
||||
)
|
||||
+2
-2
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.serialization.SerializerExtensionProtocol
|
||||
import org.jetbrains.kotlin.serialization.deserialization.*
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPackageMemberScope
|
||||
|
||||
class KotlinNativeMetadataDeserializerForDecompiler(
|
||||
class KlibMetadataDeserializerForDecompiler(
|
||||
packageFqName: FqName,
|
||||
private val proto: ProtoBuf.PackageFragment,
|
||||
private val nameResolver: NameResolver,
|
||||
@@ -67,7 +67,7 @@ class KotlinNativeMetadataDeserializerForDecompiler(
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val LOG = Logger.getInstance(KotlinNativeMetadataDeserializerForDecompiler::class.java)
|
||||
private val LOG = Logger.getInstance(KlibMetadataDeserializerForDecompiler::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||
import org.jetbrains.kotlin.serialization.SerializerExtensionProtocol
|
||||
import org.jetbrains.kotlin.serialization.js.DynamicTypeDeserializer
|
||||
|
||||
open class KotlinNativeMetadataStubBuilder(
|
||||
open class KlibMetadataStubBuilder(
|
||||
private val version: Int,
|
||||
private val fileType: FileType,
|
||||
private val serializerProtocol: () -> SerializerExtensionProtocol,
|
||||
+4
-4
@@ -10,16 +10,16 @@ import org.jetbrains.kotlin.backend.common.serialization.metadata.KlibMetadataVe
|
||||
import org.jetbrains.kotlin.library.metadata.KlibMetadataSerializerProtocol
|
||||
import org.jetbrains.kotlin.serialization.js.DynamicTypeDeserializer
|
||||
|
||||
class KotlinNativeMetadataDecompiler : KotlinNativeMetadataDecompilerBase<KlibMetadataVersion>(
|
||||
KotlinNativeMetaFileType,
|
||||
class KotlinNativeMetadataDecompiler : KlibMetadataDecompiler<KlibMetadataVersion>(
|
||||
KlibMetaFileType,
|
||||
{ KlibMetadataSerializerProtocol },
|
||||
DynamicTypeDeserializer,
|
||||
{ KlibMetadataVersion.INSTANCE },
|
||||
{ KlibMetadataVersion.INVALID_VERSION },
|
||||
KotlinNativeMetaFileType.STUB_VERSION
|
||||
KlibMetaFileType.STUB_VERSION
|
||||
) {
|
||||
override fun doReadFile(file: VirtualFile): FileWithMetadata? {
|
||||
val fragment = KotlinNativeLoadingMetadataCache.getInstance().getCachedPackageFragment(file) ?: return null
|
||||
val fragment = KlibLoadingMetadataCache.getInstance().getCachedPackageFragment(file) ?: return null
|
||||
return FileWithMetadata.Compatible(fragment, KlibMetadataSerializerProtocol) //todo: check version compatibility
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -6,28 +6,28 @@
|
||||
package org.jetbrains.kotlin.ide.konan.index
|
||||
|
||||
import com.intellij.util.indexing.FileBasedIndex
|
||||
import org.jetbrains.kotlin.ide.konan.decompiler.KotlinNativeLoadingMetadataCache
|
||||
import org.jetbrains.kotlin.ide.konan.decompiler.KotlinNativeMetaFileType
|
||||
import org.jetbrains.kotlin.ide.konan.decompiler.KlibLoadingMetadataCache
|
||||
import org.jetbrains.kotlin.ide.konan.decompiler.KlibMetaFileType
|
||||
import org.jetbrains.kotlin.idea.vfilefinder.KotlinFileIndexBase
|
||||
import org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
|
||||
object KotlinNativeMetaFileIndex : KotlinFileIndexBase<KotlinNativeMetaFileIndex>(KotlinNativeMetaFileIndex::class.java) {
|
||||
object KlibMetaFileIndex : KotlinFileIndexBase<KlibMetaFileIndex>(KlibMetaFileIndex::class.java) {
|
||||
|
||||
override fun getIndexer() = INDEXER
|
||||
|
||||
override fun getInputFilter() = FileBasedIndex.InputFilter { it.fileType === KotlinNativeMetaFileType }
|
||||
override fun getInputFilter() = FileBasedIndex.InputFilter { it.fileType === KlibMetaFileType }
|
||||
|
||||
override fun getVersion() = VERSION
|
||||
|
||||
// This is to express intention to index all Kotlin/Native metadata files irrespectively to file size:
|
||||
override fun getFileTypesWithSizeLimitNotApplicable() = listOf(KotlinNativeMetaFileType)
|
||||
override fun getFileTypesWithSizeLimitNotApplicable() = listOf(KlibMetaFileType)
|
||||
|
||||
private const val VERSION = 4
|
||||
|
||||
/*todo: check version?!*/
|
||||
private val INDEXER = indexer { fileContent ->
|
||||
val fragment = KotlinNativeLoadingMetadataCache.getInstance().getCachedPackageFragment(fileContent.file)
|
||||
val fragment = KlibLoadingMetadataCache.getInstance().getCachedPackageFragment(fileContent.file)
|
||||
if (fragment != null)
|
||||
FqName(fragment.getExtension(KlibMetadataProtoBuf.fqName))
|
||||
else
|
||||
Reference in New Issue
Block a user