From f663c0ea87367e31ae230d93d6d65b5c57bd7c4b Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Fri, 7 Sep 2018 14:20:46 +0300 Subject: [PATCH] Rename "Konan" -> "KotlinNative" in class and function names (part 3) --- .../gradle}/KotlinNativeIdeInitializer.java | 2 +- .../KotlinNativeApplicationComponent.kt} | 7 ++-- .../ide/konan/KotlinNativePluginUtil.kt | 11 +++---- .../ide/konan/NativePlatformKindResolution.kt | 2 +- .../konan/analyzer/NativeAnalyzerFacade.kt | 1 - .../decompiler/KotlinNativeDecompiledFile.kt} | 4 +-- .../KotlinNativeDescriptorManager.kt} | 8 ++--- .../decompiler/KotlinNativeMetaBinary.java} | 8 ++--- .../KotlinNativeMetadataDecompiler.kt} | 24 +++++++------- .../KotlinNativeMetadataDecompilerBase.kt} | 33 ++++++++++++++----- ...ativeMetadataDeserializerForDecompiler.kt} | 12 +++---- .../KotlinNativeMetadataStubBuilder.kt} | 15 ++++++--- .../KotlinNativeProtoBasedClassDataFinder.kt} | 7 ++-- .../konan/index/KotlinNativeMetaFileIndex.kt | 12 +++---- idea/src/META-INF/gradle.xml | 2 +- idea/src/META-INF/native.xml | 10 +++--- 16 files changed, 90 insertions(+), 68 deletions(-) rename idea/idea-gradle-native/src/org/jetbrains/{konan/gradle/internal => kotlin/ide/konan/gradle}/KotlinNativeIdeInitializer.java (96%) rename idea/idea-native/src/org/jetbrains/{konan/KonanApplicationComponent.kt => kotlin/ide/konan/KotlinNativeApplicationComponent.kt} (84%) rename idea/idea-native/src/org/jetbrains/{konan/KonanDecompiledFile.kt => kotlin/ide/konan/decompiler/KotlinNativeDecompiledFile.kt} (73%) rename idea/idea-native/src/org/jetbrains/{konan/analyser/index/KonanDescriptorManager.kt => kotlin/ide/konan/decompiler/KotlinNativeDescriptorManager.kt} (86%) rename idea/idea-native/src/org/jetbrains/{konan/analyser/index/KonanMetaBinary.java => kotlin/ide/konan/decompiler/KotlinNativeMetaBinary.java} (53%) rename idea/idea-native/src/org/jetbrains/{konan/analyser/index/KonanMetadataDecompiler.kt => kotlin/ide/konan/decompiler/KotlinNativeMetadataDecompiler.kt} (62%) rename idea/idea-native/src/org/jetbrains/{konan/analyser/index/KonanMetadataDecompilerBase.kt => kotlin/ide/konan/decompiler/KotlinNativeMetadataDecompilerBase.kt} (85%) rename idea/idea-native/src/org/jetbrains/{konan/analyser/index/KonanMetadataDeserializerForDecompiler.kt => kotlin/ide/konan/decompiler/KotlinNativeMetadataDeserializerForDecompiler.kt} (89%) rename idea/idea-native/src/org/jetbrains/{konan/analyser/index/KonanMetadataStubBuilder.kt => kotlin/ide/konan/decompiler/KotlinNativeMetadataStubBuilder.kt} (80%) rename idea/idea-native/src/org/jetbrains/{konan/analyser/index/KonanProtoBasedClassDataFinder.kt => kotlin/ide/konan/decompiler/KotlinNativeProtoBasedClassDataFinder.kt} (83%) diff --git a/idea/idea-gradle-native/src/org/jetbrains/konan/gradle/internal/KotlinNativeIdeInitializer.java b/idea/idea-gradle-native/src/org/jetbrains/kotlin/ide/konan/gradle/KotlinNativeIdeInitializer.java similarity index 96% rename from idea/idea-gradle-native/src/org/jetbrains/konan/gradle/internal/KotlinNativeIdeInitializer.java rename to idea/idea-gradle-native/src/org/jetbrains/kotlin/ide/konan/gradle/KotlinNativeIdeInitializer.java index 9449b9da21c..fb015b62245 100644 --- a/idea/idea-gradle-native/src/org/jetbrains/konan/gradle/internal/KotlinNativeIdeInitializer.java +++ b/idea/idea-gradle-native/src/org/jetbrains/kotlin/ide/konan/gradle/KotlinNativeIdeInitializer.java @@ -3,7 +3,7 @@ * 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.openapi.components.ApplicationComponent; diff --git a/idea/idea-native/src/org/jetbrains/konan/KonanApplicationComponent.kt b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/KotlinNativeApplicationComponent.kt similarity index 84% rename from idea/idea-native/src/org/jetbrains/konan/KonanApplicationComponent.kt rename to idea/idea-native/src/org/jetbrains/kotlin/ide/konan/KotlinNativeApplicationComponent.kt index dda0750e52d..60ad1639e6c 100644 --- a/idea/idea-native/src/org/jetbrains/konan/KonanApplicationComponent.kt +++ b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/KotlinNativeApplicationComponent.kt @@ -3,7 +3,7 @@ * 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.util.TipAndTrickBean @@ -12,8 +12,9 @@ import com.intellij.openapi.extensions.Extensions import com.intellij.openapi.fileTypes.FileTypeManager import org.jetbrains.kotlin.konan.library.KLIB_FILE_EXTENSION -class KonanApplicationComponent : ApplicationComponent { - override fun getComponentName(): String = "KonanApplicationComponent" +class KotlinNativeApplicationComponent : ApplicationComponent { + + override fun getComponentName(): String = "KotlinNativeApplicationComponent" override fun initComponent() { FileTypeManager.getInstance().associateExtension(ArchiveFileType.INSTANCE, KLIB_FILE_EXTENSION) diff --git a/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/KotlinNativePluginUtil.kt b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/KotlinNativePluginUtil.kt index 6921af96065..148ad7b91b0 100644 --- a/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/KotlinNativePluginUtil.kt +++ b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/KotlinNativePluginUtil.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.resolve.konan.platform.KonanPlatform import org.jetbrains.kotlin.serialization.konan.KonanResolvedModuleDescriptors 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<*> { 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 ModuleInfo.createResolvedModuleDescriptors( - project: Project, storageManager: StorageManager, builtIns: KotlinBuiltIns, languageVersionSettings: LanguageVersionSettings ): KonanResolvedModuleDescriptors { - // This is to preserve "capabilities" from the original IntelliJ LibraryInfo: + // This is to preserve "capabilities" from the original IDEA LibraryInfo: val libraryMap = this.dependencies().filterIsInstance().flatMap { dependency -> if (dependency.platform == KonanPlatform) { @@ -62,7 +61,7 @@ fun ModuleInfo.createResolvedModuleDescriptors( val libraryPaths = libraryMap.keys.toList() val resolvedLibraries = KotlinNativePluginSearchPathResolver(libraryPaths) - .libraryResolver(KONAN_CURRENT_ABI_VERSION) + .libraryResolver(KOTLIN_NATIVE_CURRENT_ABI_VERSION) .resolveWithDependencies(libraryPaths) return DefaultResolvedDescriptorsFactory.createResolved( @@ -71,6 +70,6 @@ fun ModuleInfo.createResolvedModuleDescriptors( builtIns, languageVersionSettings, null - // This is to preserve "capabilities" from the original IntelliJ LibraryInfo: - ) { konanLibrary -> libraryMap[konanLibrary.libraryFile.path]?.capabilities ?: emptyMap() } + // This is to preserve "capabilities" from the original IDEA LibraryInfo: + ) { library -> libraryMap[library.libraryFile.path]?.capabilities ?: emptyMap() } } diff --git a/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/NativePlatformKindResolution.kt b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/NativePlatformKindResolution.kt index faa2e20d097..08f11fbdd68 100644 --- a/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/NativePlatformKindResolution.kt +++ b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/NativePlatformKindResolution.kt @@ -67,7 +67,7 @@ private fun createKotlinNativeBuiltIns(projectContext: ProjectContext): KotlinBu if (stdlib != null) { 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( library, diff --git a/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/analyzer/NativeAnalyzerFacade.kt b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/analyzer/NativeAnalyzerFacade.kt index 5950356c6ea..08190546a6e 100644 --- a/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/analyzer/NativeAnalyzerFacade.kt +++ b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/analyzer/NativeAnalyzerFacade.kt @@ -58,7 +58,6 @@ object NativeAnalyzerFacade : ResolverForModuleFactory() { ) val moduleDescriptors = moduleContent.moduleInfo.createResolvedModuleDescriptors( - moduleContext.project, moduleContext.storageManager, moduleContext.module.builtIns, languageVersionSettings diff --git a/idea/idea-native/src/org/jetbrains/konan/KonanDecompiledFile.kt b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/decompiler/KotlinNativeDecompiledFile.kt similarity index 73% rename from idea/idea-native/src/org/jetbrains/konan/KonanDecompiledFile.kt rename to idea/idea-native/src/org/jetbrains/kotlin/ide/konan/decompiler/KotlinNativeDecompiledFile.kt index a09e4a6e36a..3e4920549ce 100644 --- a/idea/idea-native/src/org/jetbrains/konan/KonanDecompiledFile.kt +++ b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/decompiler/KotlinNativeDecompiledFile.kt @@ -3,12 +3,12 @@ * 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 org.jetbrains.kotlin.idea.decompiler.KotlinDecompiledFileViewProvider import org.jetbrains.kotlin.idea.decompiler.KtDecompiledFile 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) diff --git a/idea/idea-native/src/org/jetbrains/konan/analyser/index/KonanDescriptorManager.kt b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/decompiler/KotlinNativeDescriptorManager.kt similarity index 86% rename from idea/idea-native/src/org/jetbrains/konan/analyser/index/KonanDescriptorManager.kt rename to idea/idea-native/src/org/jetbrains/kotlin/ide/konan/decompiler/KotlinNativeDescriptorManager.kt index 50df01367a1..efdb1b128d0 100644 --- a/idea/idea-native/src/org/jetbrains/konan/analyser/index/KonanDescriptorManager.kt +++ b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/decompiler/KotlinNativeDescriptorManager.kt @@ -3,7 +3,7 @@ * 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.components.ApplicationComponent @@ -12,12 +12,12 @@ import com.intellij.util.containers.ContainerUtil.createConcurrentWeakValueMap import org.jetbrains.kotlin.metadata.konan.KonanProtoBuf import org.jetbrains.kotlin.serialization.konan.parsePackageFragment -class KonanDescriptorManager : ApplicationComponent { +class KotlinNativeDescriptorManager : ApplicationComponent { companion object { - @JvmStatic - fun getInstance(): KonanDescriptorManager = ApplicationManager.getApplication().getComponent(KonanDescriptorManager::class.java) + fun getInstance(): KotlinNativeDescriptorManager = + ApplicationManager.getApplication().getComponent(KotlinNativeDescriptorManager::class.java) } private val protoCache = createConcurrentWeakValueMap() diff --git a/idea/idea-native/src/org/jetbrains/konan/analyser/index/KonanMetaBinary.java b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/decompiler/KotlinNativeMetaBinary.java similarity index 53% rename from idea/idea-native/src/org/jetbrains/konan/analyser/index/KonanMetaBinary.java rename to idea/idea-native/src/org/jetbrains/kotlin/ide/konan/decompiler/KotlinNativeMetaBinary.java index 839a19e8d02..14bc9be30cb 100644 --- a/idea/idea-native/src/org/jetbrains/konan/analyser/index/KonanMetaBinary.java +++ b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/decompiler/KotlinNativeMetaBinary.java @@ -3,12 +3,12 @@ * 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; -public class KonanMetaBinary extends KotlinBinaryExtension { - public KonanMetaBinary() { - super(KonanMetaFileType.INSTANCE); +public class KotlinNativeMetaBinary extends KotlinBinaryExtension { + public KotlinNativeMetaBinary() { + super(KotlinNativeMetaFileType.INSTANCE); } } diff --git a/idea/idea-native/src/org/jetbrains/konan/analyser/index/KonanMetadataDecompiler.kt b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/decompiler/KotlinNativeMetadataDecompiler.kt similarity index 62% rename from idea/idea-native/src/org/jetbrains/konan/analyser/index/KonanMetadataDecompiler.kt rename to idea/idea-native/src/org/jetbrains/kotlin/ide/konan/decompiler/KotlinNativeMetadataDecompiler.kt index 31d66193841..6a0413352f0 100644 --- a/idea/idea-native/src/org/jetbrains/konan/analyser/index/KonanMetadataDecompiler.kt +++ b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/decompiler/KotlinNativeMetadataDecompiler.kt @@ -3,7 +3,7 @@ * 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.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.NullFlexibleTypeDeserializer -class KonanMetadataDecompiler : KonanMetadataDecompilerBase( - KonanMetaFileType, KonanPlatform, KonanSerializerProtocol, NullFlexibleTypeDeserializer, - KonanMetadataVersion.DEFAULT_INSTANCE, KonanMetadataVersion.INVALID_VERSION, KonanMetaFileType.STUB_VERSION +class KotlinNativeMetadataDecompiler : KotlinNativeMetadataDecompilerBase( + KotlinNativeMetaFileType, KonanPlatform, KonanSerializerProtocol, NullFlexibleTypeDeserializer, + KotlinNativeMetadataVersion.DEFAULT_INSTANCE, + KotlinNativeMetadataVersion.INVALID_VERSION, + KotlinNativeMetaFileType.STUB_VERSION ) { 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 } } -class KonanMetadataVersion(vararg numbers: Int) : BinaryVersion(*numbers) { +class KotlinNativeMetadataVersion(vararg numbers: Int) : BinaryVersion(*numbers) { override fun isCompatible(): Boolean = true //todo: ? companion object { @JvmField - val DEFAULT_INSTANCE = KonanMetadataVersion(1, 1, 0) + val DEFAULT_INSTANCE = KotlinNativeMetadataVersion(1, 1, 0) @JvmField - val INVALID_VERSION = KonanMetadataVersion() + val INVALID_VERSION = KotlinNativeMetadataVersion() } } -object KonanMetaFileType : FileType { +object KotlinNativeMetaFileType : FileType { override fun getName() = "KNM" override fun getDescription() = "Kotlin/Native Metadata" override fun getDefaultExtension() = KLIB_METADATA_FILE_EXTENSION @@ -50,7 +52,7 @@ object KonanMetaFileType : FileType { 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) } diff --git a/idea/idea-native/src/org/jetbrains/konan/analyser/index/KonanMetadataDecompilerBase.kt b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/decompiler/KotlinNativeMetadataDecompilerBase.kt similarity index 85% rename from idea/idea-native/src/org/jetbrains/konan/analyser/index/KonanMetadataDecompilerBase.kt rename to idea/idea-native/src/org/jetbrains/kotlin/ide/konan/decompiler/KotlinNativeMetadataDecompilerBase.kt index 6d2c89f6abd..f7121d343e4 100644 --- a/idea/idea-native/src/org/jetbrains/konan/analyser/index/KonanMetadataDecompilerBase.kt +++ b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/decompiler/KotlinNativeMetadataDecompilerBase.kt @@ -3,13 +3,12 @@ * 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.vfs.VirtualFile import com.intellij.psi.PsiManager import com.intellij.psi.compiled.ClassFileDecompilers -import org.jetbrains.konan.KonanDecompiledFile import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.idea.decompiler.KotlinDecompiledFileViewProvider 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 java.io.IOException -//todo: Fix in Kotlin plugin -abstract class KonanMetadataDecompilerBase( +abstract class KotlinNativeMetadataDecompilerBase( private val fileType: FileType, private val targetPlatform: TargetPlatform, private val serializerProtocol: SerializerExtensionProtocol, @@ -41,7 +39,13 @@ abstract class KonanMetadataDecompilerBase( stubVersion: Int ) : ClassFileDecompilers.Full() { - private val stubBuilder = KonanMetadataStubBuilder(stubVersion, fileType, serializerProtocol, ::readFileSafely) + private val stubBuilder = + KotlinNativeMetadataStubBuilder( + stubVersion, + fileType, + serializerProtocol, + ::readFileSafely + ) private val renderer = DescriptorRenderer.withOptions { defaultDecompilerRendererOptions() } @@ -52,7 +56,12 @@ abstract class KonanMetadataDecompilerBase( override fun getStubBuilder() = stubBuilder 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? { if (!file.isValid) return null @@ -75,7 +84,13 @@ abstract class KonanMetadataDecompilerBase( return when (file) { 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) } } @@ -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( file: FileWithMetadata.Compatible, targetPlatform: TargetPlatform, serializerProtocol: SerializerExtensionProtocol, @@ -107,7 +122,7 @@ fun decompiledText( renderer: DescriptorRenderer ): DecompiledText { val packageFqName = file.packageFqName - val resolver = KonanMetadataDeserializerForDecompiler( + val resolver = KotlinNativeMetadataDeserializerForDecompiler( packageFqName, file.proto, file.nameResolver, targetPlatform, serializerProtocol, flexibleTypeDeserializer ) diff --git a/idea/idea-native/src/org/jetbrains/konan/analyser/index/KonanMetadataDeserializerForDecompiler.kt b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/decompiler/KotlinNativeMetadataDeserializerForDecompiler.kt similarity index 89% rename from idea/idea-native/src/org/jetbrains/konan/analyser/index/KonanMetadataDeserializerForDecompiler.kt rename to idea/idea-native/src/org/jetbrains/kotlin/ide/konan/decompiler/KotlinNativeMetadataDeserializerForDecompiler.kt index 130e89bc7dd..a849a9a42e3 100644 --- a/idea/idea-native/src/org/jetbrains/konan/analyser/index/KonanMetadataDeserializerForDecompiler.kt +++ b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/decompiler/KotlinNativeMetadataDeserializerForDecompiler.kt @@ -4,7 +4,7 @@ */ -package org.jetbrains.konan.analyser.index +package org.jetbrains.kotlin.ide.konan.decompiler import com.intellij.openapi.diagnostic.Logger 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.descriptors.DeserializedPackageMemberScope -//todo: Fix in Kotlin plugin -class KonanMetadataDeserializerForDecompiler( +class KotlinNativeMetadataDeserializerForDecompiler( packageFqName: FqName, private val proto: KonanProtoBuf.LinkDataPackageFragment, private val nameResolver: NameResolver, @@ -40,7 +39,8 @@ class KonanMetadataDeserializerForDecompiler( val notFoundClasses = NotFoundClasses(storageManager, moduleDescriptor) deserializationComponents = DeserializationComponents( - storageManager, moduleDescriptor, DeserializationConfiguration.Default, KonanProtoBasedClassDataFinder(proto, nameResolver), + storageManager, moduleDescriptor, DeserializationConfiguration.Default, + KotlinNativeProtoBasedClassDataFinder(proto, nameResolver), AnnotationAndConstantLoaderImpl(moduleDescriptor, notFoundClasses, serializerProtocol), packageFragmentProvider, ResolveEverythingToKotlinAnyLocalClassifierResolver(builtIns), createLoggingErrorReporter(LOG), LookupTracker.DO_NOTHING, flexibleTypeDeserializer, emptyList(), notFoundClasses, ContractDeserializer.DEFAULT, @@ -57,7 +57,7 @@ class KonanMetadataDeserializerForDecompiler( createDummyPackageFragment(facadeFqName), proto.`package`, nameResolver, - KonanMetadataVersion.DEFAULT_INSTANCE, + KotlinNativeMetadataVersion.DEFAULT_INSTANCE, containerSource = null, components = deserializationComponents ) { emptyList() } @@ -66,7 +66,7 @@ class KonanMetadataDeserializerForDecompiler( } companion object { - private val LOG = Logger.getInstance(KonanMetadataDeserializerForDecompiler::class.java) + private val LOG = Logger.getInstance(KotlinNativeMetadataDeserializerForDecompiler::class.java) } } diff --git a/idea/idea-native/src/org/jetbrains/konan/analyser/index/KonanMetadataStubBuilder.kt b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/decompiler/KotlinNativeMetadataStubBuilder.kt similarity index 80% rename from idea/idea-native/src/org/jetbrains/konan/analyser/index/KonanMetadataStubBuilder.kt rename to idea/idea-native/src/org/jetbrains/kotlin/ide/konan/decompiler/KotlinNativeMetadataStubBuilder.kt index 948cfd3df9e..883db69ee39 100644 --- a/idea/idea-native/src/org/jetbrains/konan/analyser/index/KonanMetadataStubBuilder.kt +++ b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/decompiler/KotlinNativeMetadataStubBuilder.kt @@ -3,7 +3,7 @@ * 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.vfs.VirtualFile @@ -12,6 +12,8 @@ import com.intellij.psi.impl.compiled.ClassFileStubBuilder import com.intellij.psi.stubs.PsiFileStub import com.intellij.util.indexing.FileContent 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.textBuilder.defaultDecompilerRendererOptions 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.konan.NullFlexibleTypeDeserializer -//todo: Fix in Kotlin plugin -open class KonanMetadataStubBuilder( +open class KotlinNativeMetadataStubBuilder( private val version: Int, private val fileType: FileType, private val serializerProtocol: SerializerExtensionProtocol, @@ -39,7 +40,13 @@ open class KonanMetadataStubBuilder( is FileWithMetadata.Incompatible -> createIncompatibleAbiVersionFileStub() is FileWithMetadata.Compatible -> { //todo: this part is implemented in our own way 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) } } diff --git a/idea/idea-native/src/org/jetbrains/konan/analyser/index/KonanProtoBasedClassDataFinder.kt b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/decompiler/KotlinNativeProtoBasedClassDataFinder.kt similarity index 83% rename from idea/idea-native/src/org/jetbrains/konan/analyser/index/KonanProtoBasedClassDataFinder.kt rename to idea/idea-native/src/org/jetbrains/kotlin/ide/konan/decompiler/KotlinNativeProtoBasedClassDataFinder.kt index e3d71c390df..1e6e95e5e81 100644 --- a/idea/idea-native/src/org/jetbrains/konan/analyser/index/KonanProtoBasedClassDataFinder.kt +++ b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/decompiler/KotlinNativeProtoBasedClassDataFinder.kt @@ -3,7 +3,7 @@ * 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.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.getClassId -//todo: Fix in Kotlin plugin -class KonanProtoBasedClassDataFinder( +class KotlinNativeProtoBasedClassDataFinder( proto: KonanProtoBuf.LinkDataPackageFragment, private val nameResolver: NameResolver, private val classSource: (ClassId) -> SourceElement = { SourceElement.NO_SOURCE } @@ -28,6 +27,6 @@ class KonanProtoBasedClassDataFinder( override fun findClassData(classId: ClassId): ClassData? { val classProto = classIdToProto[classId] ?: return null - return ClassData(nameResolver, classProto, KonanMetadataVersion.DEFAULT_INSTANCE, classSource(classId)) + return ClassData(nameResolver, classProto, KotlinNativeMetadataVersion.DEFAULT_INSTANCE, classSource(classId)) } } diff --git a/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/index/KotlinNativeMetaFileIndex.kt b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/index/KotlinNativeMetaFileIndex.kt index b37502afa18..30958a2cc48 100644 --- a/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/index/KotlinNativeMetaFileIndex.kt +++ b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/index/KotlinNativeMetaFileIndex.kt @@ -6,8 +6,8 @@ package org.jetbrains.kotlin.ide.konan.index import com.intellij.util.indexing.FileBasedIndex -import org.jetbrains.konan.analyser.index.KonanDescriptorManager -import org.jetbrains.konan.analyser.index.KonanMetaFileType +import org.jetbrains.kotlin.ide.konan.decompiler.KotlinNativeDescriptorManager +import org.jetbrains.kotlin.ide.konan.decompiler.KotlinNativeMetaFileType import org.jetbrains.kotlin.idea.vfilefinder.KotlinFileIndexBase import org.jetbrains.kotlin.name.FqName @@ -15,18 +15,18 @@ object KotlinNativeMetaFileIndex : KotlinFileIndexBase - val fragment = KonanDescriptorManager.getInstance().getCachedPackageFragment(fileContent.file) + val fragment = KotlinNativeDescriptorManager.getInstance().getCachedPackageFragment(fileContent.file) FqName(fragment.fqName) } } diff --git a/idea/src/META-INF/gradle.xml b/idea/src/META-INF/gradle.xml index 94c8b46bfdd..1e7b4cc61c5 100644 --- a/idea/src/META-INF/gradle.xml +++ b/idea/src/META-INF/gradle.xml @@ -14,7 +14,7 @@ - org.jetbrains.konan.gradle.internal.KotlinNativeIdeInitializer + org.jetbrains.kotlin.ide.konan.gradle.KotlinNativeIdeInitializer diff --git a/idea/src/META-INF/native.xml b/idea/src/META-INF/native.xml index e009de3df02..b7ca3d692a7 100644 --- a/idea/src/META-INF/native.xml +++ b/idea/src/META-INF/native.xml @@ -1,26 +1,26 @@ - org.jetbrains.konan.KonanApplicationComponent + org.jetbrains.kotlin.ide.konan.KotlinNativeApplicationComponent - org.jetbrains.konan.analyser.index.KonanDescriptorManager + org.jetbrains.kotlin.ide.konan.decompiler.KotlinNativeDescriptorManager - + - + - +