[analysis] introduce KtBuiltinsModule and remove hacks related to the stdlib module search

This commit is contained in:
Ilya Kirillov
2022-07-18 23:07:06 +02:00
parent dc4527462f
commit dd00062559
29 changed files with 152 additions and 187 deletions
@@ -52,6 +52,7 @@ class AnalysisApiKtModuleProviderImpl(
is KtLibrarySourceModule -> ktModule.libraryName
is KtSourceModule -> ktModule.moduleName
is KtNotUnderContentRootModule -> TODO()
is KtBuiltinsModule -> "Builtins for ${ktModule.platform}"
}
@@ -58,7 +58,6 @@ class KtLibraryModuleImpl(
override val project: Project,
private val binaryRoots: Collection<Path>,
override var librarySources: KtLibrarySourceModule?,
val isBuitinsContainingStdlib: Boolean,
) : KtLibraryModule, KtModuleWithModifiableDependencies {
override val analyzerServices: PlatformDependentAnalyzerServices get() = platform.getAnalyzerServices()
override fun getBinaryRoots(): Collection<Path> = binaryRoots
@@ -96,12 +96,8 @@ object TestModuleStructureFactory {
}
}
val allStdLibCandidates = modulesFromTestServices.flatMap { module ->
module.ktModule.allDirectDependenciesOfType<KtLibraryModuleImpl>()
}.filter { it.isBuitinsContainingStdlib }
return KtModuleProjectStructure(modulesFromTestServices, binaryModulesBySourceRoots.values) { platform ->
allStdLibCandidates.first { it.platform == platform }
}
return KtModuleProjectStructure(modulesFromTestServices, binaryModulesBySourceRoots.values)
}
@OptIn(TestInfrastructureInternals::class)
@@ -114,7 +110,7 @@ object TestModuleStructureFactory {
val contentRoots = compilerConfiguration[CLIConfigurationKeys.CONTENT_ROOTS, emptyList()]
return contentRoots
.filterIsInstance<JvmClasspathRoot>()
.map { root -> createKtLibraryModuleByJar(root.file.toPath(), testServices, project, isBuitinsContainingStdlib = false) }
.map { root -> createKtLibraryModuleByJar(root.file.toPath(), testServices, project) }
}
@@ -155,7 +151,6 @@ object TestModuleStructureFactory {
jar,
testServices,
project,
isBuitinsContainingStdlib = jar.nameWithoutExtension == "kotlin-stdlib-jvm-minimal-for-test"
)
}
}
@@ -165,7 +160,6 @@ object TestModuleStructureFactory {
testServices: TestServices,
project: Project,
libraryName: String = jar.nameWithoutExtension,
isBuitinsContainingStdlib: Boolean = false,
): KtLibraryModuleImpl {
check(jar.extension == "jar")
check(jar.exists())
@@ -176,7 +170,6 @@ object TestModuleStructureFactory {
project,
listOf(jar),
librarySources = null,
isBuitinsContainingStdlib,
)
}
@@ -191,7 +184,7 @@ object TestModuleStructureFactory {
KotlinPaths.Jar.StdLib to PathUtil.KOTLIN_JAVA_STDLIB_NAME,
).map { (jar, name) ->
val lib = PathUtil.kotlinPathsForDistDirectory.jar(jar).toPath().toAbsolutePath()
createKtLibraryModuleByJar(lib, testServices, project, name, isBuitinsContainingStdlib = jar == KotlinPaths.Jar.StdLib)
createKtLibraryModuleByJar(lib, testServices, project, name)
}
}