[Platform API] Make 'ModuleInfo.platform' non-nullable
This commit is contained in:
@@ -43,9 +43,12 @@ import org.jetbrains.kotlin.idea.stubindex.KotlinSourceFilterScope
|
||||
import org.jetbrains.kotlin.idea.util.isInSourceContentWithoutInjected
|
||||
import org.jetbrains.kotlin.idea.util.rootManager
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.platform.DefaultIdeTargetPlatformKindProvider
|
||||
import org.jetbrains.kotlin.platform.idePlatformKind
|
||||
import org.jetbrains.kotlin.resolve.PlatformDependentCompilerServices
|
||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatformCompilerServices
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import java.util.*
|
||||
|
||||
@@ -318,10 +321,10 @@ data class LibrarySourceInfo(val project: Project, val library: Library, overrid
|
||||
return createLibraryInfo(project, library)
|
||||
}
|
||||
|
||||
override val platform: TargetPlatform?
|
||||
override val platform: TargetPlatform
|
||||
get() = binariesModuleInfo.platform
|
||||
|
||||
override val compilerServices: PlatformDependentCompilerServices?
|
||||
override val compilerServices: PlatformDependentCompilerServices
|
||||
get() = binariesModuleInfo.compilerServices
|
||||
|
||||
override fun toString() = "LibrarySourceInfo(libraryName=${library.name})"
|
||||
@@ -337,6 +340,12 @@ data class SdkInfo(val project: Project, val sdk: Sdk) : IdeaModuleInfo {
|
||||
override fun contentScope(): GlobalSearchScope = SdkScope(project, sdk)
|
||||
|
||||
override fun dependencies(): List<IdeaModuleInfo> = listOf(this)
|
||||
|
||||
override val platform: TargetPlatform
|
||||
get() = JvmPlatforms.defaultJvmPlatform // TODO(dsavvinov): provide proper target version
|
||||
|
||||
override val compilerServices: PlatformDependentCompilerServices
|
||||
get() = JvmPlatformCompilerServices
|
||||
}
|
||||
|
||||
object NotUnderContentRootModuleInfo : IdeaModuleInfo {
|
||||
@@ -350,11 +359,11 @@ object NotUnderContentRootModuleInfo : IdeaModuleInfo {
|
||||
//TODO: (module refactoring) dependency on runtime can be of use here
|
||||
override fun dependencies(): List<IdeaModuleInfo> = listOf(this)
|
||||
|
||||
override val platform: TargetPlatform?
|
||||
get() = null
|
||||
override val platform: TargetPlatform
|
||||
get() = DefaultIdeTargetPlatformKindProvider.defaultPlatform
|
||||
|
||||
override val compilerServices: PlatformDependentCompilerServices?
|
||||
get() = null
|
||||
override val compilerServices: PlatformDependentCompilerServices
|
||||
get() = platform.findCompilerServices
|
||||
}
|
||||
|
||||
private class LibraryWithoutSourceScope(project: Project, private val library: Library) :
|
||||
@@ -438,14 +447,14 @@ data class PlatformModuleInfo(
|
||||
|
||||
override val containedModules: List<ModuleSourceInfo> = listOf(platformModule) + commonModules
|
||||
|
||||
override val platform: TargetPlatform?
|
||||
override val platform: TargetPlatform
|
||||
get() = platformModule.platform
|
||||
|
||||
override val moduleOrigin: ModuleOrigin
|
||||
get() = platformModule.moduleOrigin
|
||||
|
||||
override val compilerServices: PlatformDependentCompilerServices?
|
||||
get() = platform?.findCompilerServices
|
||||
override val compilerServices: PlatformDependentCompilerServices
|
||||
get() = platform.findCompilerServices
|
||||
|
||||
override fun dependencies() = platformModule.dependencies()
|
||||
|
||||
|
||||
+15
-12
@@ -16,6 +16,9 @@ import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.scripting.definitions.KotlinScriptDefinition
|
||||
import org.jetbrains.kotlin.resolve.PlatformDependentCompilerServices
|
||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
||||
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatformCompilerServices
|
||||
|
||||
|
||||
data class ScriptModuleInfo(
|
||||
val project: Project,
|
||||
@@ -48,11 +51,11 @@ data class ScriptModuleInfo(
|
||||
}
|
||||
}
|
||||
|
||||
override val platform: TargetPlatform?
|
||||
get() = null
|
||||
override val platform: TargetPlatform
|
||||
get() = JvmPlatforms.defaultJvmPlatform // TODO(dsavvinov): choose proper target version
|
||||
|
||||
override val compilerServices: PlatformDependentCompilerServices?
|
||||
get() = null
|
||||
override val compilerServices: PlatformDependentCompilerServices
|
||||
get() = JvmPlatformCompilerServices
|
||||
}
|
||||
|
||||
sealed class ScriptDependenciesInfo(val project: Project) : IdeaModuleInfo, BinaryModuleInfo {
|
||||
@@ -74,11 +77,11 @@ sealed class ScriptDependenciesInfo(val project: Project) : IdeaModuleInfo, Bina
|
||||
override val sourcesModuleInfo: SourceForBinaryModuleInfo?
|
||||
get() = ScriptDependenciesSourceInfo.ForProject(project)
|
||||
|
||||
override val platform: TargetPlatform?
|
||||
get() = null
|
||||
override val platform: TargetPlatform
|
||||
get() = JvmPlatforms.defaultJvmPlatform // TODO(dsavvinov): choose proper TargetVersion
|
||||
|
||||
override val compilerServices: PlatformDependentCompilerServices?
|
||||
get() = null
|
||||
override val compilerServices: PlatformDependentCompilerServices
|
||||
get() = JvmPlatformCompilerServices
|
||||
|
||||
class ForFile(
|
||||
project: Project,
|
||||
@@ -129,11 +132,11 @@ sealed class ScriptDependenciesSourceInfo(val project: Project) : IdeaModuleInfo
|
||||
|
||||
override fun equals(other: Any?): Boolean = other is ScriptDependenciesSourceInfo && this.project == other.project
|
||||
|
||||
override val platform: TargetPlatform?
|
||||
get() = null
|
||||
override val platform: TargetPlatform
|
||||
get() = JvmPlatforms.defaultJvmPlatform // TODO(dsavvinov): choose proper TargetVersion
|
||||
|
||||
override val compilerServices: PlatformDependentCompilerServices?
|
||||
get() = null
|
||||
override val compilerServices: PlatformDependentCompilerServices
|
||||
get() = JvmPlatformCompilerServices
|
||||
|
||||
class ForProject(project: Project) : ScriptDependenciesSourceInfo(project)
|
||||
}
|
||||
Reference in New Issue
Block a user