From 7e7e779e8027acae2d3da75bd2c459a9721bf39b Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Tue, 13 Nov 2012 17:32:53 +0400 Subject: [PATCH] No printing of verbose compiler output in Ant task and REPL --- .../jet/buildtools/core/BytecodeCompiler.java | 6 +++--- .../cli/common/messages/MessageCollector.java | 2 +- .../MessageCollectorPlainTextToStream.java | 16 ++++++++++++++-- .../messages/MessageCollectorToString.java | 4 ++-- .../data/antTaskJvm/build.log.expected | 4 ---- .../org/jetbrains/jet/codegen/TestlibTest.java | 4 ++-- 6 files changed, 22 insertions(+), 14 deletions(-) diff --git a/build-tools/core/src/org/jetbrains/jet/buildtools/core/BytecodeCompiler.java b/build-tools/core/src/org/jetbrains/jet/buildtools/core/BytecodeCompiler.java index 3d4f6314698..bdd41294c5c 100644 --- a/build-tools/core/src/org/jetbrains/jet/buildtools/core/BytecodeCompiler.java +++ b/build-tools/core/src/org/jetbrains/jet/buildtools/core/BytecodeCompiler.java @@ -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 modules = CompileEnvironmentUtil.loadModuleScript(module, MessageCollector.PLAIN_TEXT_TO_SYSTEM_ERR); + List modules = CompileEnvironmentUtil.loadModuleScript(module, MessageCollectorPlainTextToStream.PLAIN_TEXT_TO_SYSTEM_ERR); List sourcesRoots = new ArrayList(); for (Module m : modules) { sourcesRoots.addAll(m.getSourceFiles()); diff --git a/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/messages/MessageCollector.java b/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/messages/MessageCollector.java index ab50ebec593..a1ff69d1fbb 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/messages/MessageCollector.java +++ b/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/messages/MessageCollector.java @@ -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); + } diff --git a/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/messages/MessageCollectorPlainTextToStream.java b/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/messages/MessageCollectorPlainTextToStream.java index 6be25bbb609..650f98f3c24 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/messages/MessageCollectorPlainTextToStream.java +++ b/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/messages/MessageCollectorPlainTextToStream.java @@ -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 VERBOSE = EnumSet.of(CompilerMessageSeverity.LOGGING, CompilerMessageSeverity.OUTPUT); + public static final EnumSet 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 severitiesToPrint; - public MessageCollectorPlainTextToStream(@NotNull PrintStream stream) { + public MessageCollectorPlainTextToStream(@NotNull PrintStream stream, @NotNull Set 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)); + } } } diff --git a/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/messages/MessageCollectorToString.java b/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/messages/MessageCollectorToString.java index 3ee9fd1184a..6f03c7052ab 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/messages/MessageCollectorToString.java +++ b/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/messages/MessageCollectorToString.java @@ -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) { diff --git a/compiler/integration-tests/data/antTaskJvm/build.log.expected b/compiler/integration-tests/data/antTaskJvm/build.log.expected index 5e63dc27348..a3246c43289 100644 --- a/compiler/integration-tests/data/antTaskJvm/build.log.expected +++ b/compiler/integration-tests/data/antTaskJvm/build.log.expected @@ -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] diff --git a/compiler/tests/org/jetbrains/jet/codegen/TestlibTest.java b/compiler/tests/org/jetbrains/jet/codegen/TestlibTest.java index fcb447a0c0d..c602eb1d6b0 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/TestlibTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/TestlibTest.java @@ -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); }