[CLI] K2JVMCompilerArguments: Model classpath as Array<String>
to allow interning individual file-path arguments on the IDE KTIJ-24976
This commit is contained in:
committed by
Space Team
parent
7f91e94e7a
commit
9dcd40d7b7
+1
-1
@@ -342,7 +342,7 @@ fun CompilerConfiguration.configureBaseRoots(args: K2JVMCompilerArguments) {
|
||||
}
|
||||
}
|
||||
|
||||
args.classpath?.split(File.pathSeparator)?.forEach { classpathRoot ->
|
||||
args.classpath?.forEach { classpathRoot ->
|
||||
add(
|
||||
CLIConfigurationKeys.CONTENT_ROOTS,
|
||||
if (isJava9Module) JvmModulePathRoot(File(classpathRoot)) else JvmClasspathRoot(File(classpathRoot))
|
||||
|
||||
+6
-4
@@ -174,7 +174,8 @@ open class IncrementalJvmCompilerRunner(
|
||||
private val psiFileFactory: PsiFileFactory by lazy {
|
||||
val rootDisposable = Disposer.newDisposable()
|
||||
val configuration = compilerConfiguration
|
||||
val environment = KotlinCoreEnvironment.createForProduction(rootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
|
||||
val environment =
|
||||
KotlinCoreEnvironment.createForProduction(rootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
|
||||
val project = environment.project
|
||||
PsiFileFactory.getInstance(project)
|
||||
}
|
||||
@@ -281,7 +282,8 @@ open class IncrementalJvmCompilerRunner(
|
||||
if (!lastBuildInfoFile.exists()) {
|
||||
return CompilationMode.Rebuild(BuildAttribute.NO_LAST_BUILD_INFO)
|
||||
}
|
||||
val lastBuildInfo = BuildInfo.read(lastBuildInfoFile, messageCollector) ?: return CompilationMode.Rebuild(BuildAttribute.INVALID_LAST_BUILD_INFO)
|
||||
val lastBuildInfo = BuildInfo.read(lastBuildInfoFile, messageCollector)
|
||||
?: return CompilationMode.Rebuild(BuildAttribute.INVALID_LAST_BUILD_INFO)
|
||||
reporter.debug { "Last Kotlin Build info -- $lastBuildInfo" }
|
||||
val scopes = caches.lookupCache.lookupSymbols.map { it.scope.ifBlank { it.name } }.distinct()
|
||||
|
||||
@@ -548,7 +550,7 @@ var K2JVMCompilerArguments.destinationAsFile: File
|
||||
}
|
||||
|
||||
var K2JVMCompilerArguments.classpathAsList: List<File>
|
||||
get() = classpath.orEmpty().split(File.pathSeparator).map(::File)
|
||||
get() = classpath.orEmpty().map(::File)
|
||||
set(value) {
|
||||
classpath = value.joinToString(separator = File.pathSeparator, transform = { it.path })
|
||||
classpath = value.map { it.path }.toTypedArray()
|
||||
}
|
||||
|
||||
+4
-4
@@ -48,14 +48,14 @@ abstract class AbstractIncrementalJvmCompilerRunnerTest : AbstractIncrementalCom
|
||||
}
|
||||
if (javaSources.isEmpty()) return TestCompilationResult(ExitCode.OK, emptyList(), emptyList())
|
||||
|
||||
val javaClasspath = compileClasspath + File.pathSeparator + kotlinClassesPath
|
||||
val javaClasspath = compileClasspath + kotlinClassesPath
|
||||
val javaDestinationDir = File(workingDir, "java-classes").apply {
|
||||
if (exists()) {
|
||||
deleteRecursively()
|
||||
}
|
||||
mkdirs()
|
||||
}
|
||||
val args = arrayOf("-cp", javaClasspath,
|
||||
val args = arrayOf("-cp", javaClasspath.joinToString(File.pathSeparator),
|
||||
"-d", javaDestinationDir.canonicalPath,
|
||||
*javaSources.map { it.canonicalPath }.toTypedArray()
|
||||
)
|
||||
@@ -73,12 +73,12 @@ abstract class AbstractIncrementalJvmCompilerRunnerTest : AbstractIncrementalCom
|
||||
K2JVMCompilerArguments().apply {
|
||||
moduleName = testDir.name
|
||||
destination = destinationDir.path
|
||||
classpath = compileClasspath
|
||||
classpath = compileClasspath.toTypedArray()
|
||||
}
|
||||
|
||||
private val compileClasspath =
|
||||
listOf(
|
||||
kotlinStdlibJvm,
|
||||
KtTestUtil.getAnnotationsJar()
|
||||
).joinToString(File.pathSeparator) { it.canonicalPath }
|
||||
).map { it.canonicalPath }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user