Render file name and position in errors from JS library stubs

Original commit: bcc6843835
This commit is contained in:
Andrey Breslav
2014-03-27 19:43:20 +04:00
parent d1a14f1d78
commit dfc72a8784
@@ -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) {