Render file name and position in errors from JS library stubs
This commit is contained in:
+5
@@ -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 + ")" : "");
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user