Refactor JPS daemon client
This commit is contained in:
+14
@@ -17,10 +17,24 @@
|
||||
package org.jetbrains.kotlin.cli.common.arguments
|
||||
|
||||
import com.intellij.util.xmlb.XmlSerializerUtil
|
||||
import com.sampullara.cli.Args
|
||||
import java.lang.reflect.Field
|
||||
import java.lang.reflect.Modifier
|
||||
import java.util.*
|
||||
|
||||
fun <A : CommonCompilerArguments> parseArguments(args: Array<String>, arguments: A) {
|
||||
val unparsedArgs = Args.parse(arguments, args, false).partition { it.startsWith("-X") }
|
||||
|
||||
arguments.unknownExtraFlags = unparsedArgs.first
|
||||
arguments.freeArgs = unparsedArgs.second
|
||||
|
||||
for (argument in arguments.freeArgs) {
|
||||
if (argument.startsWith("-")) {
|
||||
throw IllegalArgumentException("Invalid argument: " + argument)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun <T : Any> copyBean(bean: T) = copyFields(bean, bean.javaClass.newInstance(), true)
|
||||
|
||||
fun <From : Any, To : From> mergeBeans(from: From, to: To): To {
|
||||
|
||||
@@ -30,6 +30,7 @@ import kotlin.jvm.functions.Function1;
|
||||
import org.fusesource.jansi.AnsiConsole;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.cli.common.arguments.ArgumentUtilsKt;
|
||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments;
|
||||
import org.jetbrains.kotlin.cli.common.messages.*;
|
||||
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler;
|
||||
@@ -103,22 +104,7 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
||||
|
||||
@SuppressWarnings("WeakerAccess") // Used in maven (see KotlinCompileMojoBase.java)
|
||||
public void parseArguments(@NotNull String[] args, @NotNull A arguments) {
|
||||
Pair<List<String>, List<String>> unparsedArgs =
|
||||
CollectionsKt.partition(Args.parse(arguments, args, false), new Function1<String, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(String s) {
|
||||
return s.startsWith("-X");
|
||||
}
|
||||
});
|
||||
|
||||
arguments.unknownExtraFlags = unparsedArgs.getFirst();
|
||||
arguments.freeArgs = unparsedArgs.getSecond();
|
||||
|
||||
for (String argument : arguments.freeArgs) {
|
||||
if (argument.startsWith("-")) {
|
||||
throw new IllegalArgumentException("Invalid argument: " + argument);
|
||||
}
|
||||
}
|
||||
ArgumentUtilsKt.parseArguments(args, arguments);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user