[Platform API] Introduce fundamental abstraction of Platform
This is a large commit, which introduces general API for working with
abstraction of Platform.
- Add new abstraction to 'core' - SimplePlatform - which represents
exactly one platform
- Clients are strongly prohibited to create instances of SimplePlatform
by hand, instead, corresponding *Platforms abstraction should be used
(e.g. JvmPlatforms, JsPlatforms, KonanPlatforms)
- Move TargetPlatform to 'core', it represents now a collection of
SimplePlatforms
- Clients are strongly encouraged to use TargetPlatform
(not SimplePlatform) in API, to enforce checks for multiplatform
- Provide a helper-extensions to work with TargetPlatform
(in particular, for getting a specific component platform)
- Remove MultiTargetPlatform in favour of TargetPlatform
- Notably, this commit leaves another widely used duplicated abstraction,
namely, IdePlatform. For the sake sanity, removal of IdePlatform is
extracted in the separate commit.
This commit is contained in:
@@ -36,7 +36,7 @@ import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmProtoBufUtil
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getCall
|
||||
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform
|
||||
import org.jetbrains.kotlin.platform.jvm.isJvm
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
import org.jetbrains.uast.kotlin.KotlinUastResolveProviderService
|
||||
|
||||
@@ -55,11 +55,11 @@ class IdeaKotlinUastResolveProviderService : KotlinUastResolveProviderService {
|
||||
|
||||
val containingFile = psiElement.containingFile
|
||||
if (containingFile is KtFile) {
|
||||
return TargetPlatformDetector.getPlatform(containingFile) is JvmPlatform
|
||||
return TargetPlatformDetector.getPlatform(containingFile).isJvm()
|
||||
}
|
||||
|
||||
val module = psiElement.module
|
||||
return module == null || TargetPlatformDetector.getPlatform(module) is JvmPlatform
|
||||
return module == null || TargetPlatformDetector.getPlatform(module).isJvm()
|
||||
}
|
||||
|
||||
override fun getLanguageVersionSettings(element: KtElement): LanguageVersionSettings {
|
||||
@@ -78,7 +78,7 @@ class IdeaKotlinUastResolveProviderService : KotlinUastResolveProviderService {
|
||||
.getCachedValue(project, {
|
||||
Result.create(
|
||||
ModuleManager.getInstance(project).modules.all { module ->
|
||||
TargetPlatformDetector.getPlatform(module) is JvmPlatform
|
||||
TargetPlatformDetector.getPlatform(module).isJvm()
|
||||
},
|
||||
ProjectRootModificationTracker.getInstance(project)
|
||||
)
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.idea.util.module
|
||||
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmProtoBufUtil
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform
|
||||
import org.jetbrains.kotlin.platform.jvm.isJvm
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
import org.jetbrains.uast.kotlin.KotlinUastResolveProviderService
|
||||
|
||||
@@ -51,11 +51,11 @@ class IdeaKotlinUastResolveProviderService : KotlinUastResolveProviderService {
|
||||
|
||||
val containingFile = psiElement.containingFile
|
||||
if (containingFile is KtFile) {
|
||||
return TargetPlatformDetector.getPlatform(containingFile) is JvmPlatform
|
||||
return TargetPlatformDetector.getPlatform(containingFile).isJvm()
|
||||
}
|
||||
|
||||
val module = psiElement.module
|
||||
return module == null || TargetPlatformDetector.getPlatform(module) is JvmPlatform
|
||||
return module == null || TargetPlatformDetector.getPlatform(module).isJvm()
|
||||
}
|
||||
|
||||
override fun getLanguageVersionSettings(element: KtElement): LanguageVersionSettings {
|
||||
@@ -67,7 +67,7 @@ class IdeaKotlinUastResolveProviderService : KotlinUastResolveProviderService {
|
||||
.getCachedValue(project, {
|
||||
Result.create(
|
||||
ModuleManager.getInstance(project).modules.all { module ->
|
||||
TargetPlatformDetector.getPlatform(module) is JvmPlatform
|
||||
TargetPlatformDetector.getPlatform(module).isJvm()
|
||||
},
|
||||
ProjectRootModificationTracker.getInstance(project)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user