[Analysis API Standalone] simplify adding multiple binary roots for KtBinaryModuleBuilder

^KT-60884
This commit is contained in:
Ilya Kirillov
2023-08-30 14:46:41 +02:00
committed by Space Team
parent 52e9167675
commit 67f4ebc022
2 changed files with 12 additions and 4 deletions
@@ -9,5 +9,13 @@ import java.nio.file.Path
@KtModuleBuilderDsl
public abstract class KtBinaryModuleBuilder : KtModuleBuilder() {
public lateinit var binaryRoots: Collection<Path>
protected val binaryRoots: MutableList<Path> = mutableListOf()
public fun addBinaryRoot(root: Path) {
binaryRoots.add(root)
}
public fun addBinaryRoots(roots: Collection<Path>) {
binaryRoots.addAll(roots)
}
}
@@ -151,7 +151,7 @@ internal fun buildKtModuleProviderByCompilerConfiguration(
compilerConfig: CompilerConfiguration,
ktFiles: List<KtFile>,
): KtStaticProjectStructureProvider = buildProjectStructureProvider(kotlinCoreProjectEnvironment) {
val (scriptFiles, ordinaryFiles) = ktFiles.partition { it.isScript() }
val (scriptFiles, _) = ktFiles.partition { it.isScript() }
val platform = JvmPlatforms.defaultJvmPlatform
fun KtModuleBuilder.addModuleDependencies(moduleName: String) {
@@ -159,7 +159,7 @@ internal fun buildKtModuleProviderByCompilerConfiguration(
addRegularDependency(
buildKtLibraryModule {
this.platform = platform
binaryRoots = libraryRoots.map { it.toPath() }
addBinaryRoots(libraryRoots.map { it.toPath() })
libraryName = "Library for $moduleName"
}
)
@@ -171,7 +171,7 @@ internal fun buildKtModuleProviderByCompilerConfiguration(
addRegularDependency(
buildKtSdkModule {
this.platform = platform
this.binaryRoots = binaryRoots
addBinaryRoots(binaryRoots)
sdkName = "JDK for $moduleName"
}
)