[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:
@@ -44,6 +44,7 @@ import org.jetbrains.kotlin.load.kotlin.VirtualFileFinderFactory
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
import org.jetbrains.kotlin.resolve.jvm.JavaDescriptorResolver
|
||||
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform
|
||||
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatformCompilerServices
|
||||
import org.jetbrains.kotlin.resolve.lazy.KotlinCodeAnalyzer
|
||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSession
|
||||
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory
|
||||
@@ -92,8 +93,8 @@ fun createContainerForLazyResolveWithJava(
|
||||
useBuiltInsProvider: Boolean,
|
||||
configureJavaClassFinder: (StorageComponentContainer.() -> Unit)? = null,
|
||||
javaClassTracker: JavaClassesTracker? = null
|
||||
): StorageComponentContainer = createContainer("LazyResolveWithJava", JvmPlatform) {
|
||||
configureModule(moduleContext, JvmPlatform, jvmTarget, bindingTrace)
|
||||
): StorageComponentContainer = createContainer("LazyResolveWithJava", JvmPlatformCompilerServices) {
|
||||
configureModule(moduleContext, JvmPlatform, jvmTarget, JvmPlatformCompilerServices, bindingTrace)
|
||||
configureJavaTopDownAnalysis(moduleContentScope, moduleContext.project, lookupTracker, expectActualTracker)
|
||||
|
||||
if (configureJavaClassFinder != null) {
|
||||
|
||||
@@ -23,6 +23,10 @@ import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
|
||||
object JvmPlatform : TargetPlatform("JVM") {
|
||||
override val platform = MultiTargetPlatform.Specific(platformName)
|
||||
}
|
||||
|
||||
object JvmPlatformCompilerServices : PlatformDependentCompilerServices() {
|
||||
override fun computePlatformSpecificDefaultImports(storageManager: StorageManager, result: MutableList<ImportPath>) {
|
||||
result.add(ImportPath.fromString("kotlin.jvm.*"))
|
||||
|
||||
@@ -40,6 +44,4 @@ object JvmPlatform : TargetPlatform("JVM") {
|
||||
override val defaultLowPriorityImports: List<ImportPath> = listOf(ImportPath.fromString("java.lang.*"))
|
||||
|
||||
override val platformConfigurator: PlatformConfigurator = JvmPlatformConfigurator
|
||||
|
||||
override val multiTargetPlatform = MultiTargetPlatform.Specific(platformName)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user