Minor, change parameter type of parseCommandLineArguments
This commit is contained in:
+1
-2
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.cli.common.arguments
|
|||||||
|
|
||||||
import com.intellij.util.SmartList
|
import com.intellij.util.SmartList
|
||||||
import java.lang.reflect.Field
|
import java.lang.reflect.Field
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
annotation class Argument(
|
annotation class Argument(
|
||||||
val value: String,
|
val value: String,
|
||||||
@@ -54,7 +53,7 @@ data class ArgumentParseErrors(
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Parses arguments into the passed [result] object. Errors related to the parsing will be collected into [CommonToolArguments.errors].
|
// Parses arguments into the passed [result] object. Errors related to the parsing will be collected into [CommonToolArguments.errors].
|
||||||
fun <A : CommonToolArguments> parseCommandLineArguments(args: Array<out String>, result: A) {
|
fun <A : CommonToolArguments> parseCommandLineArguments(args: List<String>, result: A) {
|
||||||
data class ArgumentField(val field: Field, val argument: Argument)
|
data class ArgumentField(val field: Field, val argument: Argument)
|
||||||
|
|
||||||
val fields = result::class.java.fields.mapNotNull { field ->
|
val fields = result::class.java.fields.mapNotNull { field ->
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ abstract class CLITool<A : CommonToolArguments> {
|
|||||||
K2JVMCompiler.resetInitStartTime()
|
K2JVMCompiler.resetInitStartTime()
|
||||||
|
|
||||||
val arguments = createArguments()
|
val arguments = createArguments()
|
||||||
parseCommandLineArguments(args, arguments)
|
parseCommandLineArguments(args.asList(), arguments)
|
||||||
val collector = PrintingMessageCollector(errStream, messageRenderer, arguments.verbose)
|
val collector = PrintingMessageCollector(errStream, messageRenderer, arguments.verbose)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -99,7 +99,7 @@ abstract class CLITool<A : CommonToolArguments> {
|
|||||||
|
|
||||||
// Used in kotlin-maven-plugin (KotlinCompileMojoBase) and in kotlin-gradle-plugin (KotlinJvmOptionsImpl, KotlinJsOptionsImpl)
|
// Used in kotlin-maven-plugin (KotlinCompileMojoBase) and in kotlin-gradle-plugin (KotlinJvmOptionsImpl, KotlinJsOptionsImpl)
|
||||||
fun parseArguments(args: Array<out String>, arguments: A) {
|
fun parseArguments(args: Array<out String>, arguments: A) {
|
||||||
parseCommandLineArguments(args, arguments)
|
parseCommandLineArguments(args.asList(), arguments)
|
||||||
val message = validateArguments(arguments.errors)
|
val message = validateArguments(arguments.errors)
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
throw IllegalArgumentException(message)
|
throw IllegalArgumentException(message)
|
||||||
|
|||||||
@@ -366,7 +366,7 @@ class CompileServiceImpl(
|
|||||||
} as CLICompiler<CommonCompilerArguments>
|
} as CLICompiler<CommonCompilerArguments>
|
||||||
|
|
||||||
val k2PlatformArgs = compiler.createArguments()
|
val k2PlatformArgs = compiler.createArguments()
|
||||||
parseCommandLineArguments(compilerArguments, k2PlatformArgs)
|
parseCommandLineArguments(compilerArguments.asList(), k2PlatformArgs)
|
||||||
val argumentParseError = validateArguments(k2PlatformArgs.errors)
|
val argumentParseError = validateArguments(k2PlatformArgs.errors)
|
||||||
if (argumentParseError != null) {
|
if (argumentParseError != null) {
|
||||||
messageCollector.report(CompilerMessageSeverity.ERROR, argumentParseError)
|
messageCollector.report(CompilerMessageSeverity.ERROR, argumentParseError)
|
||||||
|
|||||||
@@ -159,8 +159,8 @@ class KotlinMavenImporter : MavenImporter(KOTLIN_PLUGIN_GROUP_ID, KOTLIN_PLUGIN_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val additionalArgs = configuration?.getChild("args")?.getChildren("arg")?.mapNotNull { it.text } ?: emptyList()
|
val additionalArgs = configuration?.getChild("args")?.getChildren("arg")?.mapNotNull { it.text }.orEmpty()
|
||||||
parseCommandLineArguments(additionalArgs.toTypedArray(), arguments)
|
parseCommandLineArguments(additionalArgs, arguments)
|
||||||
|
|
||||||
return ArgumentUtils.convertArgumentsToStringList(arguments)
|
return ArgumentUtils.convertArgumentsToStringList(arguments)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,10 @@ import com.intellij.ui.HoverHyperlinkLabel
|
|||||||
import com.intellij.util.ui.FormBuilder
|
import com.intellij.util.ui.FormBuilder
|
||||||
import com.intellij.util.ui.ThreeStateCheckBox
|
import com.intellij.util.ui.ThreeStateCheckBox
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.*
|
import org.jetbrains.kotlin.cli.common.arguments.*
|
||||||
import org.jetbrains.kotlin.config.*
|
import org.jetbrains.kotlin.config.CompilerSettings
|
||||||
|
import org.jetbrains.kotlin.config.TargetPlatformKind
|
||||||
|
import org.jetbrains.kotlin.config.createCompilerArguments
|
||||||
|
import org.jetbrains.kotlin.config.splitArgumentString
|
||||||
import org.jetbrains.kotlin.idea.compiler.configuration.*
|
import org.jetbrains.kotlin.idea.compiler.configuration.*
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||||
import java.awt.BorderLayout
|
import java.awt.BorderLayout
|
||||||
@@ -160,9 +163,7 @@ class KotlinFacetEditorGeneralTab(
|
|||||||
}
|
}
|
||||||
val argumentClass = primaryArguments.javaClass
|
val argumentClass = primaryArguments.javaClass
|
||||||
val additionalArguments = argumentClass.newInstance().apply {
|
val additionalArguments = argumentClass.newInstance().apply {
|
||||||
parseCommandLineArguments(
|
parseCommandLineArguments(splitArgumentString(editor.compilerConfigurable.additionalArgsOptionsField.text), this)
|
||||||
splitArgumentString(editor.compilerConfigurable.additionalArgsOptionsField.text).toTypedArray(), this
|
|
||||||
)
|
|
||||||
validateArguments(errors)?.let { message -> return ValidationResult(message) }
|
validateArguments(errors)?.let { message -> return ValidationResult(message) }
|
||||||
}
|
}
|
||||||
val emptyArguments = argumentClass.newInstance()
|
val emptyArguments = argumentClass.newInstance()
|
||||||
|
|||||||
@@ -200,16 +200,14 @@ fun parseCompilerArgumentsToFacet(
|
|||||||
kotlinFacet: KotlinFacet,
|
kotlinFacet: KotlinFacet,
|
||||||
modelsProvider: IdeModifiableModelsProvider
|
modelsProvider: IdeModifiableModelsProvider
|
||||||
) {
|
) {
|
||||||
val argumentArray = arguments.toTypedArray()
|
|
||||||
|
|
||||||
with(kotlinFacet.configuration.settings) {
|
with(kotlinFacet.configuration.settings) {
|
||||||
val compilerArguments = this.compilerArguments ?: return
|
val compilerArguments = this.compilerArguments ?: return
|
||||||
|
|
||||||
val defaultCompilerArguments = compilerArguments::class.java.newInstance()
|
val defaultCompilerArguments = compilerArguments::class.java.newInstance()
|
||||||
parseCommandLineArguments(defaultArguments.toTypedArray(), defaultCompilerArguments)
|
parseCommandLineArguments(defaultArguments, defaultCompilerArguments)
|
||||||
defaultCompilerArguments.convertPathsToSystemIndependent()
|
defaultCompilerArguments.convertPathsToSystemIndependent()
|
||||||
|
|
||||||
parseCommandLineArguments(argumentArray, compilerArguments)
|
parseCommandLineArguments(arguments, compilerArguments)
|
||||||
|
|
||||||
compilerArguments.convertPathsToSystemIndependent()
|
compilerArguments.convertPathsToSystemIndependent()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user