diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonToolArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonToolArguments.kt index 37f6bba396e..6d3a0458e46 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonToolArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonToolArguments.kt @@ -16,7 +16,6 @@ package org.jetbrains.kotlin.cli.common.arguments -import org.jetbrains.kotlin.utils.SmartList import java.io.Serializable abstract class CommonToolArguments : Freezable(), Serializable { @@ -24,7 +23,7 @@ abstract class CommonToolArguments : Freezable(), Serializable { @JvmStatic private val serialVersionUID = 0L } - var freeArgs: MutableList = SmartList() + var freeArgs: List by FreezableVar(emptyList()) @Transient var errors: ArgumentParseErrors = ArgumentParseErrors() diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/parseCommandLineArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/parseCommandLineArguments.kt index 798fac15018..69ebfbb88d8 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/parseCommandLineArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/parseCommandLineArguments.kt @@ -16,7 +16,7 @@ package org.jetbrains.kotlin.cli.common.arguments -import com.intellij.util.SmartList +import org.jetbrains.kotlin.utils.SmartList import kotlin.reflect.KClass import kotlin.reflect.KMutableProperty1 import kotlin.reflect.full.findAnnotation @@ -100,12 +100,14 @@ fun parseCommandLineArguments(args: List, resu return argument.value == arg } + val freeArgs = ArrayList() + var i = 0 loop@ while (i < args.size) { val arg = args[i++] if (freeArgsStarted) { - result.freeArgs.add(arg) + freeArgs.add(arg) continue } if (arg == FREE_ARGS_DELIMITER) { @@ -118,7 +120,7 @@ fun parseCommandLineArguments(args: List, resu when { arg.startsWith(ADVANCED_ARGUMENT_PREFIX) -> errors.unknownExtraFlags.add(arg) arg.startsWith("-") -> errors.unknownArgs.add(arg) - else -> result.freeArgs.add(arg) + else -> freeArgs.add(arg) } continue } @@ -148,6 +150,8 @@ fun parseCommandLineArguments(args: List, resu updateField(property, result, value, argument.delimiter) } + + result.freeArgs += freeArgs } private fun updateField(property: KMutableProperty1, result: A, value: Any, delimiter: String) { diff --git a/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJsCompilerRunner.kt b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJsCompilerRunner.kt index 2b64a8c576c..4390a182a67 100644 --- a/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJsCompilerRunner.kt +++ b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJsCompilerRunner.kt @@ -121,10 +121,10 @@ class IncrementalJsCompilerRunner( services: Services, messageCollector: MessageCollector ): ExitCode { - val freeArgsBackup = args.freeArgs.toMutableList() + val freeArgsBackup = args.freeArgs try { - sourcesToCompile.mapTo(args.freeArgs) { it.absolutePath } + args.freeArgs += sourcesToCompile.map() { it.absolutePath } val exitCode = K2JSCompiler().exec(messageCollector, services, args) reporter.reportCompileIteration(sourcesToCompile, exitCode) return exitCode diff --git a/idea/idea-jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt b/idea/idea-jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt index 2b8938ea570..8551ed971f8 100644 --- a/idea/idea-jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt +++ b/idea/idea-jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt @@ -59,6 +59,7 @@ private fun readV1Config(element: Element): KotlinFacetSettings { val jsArgumentsElement = compilerInfoElement?.getOptionBody("k2jsCompilerArguments") val compilerArguments = targetPlatform.createCompilerArguments() + compilerArguments.freeArgs = ArrayList() commonArgumentsElement?.let { XmlSerializer.deserializeInto(compilerArguments, it) } when (compilerArguments) { diff --git a/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractLookupTrackerTest.kt b/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractLookupTrackerTest.kt index 65b22374dee..c281bc1346e 100644 --- a/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractLookupTrackerTest.kt +++ b/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractLookupTrackerTest.kt @@ -138,7 +138,7 @@ abstract class AbstractJsLookupTrackerTest : AbstractLookupTrackerTest() { val args = K2JSCompilerArguments().apply { outputFile = File(outDir, "out.js").canonicalPath reportOutputFiles = true - freeArgs.addAll(filesToCompile.map { it.canonicalPath }) + freeArgs = filesToCompile.map { it.canonicalPath } } return runJSCompiler(args, env) } diff --git a/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/incremental/AbstractJsProtoComparisonTest.kt b/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/incremental/AbstractJsProtoComparisonTest.kt index 0d501069908..bbf76b06404 100644 --- a/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/incremental/AbstractJsProtoComparisonTest.kt +++ b/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/incremental/AbstractJsProtoComparisonTest.kt @@ -56,7 +56,7 @@ abstract class AbstractJsProtoComparisonTest : AbstractProtoComparisonTest is important because in Groovy a GString can be inside of a list val freeArgs = (freeCompilerArgs as List).map(Any::toString) - args.freeArgs.addAll(freeArgs) + args.freeArgs += freeArgs } \ No newline at end of file