From dfc72a87847530154967154266db1467a9449635 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Thu, 27 Mar 2014 19:43:20 +0400 Subject: [PATCH] Render file name and position in errors from JS library stubs Original commit: bcc684383581142060f76317e1111c9c2bd29030 --- .../org/jetbrains/jet/jps/build/KotlinBuilder.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/jps/jps-plugin/src/org/jetbrains/jet/jps/build/KotlinBuilder.java b/jps/jps-plugin/src/org/jetbrains/jet/jps/build/KotlinBuilder.java index c99ce3f55c9..ae45d220ab5 100644 --- a/jps/jps-plugin/src/org/jetbrains/jet/jps/build/KotlinBuilder.java +++ b/jps/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) {