Rename "Konan" -> "KotlinNative" in class and function names

This commit is contained in:
Dmitriy Dolovov
2018-09-06 12:54:03 +03:00
committed by Mikhail Glukhikh
parent 337100edc3
commit 46a697db82
8 changed files with 59 additions and 56 deletions
@@ -13,7 +13,7 @@ import com.intellij.openapi.roots.libraries.DummyLibraryProperties
import com.intellij.openapi.roots.libraries.Library
import com.intellij.openapi.roots.libraries.LibraryType
import com.intellij.psi.search.GlobalSearchScope
import org.jetbrains.konan.analyser.index.KonanMetaFileIndex
import org.jetbrains.kotlin.ide.konan.index.KotlinNativeMetaFileIndex
import org.jetbrains.kotlin.idea.configuration.KotlinWithLibraryConfigurator
import org.jetbrains.kotlin.idea.configuration.LibraryKindSearchScope
import org.jetbrains.kotlin.idea.configuration.hasKotlinFilesOnlyInTests
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.konan.library.KONAN_STDLIB_NAME
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.resolve.konan.platform.KonanPlatform
open class KonanModuleConfigurator : KotlinWithLibraryConfigurator() {
open class KotlinNativeModuleConfigurator : KotlinWithLibraryConfigurator() {
override val name: String get() = NAME
@@ -33,15 +33,15 @@ open class KonanModuleConfigurator : KotlinWithLibraryConfigurator() {
override val presentableText get() = PRESENTABLE_TEXT
override fun isConfigured(module: Module) = hasKonanRuntimeInScope(module)
override fun isConfigured(module: Module) = hasKotlinNativeRuntimeInScope(module)
override val libraryName get() = KonanStandardLibraryDescription.LIBRARY_NAME
override val libraryName get() = NativeStandardLibraryDescription.LIBRARY_NAME
override val dialogTitle get() = KonanStandardLibraryDescription.DIALOG_TITLE
override val dialogTitle get() = NativeStandardLibraryDescription.DIALOG_TITLE
override val libraryCaption get() = KonanStandardLibraryDescription.LIBRARY_CAPTION
override val libraryCaption get() = NativeStandardLibraryDescription.LIBRARY_CAPTION
override val messageForOverrideDialog get() = KonanStandardLibraryDescription.KONAN_LIBRARY_CREATION
override val messageForOverrideDialog get() = NativeStandardLibraryDescription.NATIVE_LIBRARY_CREATION
override fun getLibraryJarDescriptors(sdk: Sdk?) = emptyList<LibraryJarDescriptor>()
@@ -52,27 +52,27 @@ open class KonanModuleConfigurator : KotlinWithLibraryConfigurator() {
override val libraryType: LibraryType<DummyLibraryProperties>? get() = null
companion object {
const val NAME = "Konan"
const val NAME = "KotlinNative"
const val PRESENTABLE_TEXT = "Native"
}
}
fun hasKonanRuntimeInScope(module: Module): Boolean {
fun hasKotlinNativeRuntimeInScope(module: Module): Boolean {
return runReadAction {
val scope = module.getModuleWithDependenciesAndLibrariesScope(hasKotlinFilesOnlyInTests(module))
hasKonanMetadataFile(module.project, LibraryKindSearchScope(module, scope, KonanLibraryKind))
hasKotlinNativeMetadataFile(module.project, LibraryKindSearchScope(module, scope, NativeLibraryKind))
}
}
private val KONAN_FQ_NAMES = listOf(
private val KOTLIN_NATIVE_FQ_NAMES = listOf(
"kotlin.native",
"konan.native" // Keep "konan.native" for backward compatibility with older versions of Kotlin/Native.
).map { FqName(it) }
fun hasKonanMetadataFile(project: Project, scope: GlobalSearchScope): Boolean {
fun hasKotlinNativeMetadataFile(project: Project, scope: GlobalSearchScope): Boolean {
return runReadAction {
project.runWithAlternativeResolveEnabled {
KONAN_FQ_NAMES.any { KonanMetaFileIndex.hasSomethingInPackage(it, scope) }
KOTLIN_NATIVE_FQ_NAMES.any { KotlinNativeMetaFileIndex.hasSomethingInPackage(it, scope) }
}
}
}
@@ -12,9 +12,9 @@ import org.jetbrains.kotlin.platform.IdePlatform
import org.jetbrains.kotlin.platform.IdePlatformKind
import org.jetbrains.kotlin.resolve.konan.platform.KonanPlatform
object KonanPlatformKind : IdePlatformKind<KonanPlatformKind>() {
object NativeIdePlatformKind : IdePlatformKind<NativeIdePlatformKind>() {
override fun platformByCompilerArguments(arguments: CommonCompilerArguments): IdePlatform<KonanPlatformKind, CommonCompilerArguments>? {
override fun platformByCompilerArguments(arguments: CommonCompilerArguments): IdePlatform<NativeIdePlatformKind, CommonCompilerArguments>? {
return if (arguments is K2NativeCompilerArguments) Platform
else null
}
@@ -28,18 +28,18 @@ object KonanPlatformKind : IdePlatformKind<KonanPlatformKind>() {
override val name get() = "Native"
object Platform : IdePlatform<KonanPlatformKind, K2NativeCompilerArguments>() {
override val kind get() = KonanPlatformKind
object Platform : IdePlatform<NativeIdePlatformKind, K2NativeCompilerArguments>() {
override val kind get() = NativeIdePlatformKind
override val version get() = TargetPlatformVersion.NoVersion
override fun createArguments(init: K2NativeCompilerArguments.() -> Unit) = K2NativeCompilerArguments().apply(init)
}
override fun equals(other: Any?): Boolean = other === KonanPlatformKind
override fun equals(other: Any?): Boolean = other === NativeIdePlatformKind
override fun hashCode(): Int = javaClass.hashCode()
}
val IdePlatformKind<*>?.isKonan
get() = this === KonanPlatformKind
val IdePlatformKind<*>?.isKotlinNative
get() = this === NativeIdePlatformKind
val IdePlatform<*, *>?.isKonan
get() = this === KonanPlatformKind.Platform
val IdePlatform<*, *>?.isKotlinNative
get() = this === NativeIdePlatformKind.Platform
@@ -9,7 +9,7 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.libraries.DummyLibraryProperties
import com.intellij.openapi.roots.libraries.Library
import com.intellij.openapi.roots.libraries.PersistentLibraryKind
import org.jetbrains.konan.analyser.KonanAnalyzerFacade
import org.jetbrains.kotlin.ide.konan.analyzer.NativeAnalyzerFacade
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.gradle.KotlinPlatform
@@ -21,20 +21,20 @@ import org.jetbrains.kotlin.psi.KtNamedDeclaration
import org.jetbrains.kotlin.resolve.TargetPlatform
import javax.swing.Icon
class KonanPlatformKindTooling : IdePlatformKindTooling() {
class NativeIdePlatformKindTooling : IdePlatformKindTooling() {
override val kind = KonanPlatformKind
override val kind = NativeIdePlatformKind
override fun compilerArgumentsForProject(project: Project): CommonCompilerArguments? = null
override val resolverForModuleFactory get() = KonanAnalyzerFacade
override val resolverForModuleFactory get() = NativeAnalyzerFacade
override val mavenLibraryIds: List<String> get() = emptyList()
override val gradlePluginId: String get() = ""
override val gradlePlatformIds: List<KotlinPlatform> get() = listOf(KotlinPlatform.KONAN)
override val gradlePlatformIds: List<KotlinPlatform> get() = listOf(KotlinPlatform.NATIVE)
override val libraryKind: PersistentLibraryKind<*> = KonanLibraryKind
override fun getLibraryDescription(project: Project) = KonanStandardLibraryDescription(project)
override val libraryKind: PersistentLibraryKind<*> = NativeLibraryKind
override fun getLibraryDescription(project: Project) = NativeStandardLibraryDescription(project)
override fun getLibraryVersionProvider(project: Project): (Library) -> String? = { null }
override fun getTestIcon(declaration: KtNamedDeclaration, descriptor: DeclarationDescriptor): Icon? = null
@@ -42,30 +42,30 @@ class KonanPlatformKindTooling : IdePlatformKindTooling() {
override fun acceptsAsEntryPoint(function: KtFunction) = true
}
object KonanLibraryKind : PersistentLibraryKind<DummyLibraryProperties>("kotlin.native"), KotlinLibraryKind {
object NativeLibraryKind : PersistentLibraryKind<DummyLibraryProperties>("kotlin.native"), KotlinLibraryKind {
override val compilerPlatform: TargetPlatform
get() = KonanPlatformKind.compilerPlatform
get() = NativeIdePlatformKind.compilerPlatform
override fun createDefaultProperties() = DummyLibraryProperties.INSTANCE!!
}
class KonanStandardLibraryDescription(project: Project?) :
class NativeStandardLibraryDescription(project: Project?) :
CustomLibraryDescriptorWithDeferredConfig(
project,
KonanModuleConfigurator.NAME,
KotlinNativeModuleConfigurator.NAME,
LIBRARY_NAME,
DIALOG_TITLE,
LIBRARY_CAPTION,
KonanLibraryKind,
NativeLibraryKind,
SUITABLE_LIBRARY_KINDS
) {
companion object {
val LIBRARY_NAME = "KotlinNative"
val KONAN_LIBRARY_CREATION = "Native Library Creation"
val NATIVE_LIBRARY_CREATION = "Native Library Creation"
val DIALOG_TITLE = "Create Kotlin Native Library"
val LIBRARY_CAPTION = "Kotlin Native Library"
val SUITABLE_LIBRARY_KINDS = setOf(KonanLibraryKind)
val SUITABLE_LIBRARY_KINDS = setOf(NativeLibraryKind)
}
}
@@ -13,7 +13,7 @@ import com.intellij.openapi.roots.libraries.PersistentLibraryKind
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.util.io.exists
import org.jetbrains.konan.KONAN_CURRENT_ABI_VERSION
import org.jetbrains.konan.analyser.KonanAnalyzerFacade
import org.jetbrains.kotlin.ide.konan.analyzer.NativeAnalyzerFacade
import org.jetbrains.kotlin.builtins.DefaultBuiltIns
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.caches.resolve.IdePlatformKindResolution
@@ -29,35 +29,36 @@ import org.jetbrains.kotlin.konan.utils.KonanFactories.DefaultDeserializedDescri
import java.nio.file.Path
import java.nio.file.Paths
class KonanPlatformKindResolution : IdePlatformKindResolution {
class NativePlatformKindResolution : IdePlatformKindResolution {
override fun isLibraryFileForPlatform(virtualFile: VirtualFile): Boolean {
return virtualFile.extension == "klib"
|| virtualFile.isDirectory && virtualFile.children.any { it.name == "manifest" }
}
override val libraryKind: PersistentLibraryKind<*>?
get() = KonanLibraryKind
get() = NativeLibraryKind
override val kind get() = KonanPlatformKind
override val kind get() = NativeIdePlatformKind
override val resolverForModuleFactory get() = KonanAnalyzerFacade
override val resolverForModuleFactory get() = NativeAnalyzerFacade
override fun createBuiltIns(settings: PlatformAnalysisSettings, projectContext: ProjectContext) =
createKonanBuiltIns(projectContext)
createKotlinNativeBuiltIns(projectContext)
}
val Module.isKonanModule: Boolean
val Module.isKotlinNativeModule: Boolean
get() {
val settings = KotlinFacetSettingsProvider.getInstance(project).getInitializedSettings(this)
return settings.platform.isKonan
return settings.platform.isKotlinNative
}
private fun createKonanBuiltIns(projectContext: ProjectContext): KotlinBuiltIns {
private fun createKotlinNativeBuiltIns(projectContext: ProjectContext): KotlinBuiltIns {
// TODO: It depends on a random project's stdlib, propagate the actual project here.
val stdlib: Pair<Path, LibraryInfo>? = ProjectManager.getInstance().openProjects.asSequence().mapNotNull { project ->
ModuleManager.getInstance(project).modules.asSequence().filter { it.isKonanModule }.mapNotNull { module ->
ModuleManager.getInstance(project).modules.asSequence().filter { it.isKotlinNativeModule }.mapNotNull { module ->
var result: Pair<Path, LibraryInfo>? = null
@@ -3,7 +3,7 @@
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.konan.analyser
package org.jetbrains.kotlin.ide.konan.analyzer
import org.jetbrains.konan.createDeclarationProviderFactory
import org.jetbrains.konan.createResolvedModuleDescriptors
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.resolve.lazy.ResolveSession
/**
* @author Alefas
*/
object KonanAnalyzerFacade : ResolverForModuleFactory() {
object NativeAnalyzerFacade : ResolverForModuleFactory() {
override val targetPlatform: TargetPlatform
get() = KonanPlatform
@@ -3,13 +3,15 @@
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.konan.analyser.index
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.idea.vfilefinder.KotlinFileIndexBase
import org.jetbrains.kotlin.name.FqName
object KonanMetaFileIndex : KotlinFileIndexBase<KonanMetaFileIndex>(KonanMetaFileIndex::class.java) {
object KotlinNativeMetaFileIndex : KotlinFileIndexBase<KotlinNativeMetaFileIndex>(KotlinNativeMetaFileIndex::class.java) {
override fun getIndexer() = INDEXER
@@ -60,7 +60,7 @@ enum class KotlinPlatform(val id: String) {
COMMON("common"),
JVM("jvm"),
JS("js"),
KONAN("native"),
NATIVE("native"),
ANDROID("androidJvm");
companion object {
+5 -5
View File
@@ -27,15 +27,15 @@
<filetype.stubBuilder filetype="KNM" implementationClass="com.intellij.psi.impl.compiled.ClassFileStubBuilder"/>
<filetype.decompiler filetype="KNM" implementationClass="com.intellij.psi.impl.compiled.ClassFileDecompiler"/>
<fileTypeFactory implementation="org.jetbrains.konan.analyser.index.KonanMetaFileTypeFactory"/>
<fileBasedIndex implementation="org.jetbrains.konan.analyser.index.KonanMetaFileIndex"/>
<fileBasedIndex implementation="org.jetbrains.kotlin.ide.konan.index.KotlinNativeMetaFileIndex"/>
</extensions>
<extensions defaultExtensionNs="org.jetbrains.kotlin">
<binaryExtension implementation="org.jetbrains.konan.analyser.index.KonanMetaBinary"/>
<!--<idePlatformSupport implementation="org.jetbrains.konan.analyser.KonanPlatformSupport" order="first"/>-->
<idePlatformKind implementation="org.jetbrains.kotlin.ide.konan.KonanPlatformKind"/>
<idePlatformKindTooling implementation="org.jetbrains.kotlin.ide.konan.KonanPlatformKindTooling"/>
<idePlatformKindResolution implementation="org.jetbrains.kotlin.ide.konan.KonanPlatformKindResolution"/>
<projectConfigurator implementation="org.jetbrains.kotlin.ide.konan.KonanModuleConfigurator"/>
<idePlatformKind implementation="org.jetbrains.kotlin.ide.konan.NativeIdePlatformKind"/>
<idePlatformKindTooling implementation="org.jetbrains.kotlin.ide.konan.NativeIdePlatformKindTooling"/>
<idePlatformKindResolution implementation="org.jetbrains.kotlin.ide.konan.NativePlatformKindResolution"/>
<projectConfigurator implementation="org.jetbrains.kotlin.ide.konan.KotlinNativeModuleConfigurator"/>
</extensions>
</idea-plugin>