[Platform API] Make 'ModuleInfo.platform' non-nullable
This commit is contained in:
+4
@@ -38,6 +38,7 @@ import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.load.kotlin.MetadataFinderFactory
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.platform.CommonPlatforms
|
||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
@@ -67,6 +68,9 @@ object CommonResolverForModuleFactory : ResolverForModuleFactory() {
|
||||
override fun dependencyOnBuiltIns(): ModuleInfo.DependencyOnBuiltIns =
|
||||
if (dependOnOldBuiltIns) ModuleInfo.DependencyOnBuiltIns.LAST else ModuleInfo.DependencyOnBuiltIns.NONE
|
||||
|
||||
override val platform: TargetPlatform
|
||||
get() = CommonPlatforms.defaultCommonPlatform
|
||||
|
||||
override val compilerServices: PlatformDependentCompilerServices
|
||||
get() = CommonPlatformCompilerServices
|
||||
}
|
||||
|
||||
+2
-2
@@ -147,7 +147,7 @@ abstract class AbstractFirDiagnosticsSmokeTest : BaseDiagnosticsTest() {
|
||||
}
|
||||
|
||||
class BuiltInModuleInfo(override val name: Name) : ModuleInfo {
|
||||
override val platform: TargetPlatform?
|
||||
override val platform: TargetPlatform
|
||||
get() = JvmPlatforms.defaultJvmPlatform
|
||||
|
||||
override val compilerServices: PlatformDependentCompilerServices
|
||||
@@ -159,7 +159,7 @@ abstract class AbstractFirDiagnosticsSmokeTest : BaseDiagnosticsTest() {
|
||||
}
|
||||
|
||||
protected class TestModuleInfo(override val name: Name) : ModuleInfo {
|
||||
override val platform: TargetPlatform?
|
||||
override val platform: TargetPlatform
|
||||
get() = JvmPlatforms.defaultJvmPlatform
|
||||
|
||||
override val compilerServices: PlatformDependentCompilerServices
|
||||
|
||||
@@ -16,8 +16,8 @@ interface ModuleInfo {
|
||||
val displayedName: String get() = name.asString()
|
||||
fun dependencies(): List<ModuleInfo>
|
||||
val expectedBy: List<ModuleInfo> get() = emptyList()
|
||||
val platform: TargetPlatform? get() = null
|
||||
val compilerServices: PlatformDependentCompilerServices? get() = null
|
||||
val platform: TargetPlatform
|
||||
val compilerServices: PlatformDependentCompilerServices
|
||||
fun modulesWhoseInternalsAreVisible(): Collection<ModuleInfo> = listOf()
|
||||
val capabilities: Map<ModuleDescriptor.Capability<*>, Any?>
|
||||
get() = mapOf(Capability to this)
|
||||
|
||||
@@ -193,7 +193,7 @@ class ResolverForProjectImpl<M : ModuleInfo>(
|
||||
descriptor as ModuleDescriptorImpl,
|
||||
projectContext.withModule(descriptor),
|
||||
moduleContent,
|
||||
platformParameters(module.platform ?: TODO("Missing platform!")),
|
||||
platformParameters(module.platform),
|
||||
targetEnvironment,
|
||||
this@ResolverForProjectImpl,
|
||||
languageVersionSettings
|
||||
|
||||
+1
-1
@@ -69,6 +69,6 @@ private class TestModule(val dependsOnBuiltIns: Boolean) : ModuleInfo {
|
||||
override val platform: TargetPlatform
|
||||
get() = JvmPlatforms.defaultJvmPlatform
|
||||
|
||||
override val compilerServices: PlatformDependentCompilerServices?
|
||||
override val compilerServices: PlatformDependentCompilerServices
|
||||
get() = JvmPlatformCompilerServices
|
||||
}
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ class MultiModuleJavaAnalysisCustomTest : KtUsefulTestCase() {
|
||||
override val platform: TargetPlatform
|
||||
get() = JvmPlatforms.defaultJvmPlatform
|
||||
|
||||
override val compilerServices: PlatformDependentCompilerServices?
|
||||
override val compilerServices: PlatformDependentCompilerServices
|
||||
get() = JvmPlatformCompilerServices
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.frontend.di.configureModule
|
||||
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.js.resolve.JsPlatformCompilerServices
|
||||
import org.jetbrains.kotlin.platform.js.JsPlatforms
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
import org.jetbrains.kotlin.resolve.lazy.KotlinCodeAnalyzer
|
||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSession
|
||||
@@ -46,7 +47,7 @@ fun createTopDownAnalyzerForJs(
|
||||
val storageComponentContainer = createContainer("TopDownAnalyzerForJs", JsPlatformCompilerServices) {
|
||||
configureModule(
|
||||
moduleContext,
|
||||
DefaultBuiltInPlatforms.jsPlatform,
|
||||
JsPlatforms.defaultJsPlatform,
|
||||
JsPlatformCompilerServices,
|
||||
bindingTrace
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user