diff --git a/ide-compiler-runner/src/org/jetbrains/jet/compiler/runner/CompilerOutputParser.java b/ide-compiler-runner/src/org/jetbrains/jet/compiler/runner/CompilerOutputParser.java index 4662cd35d08..359ea425c4f 100644 --- a/ide-compiler-runner/src/org/jetbrains/jet/compiler/runner/CompilerOutputParser.java +++ b/ide-compiler-runner/src/org/jetbrains/jet/compiler/runner/CompilerOutputParser.java @@ -104,7 +104,7 @@ public class CompilerOutputParser { .put("warning", WARNING) .put("logging", LOGGING) .put("output", OUTPUT) - .put("exception", ERROR) + .put("exception", EXCEPTION) .put("info", INFO) .put("messages", INFO) // Root XML element .build(); diff --git a/ide-compiler-runner/src/org/jetbrains/jet/compiler/runner/CompilerRunnerConstants.java b/ide-compiler-runner/src/org/jetbrains/jet/compiler/runner/CompilerRunnerConstants.java new file mode 100644 index 00000000000..94dd31d8fc2 --- /dev/null +++ b/ide-compiler-runner/src/org/jetbrains/jet/compiler/runner/CompilerRunnerConstants.java @@ -0,0 +1,22 @@ +/* + * Copyright 2010-2012 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 org.jetbrains.jet.compiler.runner; + +public class CompilerRunnerConstants { + public static final String KOTLIN_COMPILER_NAME = "Kotlin"; + public static final String INTERNAL_ERROR_PREFIX = "[Internal Error] "; +} diff --git a/idea/src/org/jetbrains/jet/plugin/compiler/JetCompilerManager.java b/idea/src/org/jetbrains/jet/plugin/compiler/JetCompilerManager.java index 71fd5b79333..45935dcbcbb 100644 --- a/idea/src/org/jetbrains/jet/plugin/compiler/JetCompilerManager.java +++ b/idea/src/org/jetbrains/jet/plugin/compiler/JetCompilerManager.java @@ -16,20 +16,30 @@ package org.jetbrains.jet.plugin.compiler; -import com.intellij.openapi.compiler.CompilerManager; +import com.intellij.openapi.compiler.*; import com.intellij.openapi.components.ProjectComponent; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.fileTypes.StdFileTypes; +import com.intellij.openapi.project.Project; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.plugin.JetFileType; import java.util.Collections; +import static org.jetbrains.jet.compiler.runner.CompilerRunnerConstants.INTERNAL_ERROR_PREFIX; +import static org.jetbrains.jet.compiler.runner.CompilerRunnerConstants.KOTLIN_COMPILER_NAME; + /** * @author yole */ public class JetCompilerManager implements ProjectComponent { - public JetCompilerManager(CompilerManager manager) { + private static final Logger LOG = Logger.getInstance(JetCompilerManager.class); + + // Comes from external make + private static final String PREFIX_WITH_COMPILER_NAME = KOTLIN_COMPILER_NAME + ": " + INTERNAL_ERROR_PREFIX; + + public JetCompilerManager(Project project, CompilerManager manager) { manager.addTranslatingCompiler(new JetCompiler(), Collections.singleton(JetFileType.INSTANCE), Collections.singleton(StdFileTypes.CLASS)); @@ -37,6 +47,24 @@ public class JetCompilerManager implements ProjectComponent { Collections.singleton(JetFileType.INSTANCE), Collections.singleton(StdFileTypes.JS)); manager.addCompilableFileType(JetFileType.INSTANCE); + + manager.addCompilationStatusListener(new CompilationStatusListener() { + @Override + public void compilationFinished( + boolean aborted, int errors, int warnings, CompileContext compileContext + ) { + for (CompilerMessage error : compileContext.getMessages(CompilerMessageCategory.ERROR)) { + String message = error.getMessage(); + if (message.startsWith(INTERNAL_ERROR_PREFIX) || message.startsWith(PREFIX_WITH_COMPILER_NAME)) { + LOG.error(message); + } + } + } + + @Override + public void fileGenerated(String outputRoot, String relativePath) { + } + }, project); } @Override diff --git a/idea/src/org/jetbrains/jet/plugin/compiler/MessageCollectorAdapter.java b/idea/src/org/jetbrains/jet/plugin/compiler/MessageCollectorAdapter.java index bc520b426d8..ff29d518ed2 100644 --- a/idea/src/org/jetbrains/jet/plugin/compiler/MessageCollectorAdapter.java +++ b/idea/src/org/jetbrains/jet/plugin/compiler/MessageCollectorAdapter.java @@ -18,17 +18,15 @@ package org.jetbrains.jet.plugin.compiler; import com.intellij.openapi.compiler.CompileContext; import com.intellij.openapi.compiler.CompilerMessageCategory; -import com.intellij.openapi.diagnostic.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.cli.common.messages.CompilerMessageLocation; import org.jetbrains.jet.cli.common.messages.CompilerMessageSeverity; import org.jetbrains.jet.cli.common.messages.MessageCollector; +import org.jetbrains.jet.compiler.runner.CompilerRunnerConstants; import static com.intellij.openapi.compiler.CompilerMessageCategory.*; class MessageCollectorAdapter implements MessageCollector { - private static final Logger LOG = Logger.getInstance(MessageCollectorAdapter.class); - private final CompileContext compileContext; public MessageCollectorAdapter(CompileContext compileContext) { @@ -42,10 +40,13 @@ class MessageCollectorAdapter implements MessageCollector { @NotNull CompilerMessageLocation location ) { CompilerMessageCategory category = category(severity); - compileContext.addMessage(category, message, "file://" + location.getPath(), location.getLine(), location.getColumn()); + + String prefix = ""; if (severity == CompilerMessageSeverity.EXCEPTION) { - LOG.error(message); + prefix = CompilerRunnerConstants.INTERNAL_ERROR_PREFIX; } + + compileContext.addMessage(category, prefix + message, "file://" + location.getPath(), location.getLine(), location.getColumn()); if (severity == CompilerMessageSeverity.LOGGING) { compileContext.getProgressIndicator().setText(message); } diff --git a/jps-plugin/src/org/jetbrains/jet/jps/build/KotlinBuilder.java b/jps-plugin/src/org/jetbrains/jet/jps/build/KotlinBuilder.java index 7bff4b9b7d0..97ab73404b0 100644 --- a/jps-plugin/src/org/jetbrains/jet/jps/build/KotlinBuilder.java +++ b/jps-plugin/src/org/jetbrains/jet/jps/build/KotlinBuilder.java @@ -37,10 +37,10 @@ import java.util.Collection; import java.util.List; import static org.jetbrains.jet.cli.common.messages.CompilerMessageSeverity.ERROR; +import static org.jetbrains.jet.cli.common.messages.CompilerMessageSeverity.EXCEPTION; public class KotlinBuilder extends ModuleLevelBuilder { - private static final String KOTLIN_COMPILER_NAME = "Kotlin"; private static final String KOTLIN_BUILDER_NAME = "Kotlin Builder"; protected KotlinBuilder() { @@ -133,10 +133,14 @@ public class KotlinBuilder extends ModuleLevelBuilder { @NotNull String message, @NotNull CompilerMessageLocation location ) { + String prefix = ""; + if (severity == EXCEPTION) { + prefix = CompilerRunnerConstants.INTERNAL_ERROR_PREFIX; + } context.processMessage(new CompilerMessage( - KOTLIN_COMPILER_NAME, + CompilerRunnerConstants.KOTLIN_COMPILER_NAME, kind(severity), - message, + prefix + message, location.getPath(), -1, -1, -1, location.getLine(),