No printing of verbose compiler output in Ant task and REPL

This commit is contained in:
Andrey Breslav
2012-11-13 17:32:53 +04:00
parent 31b28cec92
commit 7e7e779e80
6 changed files with 22 additions and 14 deletions
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.cli.common.CLIConfigurationKeys;
import org.jetbrains.jet.cli.common.CompilerPlugin;
import org.jetbrains.jet.cli.common.messages.MessageCollector;
import org.jetbrains.jet.cli.common.messages.MessageCollectorPlainTextToStream;
import org.jetbrains.jet.cli.jvm.compiler.*;
import org.jetbrains.jet.config.CommonConfigurationKeys;
import org.jetbrains.jet.config.CompilerConfiguration;
@@ -84,7 +84,7 @@ public class BytecodeCompiler {
}
configuration.addAll(CommonConfigurationKeys.SOURCE_ROOTS_KEY, Arrays.asList(sourceRoots));
configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.PLAIN_TEXT_TO_SYSTEM_ERR);
configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollectorPlainTextToStream.PLAIN_TEXT_TO_SYSTEM_ERR);
// lets register any compiler plugins
configuration.addAll(CLIConfigurationKeys.COMPILER_PLUGINS, getCompilerPlugins());
@@ -172,7 +172,7 @@ public class BytecodeCompiler {
@Nullable String stdlib,
@Nullable String[] classpath) {
try {
List<Module> modules = CompileEnvironmentUtil.loadModuleScript(module, MessageCollector.PLAIN_TEXT_TO_SYSTEM_ERR);
List<Module> modules = CompileEnvironmentUtil.loadModuleScript(module, MessageCollectorPlainTextToStream.PLAIN_TEXT_TO_SYSTEM_ERR);
List<String> sourcesRoots = new ArrayList<String>();
for (Module m : modules) {
sourcesRoots.addAll(m.getSourceFiles());
@@ -19,8 +19,8 @@ package org.jetbrains.jet.cli.common.messages;
import org.jetbrains.annotations.NotNull;
public interface MessageCollector {
MessageCollector PLAIN_TEXT_TO_SYSTEM_ERR = new MessageCollectorPlainTextToStream(System.err);
void report(@NotNull CompilerMessageSeverity severity, @NotNull String message, @NotNull CompilerMessageLocation location);
}
@@ -19,21 +19,33 @@ package org.jetbrains.jet.cli.common.messages;
import org.jetbrains.annotations.NotNull;
import java.io.PrintStream;
import java.util.EnumSet;
import java.util.Set;
/**
* @author Stepan Koltsov
*/
public class MessageCollectorPlainTextToStream implements MessageCollector {
public static final EnumSet<CompilerMessageSeverity> VERBOSE = EnumSet.of(CompilerMessageSeverity.LOGGING, CompilerMessageSeverity.OUTPUT);
public static final EnumSet<CompilerMessageSeverity> NON_VERBOSE = EnumSet.complementOf(VERBOSE);
public static final MessageCollector PLAIN_TEXT_TO_SYSTEM_ERR = new MessageCollectorPlainTextToStream(System.err, NON_VERBOSE);
@NotNull
private final PrintStream stream;
@NotNull
private final Set<CompilerMessageSeverity> severitiesToPrint;
public MessageCollectorPlainTextToStream(@NotNull PrintStream stream) {
public MessageCollectorPlainTextToStream(@NotNull PrintStream stream, @NotNull Set<CompilerMessageSeverity> severities) {
this.stream = stream;
this.severitiesToPrint = severities;
}
@Override
public void report(@NotNull CompilerMessageSeverity severity, @NotNull String message, @NotNull CompilerMessageLocation location) {
stream.println(MessageRenderer.PLAIN.render(severity, message, location));
if (severitiesToPrint.contains(severity)) {
stream.println(MessageRenderer.PLAIN.render(severity, message, location));
}
}
}
@@ -28,8 +28,8 @@ import java.nio.charset.Charset;
*/
public class MessageCollectorToString implements MessageCollector {
private final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
private final MessageCollector actualCollector = new MessageCollectorPlainTextToStream(new PrintStream(outputStream));
private final MessageCollector actualCollector = new MessageCollectorPlainTextToStream(new PrintStream(outputStream),
MessageCollectorPlainTextToStream.NON_VERBOSE);
@Override
public void report(@NotNull CompilerMessageSeverity severity, @NotNull String message, @NotNull CompilerMessageLocation location) {
@@ -2,10 +2,6 @@ OUT Buildfile: build.xml
OUT
OUT build:
OUT [kotlinc] Compiling [[TestData]/hello.kt] => [[Temp]/hello.jar]
OUT [kotlinc] OUTPUT: Output:
OUT [kotlinc] Hello/namespace.class
OUT [kotlinc] Sources:
OUT [kotlinc] [TestData]/hello.kt
OUT
OUT BUILD SUCCESSFUL
OUT Total time: [time]
@@ -25,7 +25,7 @@ import org.jetbrains.jet.ConfigurationKind;
import org.jetbrains.jet.JetTestUtils;
import org.jetbrains.jet.TestJdkKind;
import org.jetbrains.jet.cli.common.CLIConfigurationKeys;
import org.jetbrains.jet.cli.common.messages.MessageCollector;
import org.jetbrains.jet.cli.common.messages.MessageCollectorPlainTextToStream;
import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys;
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
import org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler;
@@ -166,7 +166,7 @@ public class TestlibTest extends CodegenTestCase {
configuration.add(CommonConfigurationKeys.SOURCE_ROOTS_KEY, JetParsingTest.getTestDataDir() + "/../../libraries/stdlib/test");
configuration.add(CommonConfigurationKeys.SOURCE_ROOTS_KEY, JetParsingTest.getTestDataDir() + "/../../libraries/kunit/src");
configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.PLAIN_TEXT_TO_SYSTEM_ERR);
configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollectorPlainTextToStream.PLAIN_TEXT_TO_SYSTEM_ERR);
myEnvironment = new JetCoreEnvironment(getTestRootDisposable(), configuration);
}