diff --git a/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/messages/CompilerMessageLocation.java b/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/messages/CompilerMessageLocation.java index 5fdbde325fa..1cabeadb333 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/messages/CompilerMessageLocation.java +++ b/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/messages/CompilerMessageLocation.java @@ -73,4 +73,9 @@ public class CompilerMessageLocation { result = 31 * result + column; return result; } + + @Override + public String toString() { + return path + ((line != -1 || column != -1) ? " (" + line + ":" + column + ")" : ""); + } } diff --git a/compiler/cli/src/org/jetbrains/jet/cli/common/messages/AnalyzerWithCompilerReport.java b/compiler/cli/src/org/jetbrains/jet/cli/common/messages/AnalyzerWithCompilerReport.java index a1fb8549116..ed861cc1810 100644 --- a/compiler/cli/src/org/jetbrains/jet/cli/common/messages/AnalyzerWithCompilerReport.java +++ b/compiler/cli/src/org/jetbrains/jet/cli/common/messages/AnalyzerWithCompilerReport.java @@ -19,6 +19,7 @@ package org.jetbrains.jet.cli.common.messages; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiErrorElement; +import com.intellij.psi.PsiFile; import com.intellij.psi.PsiModifierListOwner; import com.intellij.psi.util.PsiFormatUtil; import kotlin.Function0; @@ -93,8 +94,9 @@ public final class AnalyzerWithCompilerReport { else { render = DefaultErrorMessages.RENDERER.render(diagnostic); } + PsiFile file = diagnostic.getPsiFile(); messageCollector.report(convertSeverity(diagnostic.getSeverity()), render, - MessageUtil.psiFileToMessageLocation(diagnostic.getPsiFile(), null, lineAndColumn.getLine(), lineAndColumn.getColumn())); + MessageUtil.psiFileToMessageLocation(file, file.getName(), lineAndColumn.getLine(), lineAndColumn.getColumn())); return diagnostic.getSeverity() == Severity.ERROR; } 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 d890f717bb3..a7005b0244b 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 @@ -128,8 +128,7 @@ public class CompilerOutputParser { message.setLength(0); - String rawPath = attributes.getValue("path"); - path = rawPath == null ? null : rawPath; + path = attributes.getValue("path"); line = safeParseInt(attributes.getValue("line"), -1); column = safeParseInt(attributes.getValue("column"), -1); } 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 c99ce3f55c9..ae45d220ab5 100644 --- a/jps-plugin/src/org/jetbrains/jet/jps/build/KotlinBuilder.java +++ b/jps-plugin/src/org/jetbrains/jet/jps/build/KotlinBuilder.java @@ -16,7 +16,6 @@ package org.jetbrains.jet.jps.build; -import com.google.common.collect.Maps; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; @@ -288,7 +287,7 @@ public class KotlinBuilder extends ModuleLevelBuilder { context.processMessage(new CompilerMessage( CompilerRunnerConstants.KOTLIN_COMPILER_NAME, kind(severity), - prefix + message, + prefix + message + renderLocationIfNeeded(location), location.getPath(), -1, -1, -1, location.getLine(), @@ -296,6 +295,16 @@ public class KotlinBuilder extends ModuleLevelBuilder { )); } + private static String renderLocationIfNeeded(@NotNull CompilerMessageLocation location) { + if (location == NO_LOCATION) return ""; + + // Sometimes we report errors in JavaScript library stubs, i.e. files like core/javautil.kt + // IDEA can't find these files, and does not display paths in Messages View, so we add the position information + // to the error message itself: + String pathname = String.valueOf(location.getPath()); + return new File(pathname).exists() ? "" : " (" + location + ")"; + } + @NotNull private static BuildMessage.Kind kind(@NotNull CompilerMessageSeverity severity) { switch (severity) {