Kotlin/Native IDE plugin clean-up

- Re-organize classes
This commit is contained in:
Dmitriy Dolovov
2019-12-12 17:11:22 +03:00
parent 36ed29d4d5
commit 5b8be16f13
6 changed files with 43 additions and 33 deletions
@@ -10,5 +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(provider: KotlinDecompiledFileViewProvider, text: (VirtualFile) -> DecompiledText) :
KtDecompiledFile(provider, text)
class KotlinNativeDecompiledFile(
provider: KotlinDecompiledFileViewProvider,
text: (VirtualFile) -> DecompiledText
) : KtDecompiledFile(provider, text)
@@ -2,13 +2,8 @@
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ide.konan.decompiler
package org.jetbrains.kotlin.ide.konan.decompiler;
import org.jetbrains.kotlin.idea.util.KotlinBinaryExtension
import org.jetbrains.kotlin.idea.util.KotlinBinaryExtension;
public class KotlinNativeMetaBinary extends KotlinBinaryExtension {
public KotlinNativeMetaBinary() {
super(KotlinNativeMetaFileType.INSTANCE);
}
}
class KotlinNativeMetaBinary : KotlinBinaryExtension(KotlinNativeMetaFileType)
@@ -0,0 +1,22 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ide.konan.decompiler
import com.intellij.openapi.fileTypes.FileType
import com.intellij.openapi.vfs.VirtualFile
import org.jetbrains.kotlin.library.KLIB_METADATA_FILE_EXTENSION
object KotlinNativeMetaFileType : FileType {
override fun getName() = "KNM"
override fun getDescription() = "Kotlin/Native Metadata"
override fun getDefaultExtension() = KLIB_METADATA_FILE_EXTENSION
override fun getIcon(): Nothing? = null
override fun isBinary() = true
override fun isReadOnly() = true
override fun getCharset(file: VirtualFile, content: ByteArray): Nothing? = null
const val STUB_VERSION = 2
}
@@ -0,0 +1,14 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ide.konan.decompiler
import com.intellij.openapi.fileTypes.FileTypeConsumer
import com.intellij.openapi.fileTypes.FileTypeFactory
class KotlinNativeMetaFileTypeFactory : FileTypeFactory() {
override fun createFileTypes(consumer: FileTypeConsumer) = consumer.consume(KotlinNativeMetaFileType, KotlinNativeMetaFileType.defaultExtension)
}
@@ -5,12 +5,8 @@
package org.jetbrains.kotlin.ide.konan.decompiler
import com.intellij.openapi.fileTypes.FileType
import com.intellij.openapi.fileTypes.FileTypeConsumer
import com.intellij.openapi.fileTypes.FileTypeFactory
import com.intellij.openapi.vfs.VirtualFile
import org.jetbrains.kotlin.backend.common.serialization.metadata.KlibMetadataVersion
import org.jetbrains.kotlin.library.KLIB_METADATA_FILE_EXTENSION
import org.jetbrains.kotlin.library.metadata.KlibMetadataSerializerProtocol
import org.jetbrains.kotlin.serialization.konan.NullFlexibleTypeDeserializer
@@ -22,26 +18,8 @@ class KotlinNativeMetadataDecompiler : KotlinNativeMetadataDecompilerBase<KlibMe
{ KlibMetadataVersion.INVALID_VERSION },
KotlinNativeMetaFileType.STUB_VERSION
) {
override fun doReadFile(file: VirtualFile): FileWithMetadata? {
val fragment = KotlinNativeLoadingMetadataCache.getInstance().getCachedPackageFragment(file) ?: return null
return FileWithMetadata.Compatible(fragment, KlibMetadataSerializerProtocol) //todo: check version compatibility
}
}
object KotlinNativeMetaFileType : FileType {
override fun getName() = "KNM"
override fun getDescription() = "Kotlin/Native Metadata"
override fun getDefaultExtension() = KLIB_METADATA_FILE_EXTENSION
override fun getIcon(): Nothing? = null
override fun isBinary() = true
override fun isReadOnly() = true
override fun getCharset(file: VirtualFile, content: ByteArray): Nothing? = null
const val STUB_VERSION = 2
}
class KotlinNativeMetaFileTypeFactory : FileTypeFactory() {
override fun createFileTypes(consumer: FileTypeConsumer) = consumer.consume(KotlinNativeMetaFileType, KotlinNativeMetaFileType.defaultExtension)
}
@@ -3,7 +3,6 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ide.konan.decompiler
import com.intellij.openapi.diagnostic.Logger