From 125c5e2942616f1098e374e34a8bc0bf989e6b3c Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Tue, 22 Jul 2014 16:34:38 +0400 Subject: [PATCH] Drop "-printArgs" --- .../arguments/CommonCompilerArguments.java | 3 --- .../jetbrains/jet/cli/common/CLICompiler.java | 22 ----------------- compiler/testData/cli/js/jsHelp.out | 1 - .../cli/js/printArgumentsWithManyValue.args | 5 ---- .../cli/js/printArgumentsWithManyValue.out | 3 --- compiler/testData/cli/jvm/help.out | 1 - compiler/testData/cli/jvm/inline/off.out | 1 - compiler/testData/cli/jvm/inline/on.out | 1 - compiler/testData/cli/jvm/inline/wrong.out | 1 - compiler/testData/cli/jvm/printArguments.args | 3 --- compiler/testData/cli/jvm/printArguments.out | 3 --- compiler/testData/cli/jvm/wrongArgument.out | 1 - .../cli/KotlincExecutableTestGenerated.java | 10 -------- .../jet/compiler/runner}/ArgumentUtils.java | 24 ++++++++++++------- .../compiler/runner/KotlinCompilerRunner.java | 1 - 15 files changed, 15 insertions(+), 65 deletions(-) delete mode 100644 compiler/testData/cli/js/printArgumentsWithManyValue.args delete mode 100644 compiler/testData/cli/js/printArgumentsWithManyValue.out delete mode 100644 compiler/testData/cli/jvm/printArguments.args delete mode 100644 compiler/testData/cli/jvm/printArguments.out rename {compiler/cli/cli-common/src/com/sampullara/cli => ide-compiler-runner/src/org/jetbrains/jet/compiler/runner}/ArgumentUtils.java (83%) diff --git a/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/CommonCompilerArguments.java b/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/CommonCompilerArguments.java index d941f9c1cc0..f46fd1442c2 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/CommonCompilerArguments.java +++ b/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/CommonCompilerArguments.java @@ -41,9 +41,6 @@ public abstract class CommonCompilerArguments { @ValueDescription(SUPPRESS_WARNINGS) public String suppress; - @Argument(value = "printArgs", description = "Print command line arguments") - public boolean printArgs; - public List freeArgs = new SmartList(); public boolean suppressAllWarnings() { diff --git a/compiler/cli/src/org/jetbrains/jet/cli/common/CLICompiler.java b/compiler/cli/src/org/jetbrains/jet/cli/common/CLICompiler.java index 48903beb40b..3e1ab10e3e3 100644 --- a/compiler/cli/src/org/jetbrains/jet/cli/common/CLICompiler.java +++ b/compiler/cli/src/org/jetbrains/jet/cli/common/CLICompiler.java @@ -20,9 +20,7 @@ import com.google.common.base.Predicates; import com.google.common.collect.Lists; import com.intellij.openapi.Disposable; import com.intellij.openapi.util.Disposer; -import com.intellij.openapi.util.text.StringUtil; import com.sampullara.cli.Args; -import com.sampullara.cli.ArgumentUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.cli.common.arguments.CommonCompilerArguments; import org.jetbrains.jet.cli.common.messages.*; @@ -112,7 +110,6 @@ public abstract class CLICompiler { MessageRenderer messageRenderer = getMessageRenderer(arguments); errStream.print(messageRenderer.renderPreamble()); - printArgumentsIfNeeded(errStream, arguments, messageRenderer); printVersionIfNeeded(errStream, arguments, messageRenderer); MessageCollector collector = new PrintingMessageCollector(errStream, messageRenderer, arguments.verbose); @@ -175,25 +172,6 @@ public abstract class CLICompiler { } } - private void printArgumentsIfNeeded( - @NotNull PrintStream errStream, - @NotNull A arguments, - @NotNull MessageRenderer messageRenderer - ) { - if (arguments.printArgs) { - String freeArgs = !arguments.freeArgs.isEmpty() ? " " + StringUtil.join(arguments.freeArgs, " ") : ""; - - List argumentsAsList = ArgumentUtils.convertArgumentsToStringList(arguments, createArguments()); - String argumentsAsString = StringUtil.join(argumentsAsList, " "); - - String printArgsMessage = messageRenderer.render(CompilerMessageSeverity.INFO, - "Invoking " + getClass().getSimpleName() + - " with arguments " + argumentsAsString + freeArgs, - CompilerMessageLocation.NO_LOCATION); - errStream.println(printArgsMessage); - } - } - /** * Useful main for derived command line tools */ diff --git a/compiler/testData/cli/js/jsHelp.out b/compiler/testData/cli/js/jsHelp.out index 8641c254d2a..c7779a9f2f9 100644 --- a/compiler/testData/cli/js/jsHelp.out +++ b/compiler/testData/cli/js/jsHelp.out @@ -13,5 +13,4 @@ where possible options include: -version Display compiler version -help (-h) Print a synopsis of standard options -suppress warnings Suppress all compiler warnings - -printArgs Print command line arguments OK \ No newline at end of file diff --git a/compiler/testData/cli/js/printArgumentsWithManyValue.args b/compiler/testData/cli/js/printArgumentsWithManyValue.args deleted file mode 100644 index 279663f1d66..00000000000 --- a/compiler/testData/cli/js/printArgumentsWithManyValue.args +++ /dev/null @@ -1,5 +0,0 @@ --printArgs --sourceFiles -$TESTDATA_DIR$/simple2js.kt,$TESTDATA_DIR$/../warnings.kt --suppress -warnings \ No newline at end of file diff --git a/compiler/testData/cli/js/printArgumentsWithManyValue.out b/compiler/testData/cli/js/printArgumentsWithManyValue.out deleted file mode 100644 index f200514cb24..00000000000 --- a/compiler/testData/cli/js/printArgumentsWithManyValue.out +++ /dev/null @@ -1,3 +0,0 @@ -INFO: Invoking K2JSCompiler with arguments -suppress warnings -printArgs -sourceFiles compiler/testData/cli/js/simple2js.kt,compiler/testData/cli/js/../warnings.kt -ERROR: Specify output file via -output -COMPILATION_ERROR diff --git a/compiler/testData/cli/jvm/help.out b/compiler/testData/cli/jvm/help.out index 96b7bfa7125..15e4e57c349 100644 --- a/compiler/testData/cli/jvm/help.out +++ b/compiler/testData/cli/jvm/help.out @@ -21,5 +21,4 @@ where possible options include: -version Display compiler version -help (-h) Print a synopsis of standard options -suppress warnings Suppress all compiler warnings - -printArgs Print command line arguments OK \ No newline at end of file diff --git a/compiler/testData/cli/jvm/inline/off.out b/compiler/testData/cli/jvm/inline/off.out index 96b7bfa7125..15e4e57c349 100644 --- a/compiler/testData/cli/jvm/inline/off.out +++ b/compiler/testData/cli/jvm/inline/off.out @@ -21,5 +21,4 @@ where possible options include: -version Display compiler version -help (-h) Print a synopsis of standard options -suppress warnings Suppress all compiler warnings - -printArgs Print command line arguments OK \ No newline at end of file diff --git a/compiler/testData/cli/jvm/inline/on.out b/compiler/testData/cli/jvm/inline/on.out index 96b7bfa7125..15e4e57c349 100644 --- a/compiler/testData/cli/jvm/inline/on.out +++ b/compiler/testData/cli/jvm/inline/on.out @@ -21,5 +21,4 @@ where possible options include: -version Display compiler version -help (-h) Print a synopsis of standard options -suppress warnings Suppress all compiler warnings - -printArgs Print command line arguments OK \ No newline at end of file diff --git a/compiler/testData/cli/jvm/inline/wrong.out b/compiler/testData/cli/jvm/inline/wrong.out index ee92bc7bce7..5ea4db25645 100644 --- a/compiler/testData/cli/jvm/inline/wrong.out +++ b/compiler/testData/cli/jvm/inline/wrong.out @@ -22,5 +22,4 @@ where possible options include: -version Display compiler version -help (-h) Print a synopsis of standard options -suppress warnings Suppress all compiler warnings - -printArgs Print command line arguments INTERNAL_ERROR \ No newline at end of file diff --git a/compiler/testData/cli/jvm/printArguments.args b/compiler/testData/cli/jvm/printArguments.args deleted file mode 100644 index a32d2e7c5ba..00000000000 --- a/compiler/testData/cli/jvm/printArguments.args +++ /dev/null @@ -1,3 +0,0 @@ --printArgs --script -$TESTDATA_DIR$/hello.kts \ No newline at end of file diff --git a/compiler/testData/cli/jvm/printArguments.out b/compiler/testData/cli/jvm/printArguments.out deleted file mode 100644 index 94f0cb25018..00000000000 --- a/compiler/testData/cli/jvm/printArguments.out +++ /dev/null @@ -1,3 +0,0 @@ -INFO: Invoking K2JVMCompiler with arguments -printArgs -script compiler/testData/cli/jvm/hello.kts -hello -OK diff --git a/compiler/testData/cli/jvm/wrongArgument.out b/compiler/testData/cli/jvm/wrongArgument.out index be0548be9ff..ab56530c4ce 100644 --- a/compiler/testData/cli/jvm/wrongArgument.out +++ b/compiler/testData/cli/jvm/wrongArgument.out @@ -22,5 +22,4 @@ where possible options include: -version Display compiler version -help (-h) Print a synopsis of standard options -suppress warnings Suppress all compiler warnings - -printArgs Print command line arguments INTERNAL_ERROR \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/cli/KotlincExecutableTestGenerated.java b/compiler/tests/org/jetbrains/jet/cli/KotlincExecutableTestGenerated.java index 6e2d05507ec..937f6a0ed59 100644 --- a/compiler/tests/org/jetbrains/jet/cli/KotlincExecutableTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/cli/KotlincExecutableTestGenerated.java @@ -74,11 +74,6 @@ public class KotlincExecutableTestGenerated extends AbstractKotlincExecutableTes doJvmTest("compiler/testData/cli/jvm/nonExistingSourcePath.args"); } - @TestMetadata("printArguments.args") - public void testPrintArguments() throws Exception { - doJvmTest("compiler/testData/cli/jvm/printArguments.args"); - } - @TestMetadata("signatureClash.args") public void testSignatureClash() throws Exception { doJvmTest("compiler/testData/cli/jvm/signatureClash.args"); @@ -181,11 +176,6 @@ public class KotlincExecutableTestGenerated extends AbstractKotlincExecutableTes doJsTest("compiler/testData/cli/js/outputPrefixFileNotFound.args"); } - @TestMetadata("printArgumentsWithManyValue.args") - public void testPrintArgumentsWithManyValue() throws Exception { - doJsTest("compiler/testData/cli/js/printArgumentsWithManyValue.args"); - } - @TestMetadata("simple2js.args") public void testSimple2js() throws Exception { doJsTest("compiler/testData/cli/js/simple2js.args"); diff --git a/compiler/cli/cli-common/src/com/sampullara/cli/ArgumentUtils.java b/ide-compiler-runner/src/org/jetbrains/jet/compiler/runner/ArgumentUtils.java similarity index 83% rename from compiler/cli/cli-common/src/com/sampullara/cli/ArgumentUtils.java rename to ide-compiler-runner/src/org/jetbrains/jet/compiler/runner/ArgumentUtils.java index 51e2ff854d7..1759ed9d899 100644 --- a/compiler/cli/cli-common/src/com/sampullara/cli/ArgumentUtils.java +++ b/ide-compiler-runner/src/org/jetbrains/jet/compiler/runner/ArgumentUtils.java @@ -14,11 +14,12 @@ * limitations under the License. */ -package com.sampullara.cli; +package org.jetbrains.jet.compiler.runner; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.Function; import com.intellij.util.containers.ComparatorUtil; +import com.sampullara.cli.Argument; import org.jetbrains.annotations.NotNull; import java.lang.reflect.Field; @@ -26,18 +27,13 @@ import java.util.ArrayList; import java.util.List; public class ArgumentUtils { - private ArgumentUtils() {} @NotNull public static List convertArgumentsToStringList(@NotNull T arguments, @NotNull T defaultArguments) { List result = new ArrayList(); - convertArgumentsToStringList(arguments, defaultArguments, result); - return result; - } - - public static void convertArgumentsToStringList(@NotNull T arguments, @NotNull T defaultArguments, @NotNull List result) { convertArgumentsToStringList(arguments, defaultArguments, arguments.getClass(), result); + return result; } private static void convertArgumentsToStringList(T arguments, T defaultArguments, Class clazz, List result) { @@ -63,9 +59,9 @@ public class ArgumentUtils { if (ComparatorUtil.equalsNullable(value, defaultValue)) continue; - String name = Args.getAlias(argument); + String name = getAlias(argument); if (name == null) { - name = Args.getName(argument, field); + name = getName(argument, field); } Class fieldType = field.getType(); @@ -73,6 +69,7 @@ public class ArgumentUtils { if (fieldType.isArray()) { Object[] values = (Object[]) value; if (values.length == 0) continue; + //noinspection unchecked value = StringUtil.join(values, Function.TO_STRING, argument.delimiter()); } @@ -84,4 +81,13 @@ public class ArgumentUtils { } } + private static String getAlias(Argument argument) { + String alias = argument.alias(); + return alias.isEmpty() ? null : alias; + } + + private static String getName(Argument argument, Field field) { + String name = argument.value(); + return name.isEmpty() ? field.getName() : name; + } } diff --git a/ide-compiler-runner/src/org/jetbrains/jet/compiler/runner/KotlinCompilerRunner.java b/ide-compiler-runner/src/org/jetbrains/jet/compiler/runner/KotlinCompilerRunner.java index 65babb4903c..acc439c8b84 100644 --- a/ide-compiler-runner/src/org/jetbrains/jet/compiler/runner/KotlinCompilerRunner.java +++ b/ide-compiler-runner/src/org/jetbrains/jet/compiler/runner/KotlinCompilerRunner.java @@ -22,7 +22,6 @@ import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.xmlb.Accessor; import com.intellij.util.xmlb.XmlSerializerUtil; -import com.sampullara.cli.ArgumentUtils; import org.jetbrains.jet.cli.common.arguments.CommonCompilerArguments; import org.jetbrains.jet.cli.common.arguments.K2JSCompilerArguments; import org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments;