Revert "Add info about the end of range in scripting REPL compiler messages"

This reverts commit af251caf, because it breaks daemon/client
compatibility, which we'd like to keep as much as possible
This commit is contained in:
Ilya Chernikov
2020-05-15 15:12:37 +02:00
parent 3793e485b6
commit fb6ef38370
9 changed files with 18 additions and 103 deletions
@@ -19,12 +19,10 @@ package org.jetbrains.kotlin.cli.common.messages
import java.io.Serializable
data class CompilerMessageLocation private constructor(
val path: String,
val line: Int,
val column: Int,
val lineEnd: Int,
val columnEnd: Int,
val lineContent: String?
val path: String,
val line: Int,
val column: Int,
val lineContent: String?
) : Serializable {
override fun toString(): String =
path + (if (line != -1 || column != -1) " ($line:$column)" else "")
@@ -32,23 +30,12 @@ data class CompilerMessageLocation private constructor(
companion object {
@JvmStatic
fun create(path: String?): CompilerMessageLocation? =
create(path, -1, -1, null)
create(path, -1, -1, null)
@JvmStatic
fun create(path: String?, line: Int, column: Int, lineContent: String?): CompilerMessageLocation? =
if (path == null) null else CompilerMessageLocation(path, line, column, -1, -1, lineContent)
if (path == null) null else CompilerMessageLocation(path, line, column, lineContent)
@JvmStatic
fun create(
path: String?,
lineStart: Int,
columnStart: Int,
lineEnd: Int?,
columnEnd: Int?,
lineContent: String?
): CompilerMessageLocation? =
if (path == null) null else CompilerMessageLocation(path, lineStart, columnStart, lineEnd ?: -1, columnEnd ?: -1, lineContent)
private val serialVersionUID: Long = 8228357579L
private val serialVersionUID: Long = 8228357578L
}
}
@@ -31,6 +31,6 @@ interface MessageCollectorBasedReporter : DiagnosticMessageReporter {
override fun report(diagnostic: Diagnostic, file: PsiFile, render: String) = messageCollector.report(
AnalyzerWithCompilerReport.convertSeverity(diagnostic.severity),
render,
MessageUtil.psiFileToMessageLocation(file, file.name, DiagnosticUtils.getLineAndColumnRange(diagnostic))
MessageUtil.psiFileToMessageLocation(file, file.name, DiagnosticUtils.getLineAndColumn(diagnostic))
)
}
@@ -35,20 +35,18 @@ public class MessageUtil {
public static CompilerMessageLocation psiElementToMessageLocation(@Nullable PsiElement element) {
if (element == null) return null;
PsiFile file = element.getContainingFile();
return psiFileToMessageLocation(file, "<no path>", DiagnosticUtils.getLineAndColumnRangeInPsiFile(file, element.getTextRange()));
return psiFileToMessageLocation(file, "<no path>", DiagnosticUtils.getLineAndColumnInPsiFile(file, element.getTextRange()));
}
@Nullable
public static CompilerMessageLocation psiFileToMessageLocation(
@NotNull PsiFile file,
@Nullable String defaultValue,
@NotNull PsiDiagnosticUtils.LineAndColumnRange range
@NotNull PsiDiagnosticUtils.LineAndColumn lineAndColumn
) {
VirtualFile virtualFile = file.getVirtualFile();
String path = virtualFile != null ? virtualFileToPath(virtualFile) : defaultValue;
PsiDiagnosticUtils.LineAndColumn start = range.getStart();
PsiDiagnosticUtils.LineAndColumn end = range.getEnd();
return CompilerMessageLocation.create(path, start.getLine(), start.getColumn(), end.getLine(), end.getColumn(), start.getLineContent());
return CompilerMessageLocation.create(path, lineAndColumn.getLine(), lineAndColumn.getColumn(), lineAndColumn.getLineContent());
}
@NotNull