Drop "-printArgs"
This commit is contained in:
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.sampullara.cli;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ComparatorUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
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);
|
||||
}
|
||||
|
||||
private static <T> void convertArgumentsToStringList(T arguments, T defaultArguments, Class clazz, List<String> result) {
|
||||
Class superClazz = clazz.getSuperclass();
|
||||
if (superClazz != null) {
|
||||
convertArgumentsToStringList(arguments, defaultArguments, superClazz, result);
|
||||
}
|
||||
|
||||
for (Field field : clazz.getDeclaredFields()) {
|
||||
Argument argument = field.getAnnotation(Argument.class);
|
||||
if (argument == null) continue;
|
||||
|
||||
Object value;
|
||||
Object defaultValue;
|
||||
try {
|
||||
value = field.get(arguments);
|
||||
defaultValue = field.get(defaultArguments);
|
||||
}
|
||||
catch (IllegalAccessException ignored) {
|
||||
// skip this field
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ComparatorUtil.equalsNullable(value, defaultValue)) continue;
|
||||
|
||||
String name = Args.getAlias(argument);
|
||||
if (name == null) {
|
||||
name = Args.getName(argument, field);
|
||||
}
|
||||
|
||||
Class<?> fieldType = field.getType();
|
||||
|
||||
if (fieldType.isArray()) {
|
||||
Object[] values = (Object[]) value;
|
||||
if (values.length == 0) continue;
|
||||
value = StringUtil.join(values, Function.TO_STRING, argument.delimiter());
|
||||
}
|
||||
|
||||
result.add(argument.prefix() + name);
|
||||
|
||||
if (fieldType == boolean.class || fieldType == Boolean.class) continue;
|
||||
|
||||
result.add(value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
-3
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user