[Platform API] Split TargetPlatform into lightweight TargetPlatform and CompilerServices
This decouples simple data (TargetPlatform) from other subsystem-specific logic (like default imports, built-ins, etc.). Aside from purely aesthetic improvements, it also makes it easier to move 'TargetPlatform' into core (see next commits)
This commit is contained in:
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.analyzer
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.PlatformDependentCompilerServices
|
||||
import org.jetbrains.kotlin.resolve.TargetPlatform
|
||||
|
||||
|
||||
@@ -16,6 +17,7 @@ interface ModuleInfo {
|
||||
fun dependencies(): List<ModuleInfo>
|
||||
val expectedBy: List<ModuleInfo> get() = emptyList()
|
||||
val platform: TargetPlatform? get() = null
|
||||
val compilerServices: PlatformDependentCompilerServices? get() = null
|
||||
fun modulesWhoseInternalsAreVisible(): Collection<ModuleInfo> = listOf()
|
||||
val capabilities: Map<ModuleDescriptor.Capability<*>, Any?>
|
||||
get() = mapOf(Capability to this)
|
||||
@@ -28,7 +30,7 @@ interface ModuleInfo {
|
||||
// but if they are present, they should come after JVM built-ins in the dependencies list, because JVM built-ins contain
|
||||
// additional members dependent on the JDK
|
||||
fun dependencyOnBuiltIns(): ModuleInfo.DependencyOnBuiltIns =
|
||||
platform?.dependencyOnBuiltIns() ?: ModuleInfo.DependencyOnBuiltIns.LAST
|
||||
compilerServices?.dependencyOnBuiltIns() ?: ModuleInfo.DependencyOnBuiltIns.LAST
|
||||
|
||||
//TODO: (module refactoring) provide dependency on builtins after runtime in IDEA
|
||||
enum class DependencyOnBuiltIns { NONE, AFTER_SDK, LAST }
|
||||
|
||||
@@ -14,6 +14,11 @@ import org.jetbrains.kotlin.storage.StorageManager
|
||||
import java.util.*
|
||||
|
||||
abstract class TargetPlatform(val platformName: String) {
|
||||
override fun toString() = platformName
|
||||
abstract val platform: MultiTargetPlatform
|
||||
}
|
||||
|
||||
abstract class PlatformDependentCompilerServices {
|
||||
private data class DefaultImportsKey(val includeKotlinComparisons: Boolean, val includeLowPriorityImports: Boolean)
|
||||
|
||||
private val defaultImports = LockBasedStorageManager("TargetPlatform").let { storageManager ->
|
||||
@@ -42,8 +47,6 @@ abstract class TargetPlatform(val platformName: String) {
|
||||
}
|
||||
}
|
||||
|
||||
override fun toString() = platformName
|
||||
|
||||
abstract val platformConfigurator: PlatformConfigurator
|
||||
|
||||
open val defaultLowPriorityImports: List<ImportPath> get() = emptyList()
|
||||
@@ -60,8 +63,6 @@ abstract class TargetPlatform(val platformName: String) {
|
||||
|
||||
open val excludedImports: List<FqName> get() = emptyList()
|
||||
|
||||
abstract val multiTargetPlatform: MultiTargetPlatform
|
||||
|
||||
// This function is used in "cat.helm.clean:0.1.1-SNAPSHOT": https://plugins.jetbrains.com/plugin/index?xmlId=cat.helm.clean
|
||||
@Suppress("DeprecatedCallableAddReplaceWith", "unused")
|
||||
@Deprecated("Use getDefaultImports(LanguageVersionSettings, Boolean) instead.", level = DeprecationLevel.ERROR)
|
||||
|
||||
Reference in New Issue
Block a user