CLI: add an extra MessageRenderer parameter to compiler exec

Is supposed to be used instead of the "-tags" CLI argument
This commit is contained in:
Alexander Udalov
2014-07-23 16:18:10 +04:00
parent 6258e08011
commit 4a7dc25406
4 changed files with 17 additions and 7 deletions
@@ -52,7 +52,17 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
if (!parseArguments(errStream, arguments, args)) {
return INTERNAL_ERROR;
}
return exec(errStream, arguments);
return exec(errStream, getMessageRenderer(arguments), arguments);
}
@SuppressWarnings("UnusedDeclaration") // Used via reflection in CompilerRunnerUtil#invokeExecMethod
@NotNull
public ExitCode execAndOutputHtml(@NotNull PrintStream errStream, @NotNull String... args) {
A arguments = createArguments();
if (!parseArguments(errStream, arguments, args)) {
return INTERNAL_ERROR;
}
return exec(errStream, MessageRenderer.TAGS, arguments);
}
/**
@@ -100,13 +110,12 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
* Executes the compiler on the parsed arguments
*/
@NotNull
public ExitCode exec(@NotNull PrintStream errStream, @NotNull A arguments) {
public ExitCode exec(@NotNull PrintStream errStream, @NotNull MessageRenderer messageRenderer, @NotNull A arguments) {
if (arguments.help || arguments.extraHelp) {
usage(errStream, arguments.extraHelp);
return OK;
}
MessageRenderer messageRenderer = getMessageRenderer(arguments);
errStream.print(messageRenderer.renderPreamble());
printVersionIfNeeded(errStream, arguments, messageRenderer);
@@ -17,7 +17,6 @@
package org.jetbrains.jet.compiler.runner;
import com.intellij.util.Function;
import kotlin.Function1;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.cli.common.messages.MessageCollector;
@@ -124,7 +123,7 @@ public class CompilerRunnerUtil {
: getOrCreateClassLoader(environment.getKotlinPaths(), messageCollector);
Class<?> kompiler = Class.forName(compilerClassName, true, loader);
Method exec = kompiler.getMethod("exec", PrintStream.class, String[].class);
Method exec = kompiler.getMethod("execAndOutputHtml", PrintStream.class, String[].class);
return exec.invoke(kompiler.newInstance(), out, arguments);
}
@@ -20,6 +20,7 @@ import com.google.common.collect.Lists;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.cli.common.ExitCode;
import org.jetbrains.jet.cli.common.arguments.K2JSCompilerArguments;
import org.jetbrains.jet.cli.common.messages.MessageRenderer;
import org.jetbrains.jet.cli.js.K2JSCompiler;
import org.jetbrains.k2js.config.EcmaVersion;
import org.jetbrains.k2js.test.SingleFileTranslationTest;
@@ -96,7 +97,7 @@ public class CompileMavenGeneratedJSLibrary extends SingleFileTranslationTest {
arguments.verbose = true;
arguments.libraryFiles = new String[] {generatedJsDefinitionsDir};
System.out.println("Compiling with version: " + version + " to: " + arguments.outputFile);
ExitCode answer = compiler.exec(System.out, arguments);
ExitCode answer = compiler.exec(System.out, MessageRenderer.PLAIN, arguments);
assertEquals("Compile failed", ExitCode.OK, answer);
}
}
@@ -21,6 +21,7 @@ import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.cli.common.ExitCode;
import org.jetbrains.jet.cli.common.arguments.K2JSCompilerArguments;
import org.jetbrains.jet.cli.common.messages.MessageRenderer;
import org.jetbrains.jet.cli.js.K2JSCompiler;
import org.jetbrains.k2js.config.EcmaVersion;
import org.jetbrains.k2js.test.SingleFileTranslationTest;
@@ -74,7 +75,7 @@ abstract class StdLibTestBase extends SingleFileTranslationTest {
arguments.verbose = true;
arguments.libraryFiles = ArrayUtil.toStringArray(libFiles);
System.out.println("Compiling with version: " + version + " to: " + arguments.outputFile);
ExitCode answer = compiler.exec(System.out, arguments);
ExitCode answer = compiler.exec(System.out, MessageRenderer.PLAIN, arguments);
assertEquals("Compile failed", ExitCode.OK, answer);
}