Use the system path separator character in compiler messages.
Fix for CliTest.
This commit is contained in:
+1
-4
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.jet.cli.common.messages;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiErrorElement;
|
||||
@@ -90,8 +89,6 @@ public final class AnalyzerWithCompilerReport {
|
||||
private static boolean reportDiagnostic(@NotNull Diagnostic diagnostic, @NotNull MessageCollector messageCollector) {
|
||||
if (!diagnostic.isValid()) return false;
|
||||
DiagnosticUtils.LineAndColumn lineAndColumn = DiagnosticUtils.getLineAndColumn(diagnostic);
|
||||
VirtualFile virtualFile = diagnostic.getPsiFile().getVirtualFile();
|
||||
String path = virtualFile == null ? null : virtualFile.getPath();
|
||||
String render;
|
||||
if (diagnostic instanceof MyDiagnostic) {
|
||||
render = ((MyDiagnostic)diagnostic).message;
|
||||
@@ -100,7 +97,7 @@ public final class AnalyzerWithCompilerReport {
|
||||
render = DefaultErrorMessages.RENDERER.render(diagnostic);
|
||||
}
|
||||
messageCollector.report(convertSeverity(diagnostic.getSeverity()), render,
|
||||
CompilerMessageLocation.create(path, lineAndColumn.getLine(), lineAndColumn.getColumn()));
|
||||
MessageUtil.psiFileToMessageLocation(diagnostic.getPsiFile(), null, lineAndColumn.getLine(), lineAndColumn.getColumn()));
|
||||
return diagnostic.getSeverity() == Severity.ERROR;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,11 +17,16 @@
|
||||
package org.jetbrains.jet.cli.common.messages;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.impl.jar.CoreJarVirtualFile;
|
||||
import com.intellij.openapi.vfs.local.CoreLocalVirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
|
||||
|
||||
import static com.intellij.openapi.util.io.FileUtil.toSystemDependentName;
|
||||
|
||||
public class MessageUtil {
|
||||
private MessageUtil() {}
|
||||
|
||||
@@ -29,8 +34,23 @@ public class MessageUtil {
|
||||
public static CompilerMessageLocation psiElementToMessageLocation(@NotNull PsiElement element) {
|
||||
PsiFile file = element.getContainingFile();
|
||||
DiagnosticUtils.LineAndColumn lineAndColumn = DiagnosticUtils.getLineAndColumnInPsiFile(file, element.getTextRange());
|
||||
return psiFileToMessageLocation(file, "<no path>", lineAndColumn.getLine(), lineAndColumn.getColumn());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static CompilerMessageLocation psiFileToMessageLocation(@NotNull PsiFile file, @Nullable String defaultValue, int line, int column) {
|
||||
String path;
|
||||
VirtualFile virtualFile = file.getVirtualFile();
|
||||
String path = virtualFile == null ? "<no path>" : virtualFile.getPath();
|
||||
return CompilerMessageLocation.create(path, lineAndColumn.getLine(), lineAndColumn.getColumn());
|
||||
if (virtualFile == null) {
|
||||
path = defaultValue;
|
||||
}
|
||||
else {
|
||||
path = virtualFile.getPath();
|
||||
// Convert path to platform-dependent format when virtualFile is local file.
|
||||
if (virtualFile instanceof CoreLocalVirtualFile || virtualFile instanceof CoreJarVirtualFile) {
|
||||
path = toSystemDependentName(path);
|
||||
}
|
||||
}
|
||||
return CompilerMessageLocation.create(path, line, column);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user