Rename "Konan" -> "KotlinNative" in class and function names (part 3)
This commit is contained in:
committed by
Mikhail Glukhikh
parent
cb7009ace8
commit
f663c0ea87
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
* that can be found in the license/LICENSE.txt file.
|
* that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.konan.gradle.internal;
|
package org.jetbrains.kotlin.ide.konan.gradle;
|
||||||
|
|
||||||
import com.intellij.codeInspection.LocalInspectionEP;
|
import com.intellij.codeInspection.LocalInspectionEP;
|
||||||
import com.intellij.openapi.components.ApplicationComponent;
|
import com.intellij.openapi.components.ApplicationComponent;
|
||||||
+4
-3
@@ -3,7 +3,7 @@
|
|||||||
* that can be found in the license/LICENSE.txt file.
|
* that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.konan
|
package org.jetbrains.kotlin.ide.konan
|
||||||
|
|
||||||
import com.intellij.ide.highlighter.ArchiveFileType
|
import com.intellij.ide.highlighter.ArchiveFileType
|
||||||
import com.intellij.ide.util.TipAndTrickBean
|
import com.intellij.ide.util.TipAndTrickBean
|
||||||
@@ -12,8 +12,9 @@ import com.intellij.openapi.extensions.Extensions
|
|||||||
import com.intellij.openapi.fileTypes.FileTypeManager
|
import com.intellij.openapi.fileTypes.FileTypeManager
|
||||||
import org.jetbrains.kotlin.konan.library.KLIB_FILE_EXTENSION
|
import org.jetbrains.kotlin.konan.library.KLIB_FILE_EXTENSION
|
||||||
|
|
||||||
class KonanApplicationComponent : ApplicationComponent {
|
class KotlinNativeApplicationComponent : ApplicationComponent {
|
||||||
override fun getComponentName(): String = "KonanApplicationComponent"
|
|
||||||
|
override fun getComponentName(): String = "KotlinNativeApplicationComponent"
|
||||||
|
|
||||||
override fun initComponent() {
|
override fun initComponent() {
|
||||||
FileTypeManager.getInstance().associateExtension(ArchiveFileType.INSTANCE, KLIB_FILE_EXTENSION)
|
FileTypeManager.getInstance().associateExtension(ArchiveFileType.INSTANCE, KLIB_FILE_EXTENSION)
|
||||||
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.resolve.konan.platform.KonanPlatform
|
|||||||
import org.jetbrains.kotlin.serialization.konan.KonanResolvedModuleDescriptors
|
import org.jetbrains.kotlin.serialization.konan.KonanResolvedModuleDescriptors
|
||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
|
|
||||||
const val KONAN_CURRENT_ABI_VERSION = 1
|
const val KOTLIN_NATIVE_CURRENT_ABI_VERSION = 1
|
||||||
|
|
||||||
fun createFileStub(project: Project, text: String): PsiFileStub<*> {
|
fun createFileStub(project: Project, text: String): PsiFileStub<*> {
|
||||||
val virtualFile = LightVirtualFile("dummy.kt", KotlinFileType.INSTANCE, text)
|
val virtualFile = LightVirtualFile("dummy.kt", KotlinFileType.INSTANCE, text)
|
||||||
@@ -41,13 +41,12 @@ fun createFileStub(project: Project, text: String): PsiFileStub<*> {
|
|||||||
fun createLoggingErrorReporter(log: Logger) = LoggingErrorReporter(log)
|
fun createLoggingErrorReporter(log: Logger) = LoggingErrorReporter(log)
|
||||||
|
|
||||||
fun ModuleInfo.createResolvedModuleDescriptors(
|
fun ModuleInfo.createResolvedModuleDescriptors(
|
||||||
project: Project,
|
|
||||||
storageManager: StorageManager,
|
storageManager: StorageManager,
|
||||||
builtIns: KotlinBuiltIns,
|
builtIns: KotlinBuiltIns,
|
||||||
languageVersionSettings: LanguageVersionSettings
|
languageVersionSettings: LanguageVersionSettings
|
||||||
): KonanResolvedModuleDescriptors {
|
): KonanResolvedModuleDescriptors {
|
||||||
|
|
||||||
// This is to preserve "capabilities" from the original IntelliJ LibraryInfo:
|
// This is to preserve "capabilities" from the original IDEA LibraryInfo:
|
||||||
val libraryMap =
|
val libraryMap =
|
||||||
this.dependencies().filterIsInstance<LibraryInfo>().flatMap { dependency ->
|
this.dependencies().filterIsInstance<LibraryInfo>().flatMap { dependency ->
|
||||||
if (dependency.platform == KonanPlatform) {
|
if (dependency.platform == KonanPlatform) {
|
||||||
@@ -62,7 +61,7 @@ fun ModuleInfo.createResolvedModuleDescriptors(
|
|||||||
val libraryPaths = libraryMap.keys.toList()
|
val libraryPaths = libraryMap.keys.toList()
|
||||||
|
|
||||||
val resolvedLibraries = KotlinNativePluginSearchPathResolver(libraryPaths)
|
val resolvedLibraries = KotlinNativePluginSearchPathResolver(libraryPaths)
|
||||||
.libraryResolver(KONAN_CURRENT_ABI_VERSION)
|
.libraryResolver(KOTLIN_NATIVE_CURRENT_ABI_VERSION)
|
||||||
.resolveWithDependencies(libraryPaths)
|
.resolveWithDependencies(libraryPaths)
|
||||||
|
|
||||||
return DefaultResolvedDescriptorsFactory.createResolved(
|
return DefaultResolvedDescriptorsFactory.createResolved(
|
||||||
@@ -71,6 +70,6 @@ fun ModuleInfo.createResolvedModuleDescriptors(
|
|||||||
builtIns,
|
builtIns,
|
||||||
languageVersionSettings,
|
languageVersionSettings,
|
||||||
null
|
null
|
||||||
// This is to preserve "capabilities" from the original IntelliJ LibraryInfo:
|
// This is to preserve "capabilities" from the original IDEA LibraryInfo:
|
||||||
) { konanLibrary -> libraryMap[konanLibrary.libraryFile.path]?.capabilities ?: emptyMap() }
|
) { library -> libraryMap[library.libraryFile.path]?.capabilities ?: emptyMap() }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ private fun createKotlinNativeBuiltIns(projectContext: ProjectContext): KotlinBu
|
|||||||
if (stdlib != null) {
|
if (stdlib != null) {
|
||||||
|
|
||||||
val (path, libraryInfo) = stdlib
|
val (path, libraryInfo) = stdlib
|
||||||
val library = createKonanLibrary(File(path), KONAN_CURRENT_ABI_VERSION)
|
val library = createKonanLibrary(File(path), KOTLIN_NATIVE_CURRENT_ABI_VERSION)
|
||||||
|
|
||||||
val builtInsModule = DefaultDeserializedDescriptorFactory.createDescriptorAndNewBuiltIns(
|
val builtInsModule = DefaultDeserializedDescriptorFactory.createDescriptorAndNewBuiltIns(
|
||||||
library,
|
library,
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ object NativeAnalyzerFacade : ResolverForModuleFactory() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
val moduleDescriptors = moduleContent.moduleInfo.createResolvedModuleDescriptors(
|
val moduleDescriptors = moduleContent.moduleInfo.createResolvedModuleDescriptors(
|
||||||
moduleContext.project,
|
|
||||||
moduleContext.storageManager,
|
moduleContext.storageManager,
|
||||||
moduleContext.module.builtIns,
|
moduleContext.module.builtIns,
|
||||||
languageVersionSettings
|
languageVersionSettings
|
||||||
|
|||||||
+2
-2
@@ -3,12 +3,12 @@
|
|||||||
* that can be found in the license/LICENSE.txt file.
|
* that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.konan
|
package org.jetbrains.kotlin.ide.konan.decompiler
|
||||||
|
|
||||||
import com.intellij.openapi.vfs.VirtualFile
|
import com.intellij.openapi.vfs.VirtualFile
|
||||||
import org.jetbrains.kotlin.idea.decompiler.KotlinDecompiledFileViewProvider
|
import org.jetbrains.kotlin.idea.decompiler.KotlinDecompiledFileViewProvider
|
||||||
import org.jetbrains.kotlin.idea.decompiler.KtDecompiledFile
|
import org.jetbrains.kotlin.idea.decompiler.KtDecompiledFile
|
||||||
import org.jetbrains.kotlin.idea.decompiler.textBuilder.DecompiledText
|
import org.jetbrains.kotlin.idea.decompiler.textBuilder.DecompiledText
|
||||||
|
|
||||||
class KonanDecompiledFile(provider: KotlinDecompiledFileViewProvider, text: (VirtualFile) -> DecompiledText) :
|
class KotlinNativeDecompiledFile(provider: KotlinDecompiledFileViewProvider, text: (VirtualFile) -> DecompiledText) :
|
||||||
KtDecompiledFile(provider, text)
|
KtDecompiledFile(provider, text)
|
||||||
+4
-4
@@ -3,7 +3,7 @@
|
|||||||
* that can be found in the license/LICENSE.txt file.
|
* that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.konan.analyser.index
|
package org.jetbrains.kotlin.ide.konan.decompiler
|
||||||
|
|
||||||
import com.intellij.openapi.application.ApplicationManager
|
import com.intellij.openapi.application.ApplicationManager
|
||||||
import com.intellij.openapi.components.ApplicationComponent
|
import com.intellij.openapi.components.ApplicationComponent
|
||||||
@@ -12,12 +12,12 @@ import com.intellij.util.containers.ContainerUtil.createConcurrentWeakValueMap
|
|||||||
import org.jetbrains.kotlin.metadata.konan.KonanProtoBuf
|
import org.jetbrains.kotlin.metadata.konan.KonanProtoBuf
|
||||||
import org.jetbrains.kotlin.serialization.konan.parsePackageFragment
|
import org.jetbrains.kotlin.serialization.konan.parsePackageFragment
|
||||||
|
|
||||||
class KonanDescriptorManager : ApplicationComponent {
|
class KotlinNativeDescriptorManager : ApplicationComponent {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getInstance(): KonanDescriptorManager = ApplicationManager.getApplication().getComponent(KonanDescriptorManager::class.java)
|
fun getInstance(): KotlinNativeDescriptorManager =
|
||||||
|
ApplicationManager.getApplication().getComponent(KotlinNativeDescriptorManager::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val protoCache = createConcurrentWeakValueMap<VirtualFile, KonanProtoBuf.LinkDataPackageFragment>()
|
private val protoCache = createConcurrentWeakValueMap<VirtualFile, KonanProtoBuf.LinkDataPackageFragment>()
|
||||||
+4
-4
@@ -3,12 +3,12 @@
|
|||||||
* that can be found in the license/LICENSE.txt file.
|
* that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.konan.analyser.index;
|
package org.jetbrains.kotlin.ide.konan.decompiler;
|
||||||
|
|
||||||
import org.jetbrains.kotlin.idea.util.KotlinBinaryExtension;
|
import org.jetbrains.kotlin.idea.util.KotlinBinaryExtension;
|
||||||
|
|
||||||
public class KonanMetaBinary extends KotlinBinaryExtension {
|
public class KotlinNativeMetaBinary extends KotlinBinaryExtension {
|
||||||
public KonanMetaBinary() {
|
public KotlinNativeMetaBinary() {
|
||||||
super(KonanMetaFileType.INSTANCE);
|
super(KotlinNativeMetaFileType.INSTANCE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+13
-11
@@ -3,7 +3,7 @@
|
|||||||
* that can be found in the license/LICENSE.txt file.
|
* that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.konan.analyser.index
|
package org.jetbrains.kotlin.ide.konan.decompiler
|
||||||
|
|
||||||
import com.intellij.openapi.fileTypes.FileType
|
import com.intellij.openapi.fileTypes.FileType
|
||||||
import com.intellij.openapi.fileTypes.FileTypeConsumer
|
import com.intellij.openapi.fileTypes.FileTypeConsumer
|
||||||
@@ -15,30 +15,32 @@ import org.jetbrains.kotlin.resolve.konan.platform.KonanPlatform
|
|||||||
import org.jetbrains.kotlin.serialization.konan.KonanSerializerProtocol
|
import org.jetbrains.kotlin.serialization.konan.KonanSerializerProtocol
|
||||||
import org.jetbrains.kotlin.serialization.konan.NullFlexibleTypeDeserializer
|
import org.jetbrains.kotlin.serialization.konan.NullFlexibleTypeDeserializer
|
||||||
|
|
||||||
class KonanMetadataDecompiler : KonanMetadataDecompilerBase<KonanMetadataVersion>(
|
class KotlinNativeMetadataDecompiler : KotlinNativeMetadataDecompilerBase<KotlinNativeMetadataVersion>(
|
||||||
KonanMetaFileType, KonanPlatform, KonanSerializerProtocol, NullFlexibleTypeDeserializer,
|
KotlinNativeMetaFileType, KonanPlatform, KonanSerializerProtocol, NullFlexibleTypeDeserializer,
|
||||||
KonanMetadataVersion.DEFAULT_INSTANCE, KonanMetadataVersion.INVALID_VERSION, KonanMetaFileType.STUB_VERSION
|
KotlinNativeMetadataVersion.DEFAULT_INSTANCE,
|
||||||
|
KotlinNativeMetadataVersion.INVALID_VERSION,
|
||||||
|
KotlinNativeMetaFileType.STUB_VERSION
|
||||||
) {
|
) {
|
||||||
|
|
||||||
override fun doReadFile(file: VirtualFile): FileWithMetadata? {
|
override fun doReadFile(file: VirtualFile): FileWithMetadata? {
|
||||||
val proto = KonanDescriptorManager.getInstance().getCachedPackageFragment(file)
|
val proto = KotlinNativeDescriptorManager.getInstance().getCachedPackageFragment(file)
|
||||||
return FileWithMetadata.Compatible(proto, KonanSerializerProtocol) //todo: check version compatibility
|
return FileWithMetadata.Compatible(proto, KonanSerializerProtocol) //todo: check version compatibility
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class KonanMetadataVersion(vararg numbers: Int) : BinaryVersion(*numbers) {
|
class KotlinNativeMetadataVersion(vararg numbers: Int) : BinaryVersion(*numbers) {
|
||||||
override fun isCompatible(): Boolean = true //todo: ?
|
override fun isCompatible(): Boolean = true //todo: ?
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@JvmField
|
@JvmField
|
||||||
val DEFAULT_INSTANCE = KonanMetadataVersion(1, 1, 0)
|
val DEFAULT_INSTANCE = KotlinNativeMetadataVersion(1, 1, 0)
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val INVALID_VERSION = KonanMetadataVersion()
|
val INVALID_VERSION = KotlinNativeMetadataVersion()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object KonanMetaFileType : FileType {
|
object KotlinNativeMetaFileType : FileType {
|
||||||
override fun getName() = "KNM"
|
override fun getName() = "KNM"
|
||||||
override fun getDescription() = "Kotlin/Native Metadata"
|
override fun getDescription() = "Kotlin/Native Metadata"
|
||||||
override fun getDefaultExtension() = KLIB_METADATA_FILE_EXTENSION
|
override fun getDefaultExtension() = KLIB_METADATA_FILE_EXTENSION
|
||||||
@@ -50,7 +52,7 @@ object KonanMetaFileType : FileType {
|
|||||||
const val STUB_VERSION = 2
|
const val STUB_VERSION = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
class KonanMetaFileTypeFactory : FileTypeFactory() {
|
class KotlinNativeMetaFileTypeFactory : FileTypeFactory() {
|
||||||
|
|
||||||
override fun createFileTypes(consumer: FileTypeConsumer) = consumer.consume(KonanMetaFileType, KonanMetaFileType.defaultExtension)
|
override fun createFileTypes(consumer: FileTypeConsumer) = consumer.consume(KotlinNativeMetaFileType, KotlinNativeMetaFileType.defaultExtension)
|
||||||
}
|
}
|
||||||
+24
-9
@@ -3,13 +3,12 @@
|
|||||||
* that can be found in the license/LICENSE.txt file.
|
* that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.konan.analyser.index
|
package org.jetbrains.kotlin.ide.konan.decompiler
|
||||||
|
|
||||||
import com.intellij.openapi.fileTypes.FileType
|
import com.intellij.openapi.fileTypes.FileType
|
||||||
import com.intellij.openapi.vfs.VirtualFile
|
import com.intellij.openapi.vfs.VirtualFile
|
||||||
import com.intellij.psi.PsiManager
|
import com.intellij.psi.PsiManager
|
||||||
import com.intellij.psi.compiled.ClassFileDecompilers
|
import com.intellij.psi.compiled.ClassFileDecompilers
|
||||||
import org.jetbrains.konan.KonanDecompiledFile
|
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
import org.jetbrains.kotlin.idea.decompiler.KotlinDecompiledFileViewProvider
|
import org.jetbrains.kotlin.idea.decompiler.KotlinDecompiledFileViewProvider
|
||||||
import org.jetbrains.kotlin.idea.decompiler.common.createIncompatibleAbiVersionDecompiledText
|
import org.jetbrains.kotlin.idea.decompiler.common.createIncompatibleAbiVersionDecompiledText
|
||||||
@@ -30,8 +29,7 @@ import org.jetbrains.kotlin.serialization.deserialization.getClassId
|
|||||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
//todo: Fix in Kotlin plugin
|
abstract class KotlinNativeMetadataDecompilerBase<out V : BinaryVersion>(
|
||||||
abstract class KonanMetadataDecompilerBase<out V : BinaryVersion>(
|
|
||||||
private val fileType: FileType,
|
private val fileType: FileType,
|
||||||
private val targetPlatform: TargetPlatform,
|
private val targetPlatform: TargetPlatform,
|
||||||
private val serializerProtocol: SerializerExtensionProtocol,
|
private val serializerProtocol: SerializerExtensionProtocol,
|
||||||
@@ -41,7 +39,13 @@ abstract class KonanMetadataDecompilerBase<out V : BinaryVersion>(
|
|||||||
stubVersion: Int
|
stubVersion: Int
|
||||||
) : ClassFileDecompilers.Full() {
|
) : ClassFileDecompilers.Full() {
|
||||||
|
|
||||||
private val stubBuilder = KonanMetadataStubBuilder(stubVersion, fileType, serializerProtocol, ::readFileSafely)
|
private val stubBuilder =
|
||||||
|
KotlinNativeMetadataStubBuilder(
|
||||||
|
stubVersion,
|
||||||
|
fileType,
|
||||||
|
serializerProtocol,
|
||||||
|
::readFileSafely
|
||||||
|
)
|
||||||
|
|
||||||
private val renderer = DescriptorRenderer.withOptions { defaultDecompilerRendererOptions() }
|
private val renderer = DescriptorRenderer.withOptions { defaultDecompilerRendererOptions() }
|
||||||
|
|
||||||
@@ -52,7 +56,12 @@ abstract class KonanMetadataDecompilerBase<out V : BinaryVersion>(
|
|||||||
override fun getStubBuilder() = stubBuilder
|
override fun getStubBuilder() = stubBuilder
|
||||||
|
|
||||||
override fun createFileViewProvider(file: VirtualFile, manager: PsiManager, physical: Boolean) =
|
override fun createFileViewProvider(file: VirtualFile, manager: PsiManager, physical: Boolean) =
|
||||||
KotlinDecompiledFileViewProvider(manager, file, physical) { provider -> KonanDecompiledFile(provider, ::buildDecompiledText) }
|
KotlinDecompiledFileViewProvider(manager, file, physical) { provider ->
|
||||||
|
KotlinNativeDecompiledFile(
|
||||||
|
provider,
|
||||||
|
::buildDecompiledText
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
private fun readFileSafely(file: VirtualFile): FileWithMetadata? {
|
private fun readFileSafely(file: VirtualFile): FileWithMetadata? {
|
||||||
if (!file.isValid) return null
|
if (!file.isValid) return null
|
||||||
@@ -75,7 +84,13 @@ abstract class KonanMetadataDecompilerBase<out V : BinaryVersion>(
|
|||||||
|
|
||||||
return when (file) {
|
return when (file) {
|
||||||
is FileWithMetadata.Incompatible -> createIncompatibleAbiVersionDecompiledText(expectedBinaryVersion, file.version)
|
is FileWithMetadata.Incompatible -> createIncompatibleAbiVersionDecompiledText(expectedBinaryVersion, file.version)
|
||||||
is FileWithMetadata.Compatible -> decompiledText(file, targetPlatform, serializerProtocol, flexibleTypeDeserializer, renderer)
|
is FileWithMetadata.Compatible -> decompiledText(
|
||||||
|
file,
|
||||||
|
targetPlatform,
|
||||||
|
serializerProtocol,
|
||||||
|
flexibleTypeDeserializer,
|
||||||
|
renderer
|
||||||
|
)
|
||||||
null -> createIncompatibleAbiVersionDecompiledText(expectedBinaryVersion, invalidBinaryVersion)
|
null -> createIncompatibleAbiVersionDecompiledText(expectedBinaryVersion, invalidBinaryVersion)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -99,7 +114,7 @@ sealed class FileWithMetadata {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo: this function is extracted for KonanMetadataStubBuilder, that's the difference from Big Kotlin.
|
//todo: this function is extracted for KotlinNativeMetadataStubBuilder, that's the difference from Big Kotlin.
|
||||||
fun decompiledText(
|
fun decompiledText(
|
||||||
file: FileWithMetadata.Compatible, targetPlatform: TargetPlatform,
|
file: FileWithMetadata.Compatible, targetPlatform: TargetPlatform,
|
||||||
serializerProtocol: SerializerExtensionProtocol,
|
serializerProtocol: SerializerExtensionProtocol,
|
||||||
@@ -107,7 +122,7 @@ fun decompiledText(
|
|||||||
renderer: DescriptorRenderer
|
renderer: DescriptorRenderer
|
||||||
): DecompiledText {
|
): DecompiledText {
|
||||||
val packageFqName = file.packageFqName
|
val packageFqName = file.packageFqName
|
||||||
val resolver = KonanMetadataDeserializerForDecompiler(
|
val resolver = KotlinNativeMetadataDeserializerForDecompiler(
|
||||||
packageFqName, file.proto, file.nameResolver,
|
packageFqName, file.proto, file.nameResolver,
|
||||||
targetPlatform, serializerProtocol, flexibleTypeDeserializer
|
targetPlatform, serializerProtocol, flexibleTypeDeserializer
|
||||||
)
|
)
|
||||||
+6
-6
@@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.jetbrains.konan.analyser.index
|
package org.jetbrains.kotlin.ide.konan.decompiler
|
||||||
|
|
||||||
import com.intellij.openapi.diagnostic.Logger
|
import com.intellij.openapi.diagnostic.Logger
|
||||||
import org.jetbrains.kotlin.builtins.DefaultBuiltIns
|
import org.jetbrains.kotlin.builtins.DefaultBuiltIns
|
||||||
@@ -23,8 +23,7 @@ import org.jetbrains.kotlin.serialization.SerializerExtensionProtocol
|
|||||||
import org.jetbrains.kotlin.serialization.deserialization.*
|
import org.jetbrains.kotlin.serialization.deserialization.*
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPackageMemberScope
|
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPackageMemberScope
|
||||||
|
|
||||||
//todo: Fix in Kotlin plugin
|
class KotlinNativeMetadataDeserializerForDecompiler(
|
||||||
class KonanMetadataDeserializerForDecompiler(
|
|
||||||
packageFqName: FqName,
|
packageFqName: FqName,
|
||||||
private val proto: KonanProtoBuf.LinkDataPackageFragment,
|
private val proto: KonanProtoBuf.LinkDataPackageFragment,
|
||||||
private val nameResolver: NameResolver,
|
private val nameResolver: NameResolver,
|
||||||
@@ -40,7 +39,8 @@ class KonanMetadataDeserializerForDecompiler(
|
|||||||
val notFoundClasses = NotFoundClasses(storageManager, moduleDescriptor)
|
val notFoundClasses = NotFoundClasses(storageManager, moduleDescriptor)
|
||||||
|
|
||||||
deserializationComponents = DeserializationComponents(
|
deserializationComponents = DeserializationComponents(
|
||||||
storageManager, moduleDescriptor, DeserializationConfiguration.Default, KonanProtoBasedClassDataFinder(proto, nameResolver),
|
storageManager, moduleDescriptor, DeserializationConfiguration.Default,
|
||||||
|
KotlinNativeProtoBasedClassDataFinder(proto, nameResolver),
|
||||||
AnnotationAndConstantLoaderImpl(moduleDescriptor, notFoundClasses, serializerProtocol), packageFragmentProvider,
|
AnnotationAndConstantLoaderImpl(moduleDescriptor, notFoundClasses, serializerProtocol), packageFragmentProvider,
|
||||||
ResolveEverythingToKotlinAnyLocalClassifierResolver(builtIns), createLoggingErrorReporter(LOG),
|
ResolveEverythingToKotlinAnyLocalClassifierResolver(builtIns), createLoggingErrorReporter(LOG),
|
||||||
LookupTracker.DO_NOTHING, flexibleTypeDeserializer, emptyList(), notFoundClasses, ContractDeserializer.DEFAULT,
|
LookupTracker.DO_NOTHING, flexibleTypeDeserializer, emptyList(), notFoundClasses, ContractDeserializer.DEFAULT,
|
||||||
@@ -57,7 +57,7 @@ class KonanMetadataDeserializerForDecompiler(
|
|||||||
createDummyPackageFragment(facadeFqName),
|
createDummyPackageFragment(facadeFqName),
|
||||||
proto.`package`,
|
proto.`package`,
|
||||||
nameResolver,
|
nameResolver,
|
||||||
KonanMetadataVersion.DEFAULT_INSTANCE,
|
KotlinNativeMetadataVersion.DEFAULT_INSTANCE,
|
||||||
containerSource = null,
|
containerSource = null,
|
||||||
components = deserializationComponents
|
components = deserializationComponents
|
||||||
) { emptyList() }
|
) { emptyList() }
|
||||||
@@ -66,7 +66,7 @@ class KonanMetadataDeserializerForDecompiler(
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val LOG = Logger.getInstance(KonanMetadataDeserializerForDecompiler::class.java)
|
private val LOG = Logger.getInstance(KotlinNativeMetadataDeserializerForDecompiler::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+11
-4
@@ -3,7 +3,7 @@
|
|||||||
* that can be found in the license/LICENSE.txt file.
|
* that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.konan.analyser.index
|
package org.jetbrains.kotlin.ide.konan.decompiler
|
||||||
|
|
||||||
import com.intellij.openapi.fileTypes.FileType
|
import com.intellij.openapi.fileTypes.FileType
|
||||||
import com.intellij.openapi.vfs.VirtualFile
|
import com.intellij.openapi.vfs.VirtualFile
|
||||||
@@ -12,6 +12,8 @@ import com.intellij.psi.impl.compiled.ClassFileStubBuilder
|
|||||||
import com.intellij.psi.stubs.PsiFileStub
|
import com.intellij.psi.stubs.PsiFileStub
|
||||||
import com.intellij.util.indexing.FileContent
|
import com.intellij.util.indexing.FileContent
|
||||||
import org.jetbrains.kotlin.ide.konan.createFileStub
|
import org.jetbrains.kotlin.ide.konan.createFileStub
|
||||||
|
import org.jetbrains.kotlin.ide.konan.decompiler.FileWithMetadata
|
||||||
|
import org.jetbrains.kotlin.ide.konan.decompiler.decompiledText
|
||||||
import org.jetbrains.kotlin.idea.decompiler.stubBuilder.createIncompatibleAbiVersionFileStub
|
import org.jetbrains.kotlin.idea.decompiler.stubBuilder.createIncompatibleAbiVersionFileStub
|
||||||
import org.jetbrains.kotlin.idea.decompiler.textBuilder.defaultDecompilerRendererOptions
|
import org.jetbrains.kotlin.idea.decompiler.textBuilder.defaultDecompilerRendererOptions
|
||||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||||
@@ -19,8 +21,7 @@ import org.jetbrains.kotlin.resolve.konan.platform.KonanPlatform
|
|||||||
import org.jetbrains.kotlin.serialization.SerializerExtensionProtocol
|
import org.jetbrains.kotlin.serialization.SerializerExtensionProtocol
|
||||||
import org.jetbrains.kotlin.serialization.konan.NullFlexibleTypeDeserializer
|
import org.jetbrains.kotlin.serialization.konan.NullFlexibleTypeDeserializer
|
||||||
|
|
||||||
//todo: Fix in Kotlin plugin
|
open class KotlinNativeMetadataStubBuilder(
|
||||||
open class KonanMetadataStubBuilder(
|
|
||||||
private val version: Int,
|
private val version: Int,
|
||||||
private val fileType: FileType,
|
private val fileType: FileType,
|
||||||
private val serializerProtocol: SerializerExtensionProtocol,
|
private val serializerProtocol: SerializerExtensionProtocol,
|
||||||
@@ -39,7 +40,13 @@ open class KonanMetadataStubBuilder(
|
|||||||
is FileWithMetadata.Incompatible -> createIncompatibleAbiVersionFileStub()
|
is FileWithMetadata.Incompatible -> createIncompatibleAbiVersionFileStub()
|
||||||
is FileWithMetadata.Compatible -> { //todo: this part is implemented in our own way
|
is FileWithMetadata.Compatible -> { //todo: this part is implemented in our own way
|
||||||
val renderer = DescriptorRenderer.withOptions { defaultDecompilerRendererOptions() }
|
val renderer = DescriptorRenderer.withOptions { defaultDecompilerRendererOptions() }
|
||||||
val ktFileText = decompiledText(file, KonanPlatform, serializerProtocol, NullFlexibleTypeDeserializer, renderer)
|
val ktFileText = decompiledText(
|
||||||
|
file,
|
||||||
|
KonanPlatform,
|
||||||
|
serializerProtocol,
|
||||||
|
NullFlexibleTypeDeserializer,
|
||||||
|
renderer
|
||||||
|
)
|
||||||
createFileStub(content.project, ktFileText.text)
|
createFileStub(content.project, ktFileText.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+3
-4
@@ -3,7 +3,7 @@
|
|||||||
* that can be found in the license/LICENSE.txt file.
|
* that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.konan.analyser.index
|
package org.jetbrains.kotlin.ide.konan.decompiler
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||||
import org.jetbrains.kotlin.metadata.deserialization.NameResolver
|
import org.jetbrains.kotlin.metadata.deserialization.NameResolver
|
||||||
@@ -13,8 +13,7 @@ import org.jetbrains.kotlin.serialization.deserialization.ClassData
|
|||||||
import org.jetbrains.kotlin.serialization.deserialization.ClassDataFinder
|
import org.jetbrains.kotlin.serialization.deserialization.ClassDataFinder
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.getClassId
|
import org.jetbrains.kotlin.serialization.deserialization.getClassId
|
||||||
|
|
||||||
//todo: Fix in Kotlin plugin
|
class KotlinNativeProtoBasedClassDataFinder(
|
||||||
class KonanProtoBasedClassDataFinder(
|
|
||||||
proto: KonanProtoBuf.LinkDataPackageFragment,
|
proto: KonanProtoBuf.LinkDataPackageFragment,
|
||||||
private val nameResolver: NameResolver,
|
private val nameResolver: NameResolver,
|
||||||
private val classSource: (ClassId) -> SourceElement = { SourceElement.NO_SOURCE }
|
private val classSource: (ClassId) -> SourceElement = { SourceElement.NO_SOURCE }
|
||||||
@@ -28,6 +27,6 @@ class KonanProtoBasedClassDataFinder(
|
|||||||
|
|
||||||
override fun findClassData(classId: ClassId): ClassData? {
|
override fun findClassData(classId: ClassId): ClassData? {
|
||||||
val classProto = classIdToProto[classId] ?: return null
|
val classProto = classIdToProto[classId] ?: return null
|
||||||
return ClassData(nameResolver, classProto, KonanMetadataVersion.DEFAULT_INSTANCE, classSource(classId))
|
return ClassData(nameResolver, classProto, KotlinNativeMetadataVersion.DEFAULT_INSTANCE, classSource(classId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+6
-6
@@ -6,8 +6,8 @@
|
|||||||
package org.jetbrains.kotlin.ide.konan.index
|
package org.jetbrains.kotlin.ide.konan.index
|
||||||
|
|
||||||
import com.intellij.util.indexing.FileBasedIndex
|
import com.intellij.util.indexing.FileBasedIndex
|
||||||
import org.jetbrains.konan.analyser.index.KonanDescriptorManager
|
import org.jetbrains.kotlin.ide.konan.decompiler.KotlinNativeDescriptorManager
|
||||||
import org.jetbrains.konan.analyser.index.KonanMetaFileType
|
import org.jetbrains.kotlin.ide.konan.decompiler.KotlinNativeMetaFileType
|
||||||
import org.jetbrains.kotlin.idea.vfilefinder.KotlinFileIndexBase
|
import org.jetbrains.kotlin.idea.vfilefinder.KotlinFileIndexBase
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
|
||||||
@@ -15,18 +15,18 @@ object KotlinNativeMetaFileIndex : KotlinFileIndexBase<KotlinNativeMetaFileIndex
|
|||||||
|
|
||||||
override fun getIndexer() = INDEXER
|
override fun getIndexer() = INDEXER
|
||||||
|
|
||||||
override fun getInputFilter() = FileBasedIndex.InputFilter { it.fileType === KonanMetaFileType }
|
override fun getInputFilter() = FileBasedIndex.InputFilter { it.fileType === KotlinNativeMetaFileType }
|
||||||
|
|
||||||
override fun getVersion() = VERSION
|
override fun getVersion() = VERSION
|
||||||
|
|
||||||
// this is to express intention to index all Kotlin/Native metadata files irrespectively to file size
|
// This is to express intention to index all Kotlin/Native metadata files irrespectively to file size:
|
||||||
override fun getFileTypesWithSizeLimitNotApplicable() = listOf(KonanMetaFileType)
|
override fun getFileTypesWithSizeLimitNotApplicable() = listOf(KotlinNativeMetaFileType)
|
||||||
|
|
||||||
private const val VERSION = 4
|
private const val VERSION = 4
|
||||||
|
|
||||||
/*todo: check version?!*/
|
/*todo: check version?!*/
|
||||||
private val INDEXER = indexer { fileContent ->
|
private val INDEXER = indexer { fileContent ->
|
||||||
val fragment = KonanDescriptorManager.getInstance().getCachedPackageFragment(fileContent.file)
|
val fragment = KotlinNativeDescriptorManager.getInstance().getCachedPackageFragment(fileContent.file)
|
||||||
FqName(fragment.fqName)
|
FqName(fragment.fqName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<!-- NATIVE PART -->
|
<!-- NATIVE PART -->
|
||||||
<application-components>
|
<application-components>
|
||||||
<component>
|
<component>
|
||||||
<implementation-class>org.jetbrains.konan.gradle.internal.KotlinNativeIdeInitializer</implementation-class>
|
<implementation-class>org.jetbrains.kotlin.ide.konan.gradle.KotlinNativeIdeInitializer</implementation-class>
|
||||||
</component>
|
</component>
|
||||||
</application-components>
|
</application-components>
|
||||||
<!-- /NATIVE PART -->
|
<!-- /NATIVE PART -->
|
||||||
|
|||||||
@@ -1,26 +1,26 @@
|
|||||||
<idea-plugin xmlns:xi="http://www.w3.org/2001/XInclude">
|
<idea-plugin xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||||
<application-components>
|
<application-components>
|
||||||
<component>
|
<component>
|
||||||
<implementation-class>org.jetbrains.konan.KonanApplicationComponent</implementation-class>
|
<implementation-class>org.jetbrains.kotlin.ide.konan.KotlinNativeApplicationComponent</implementation-class>
|
||||||
</component>
|
</component>
|
||||||
<component>
|
<component>
|
||||||
<implementation-class>org.jetbrains.konan.analyser.index.KonanDescriptorManager</implementation-class>
|
<implementation-class>org.jetbrains.kotlin.ide.konan.decompiler.KotlinNativeDescriptorManager</implementation-class>
|
||||||
</component>
|
</component>
|
||||||
</application-components>
|
</application-components>
|
||||||
|
|
||||||
<extensions defaultExtensionNs="com.intellij">
|
<extensions defaultExtensionNs="com.intellij">
|
||||||
<psi.classFileDecompiler implementation="org.jetbrains.konan.analyser.index.KonanMetadataDecompiler"/>
|
<psi.classFileDecompiler implementation="org.jetbrains.kotlin.ide.konan.decompiler.KotlinNativeMetadataDecompiler"/>
|
||||||
|
|
||||||
<fileType.fileViewProviderFactory filetype="KNM"
|
<fileType.fileViewProviderFactory filetype="KNM"
|
||||||
implementationClass="com.intellij.psi.ClassFileViewProviderFactory"/>
|
implementationClass="com.intellij.psi.ClassFileViewProviderFactory"/>
|
||||||
<filetype.stubBuilder filetype="KNM" implementationClass="com.intellij.psi.impl.compiled.ClassFileStubBuilder"/>
|
<filetype.stubBuilder filetype="KNM" implementationClass="com.intellij.psi.impl.compiled.ClassFileStubBuilder"/>
|
||||||
<filetype.decompiler filetype="KNM" implementationClass="com.intellij.psi.impl.compiled.ClassFileDecompiler"/>
|
<filetype.decompiler filetype="KNM" implementationClass="com.intellij.psi.impl.compiled.ClassFileDecompiler"/>
|
||||||
<fileTypeFactory implementation="org.jetbrains.konan.analyser.index.KonanMetaFileTypeFactory"/>
|
<fileTypeFactory implementation="org.jetbrains.kotlin.ide.konan.decompiler.KotlinNativeMetaFileTypeFactory"/>
|
||||||
<fileBasedIndex implementation="org.jetbrains.kotlin.ide.konan.index.KotlinNativeMetaFileIndex"/>
|
<fileBasedIndex implementation="org.jetbrains.kotlin.ide.konan.index.KotlinNativeMetaFileIndex"/>
|
||||||
</extensions>
|
</extensions>
|
||||||
|
|
||||||
<extensions defaultExtensionNs="org.jetbrains.kotlin">
|
<extensions defaultExtensionNs="org.jetbrains.kotlin">
|
||||||
<binaryExtension implementation="org.jetbrains.konan.analyser.index.KonanMetaBinary"/>
|
<binaryExtension implementation="org.jetbrains.kotlin.ide.konan.decompiler.KotlinNativeMetaBinary"/>
|
||||||
<idePlatformKind implementation="org.jetbrains.kotlin.ide.konan.NativeIdePlatformKind"/>
|
<idePlatformKind implementation="org.jetbrains.kotlin.ide.konan.NativeIdePlatformKind"/>
|
||||||
<idePlatformKindTooling implementation="org.jetbrains.kotlin.ide.konan.NativeIdePlatformKindTooling"/>
|
<idePlatformKindTooling implementation="org.jetbrains.kotlin.ide.konan.NativeIdePlatformKindTooling"/>
|
||||||
<idePlatformKindResolution implementation="org.jetbrains.kotlin.ide.konan.NativePlatformKindResolution"/>
|
<idePlatformKindResolution implementation="org.jetbrains.kotlin.ide.konan.NativePlatformKindResolution"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user