Drop "-printArgs"

This commit is contained in:
Alexander Udalov
2014-07-22 16:34:38 +04:00
parent cb80f95cab
commit 125c5e2942
15 changed files with 15 additions and 65 deletions
@@ -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<String> freeArgs = new SmartList<String>();
public boolean suppressAllWarnings() {
@@ -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<A extends CommonCompilerArguments> {
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<A extends CommonCompilerArguments> {
}
}
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<String> 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
*/
-1
View File
@@ -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
@@ -1,5 +0,0 @@
-printArgs
-sourceFiles
$TESTDATA_DIR$/simple2js.kt,$TESTDATA_DIR$/../warnings.kt
-suppress
warnings
@@ -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
-1
View File
@@ -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
-1
View File
@@ -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
-1
View File
@@ -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
@@ -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
@@ -1,3 +0,0 @@
-printArgs
-script
$TESTDATA_DIR$/hello.kts
@@ -1,3 +0,0 @@
INFO: Invoking K2JVMCompiler with arguments -printArgs -script compiler/testData/cli/jvm/hello.kts
hello
OK
@@ -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
@@ -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");
@@ -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 <T> List<String> convertArgumentsToStringList(@NotNull T arguments, @NotNull T defaultArguments) {
List<String> result = new ArrayList<String>();
convertArgumentsToStringList(arguments, defaultArguments, result);
return result;
}
public static <T> void convertArgumentsToStringList(@NotNull T arguments, @NotNull T defaultArguments, @NotNull List<String> result) {
convertArgumentsToStringList(arguments, defaultArguments, arguments.getClass(), result);
return result;
}
private static <T> void convertArgumentsToStringList(T arguments, T defaultArguments, Class clazz, List<String> 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;
}
}
@@ -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;