Added support project settings in old kotlin2js compiler and made minor refactoring.

This commit is contained in:
Zalim Bashorov
2013-10-16 16:04:24 +04:00
parent fb8c9c2ef9
commit 5a28f4e158
11 changed files with 92 additions and 139 deletions
@@ -16,6 +16,8 @@
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;
@@ -66,12 +68,19 @@ public class ArgumentUtils {
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);
Class<?> fieldType = field.getType();
if (fieldType != boolean.class && fieldType != Boolean.class) {
result.add(value.toString());
}
if (fieldType == boolean.class || fieldType == Boolean.class) continue;
result.add(value.toString());
}
}
@@ -189,14 +189,14 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
@NotNull MessageRenderer messageRenderer
) {
if (arguments.printArgs) {
String freeArgs = StringUtil.join(arguments.freeArgs, " ");
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 compiler " + getClass().getName() +
" with arguments " + argumentsAsString + " " + freeArgs,
" with arguments " + argumentsAsString + freeArgs,
CompilerMessageLocation.NO_LOCATION);
errStream.println(printArgsMessage);
}
@@ -93,17 +93,17 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
reportCompiledSourcesList(messageCollector, environmentForJS);
}
Config config = getConfig(arguments, project);
if (analyzeAndReportErrors(messageCollector, environmentForJS.getSourceFiles(), config)) {
return COMPILATION_ERROR;
}
String outputFile = arguments.outputFile;
if (outputFile == null) {
messageCollector.report(CompilerMessageSeverity.ERROR, "Specify output file via -output", CompilerMessageLocation.NO_LOCATION);
return ExitCode.INTERNAL_ERROR;
}
Config config = getConfig(arguments, project);
if (analyzeAndReportErrors(messageCollector, environmentForJS.getSourceFiles(), config)) {
return COMPILATION_ERROR;
}
MainCallParameters mainCallParameters = createMainCallParameters(arguments.main);
return translateAndGenerateOutputFile(mainCallParameters, environmentForJS, config, outputFile);
}