Skip to content

Commit

Permalink
[FE] Fix creating location of compiler errors in CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
demiurg906 committed Nov 28, 2020
1 parent dc364b8 commit 406e863
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.getLineAndColumn(diagnostic))
MessageUtil.psiFileToMessageLocation(file, file.name, DiagnosticUtils.getLineAndColumnRange(diagnostic))
)
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,23 @@ public class MessageUtil {
private MessageUtil() {}

@Nullable
public static CompilerMessageLocation psiElementToMessageLocation(@Nullable PsiElement element) {
public static CompilerMessageSourceLocation psiElementToMessageLocation(@Nullable PsiElement element) {
if (element == null) return null;
PsiFile file = element.getContainingFile();
return psiFileToMessageLocation(file, "<no path>", DiagnosticUtils.getLineAndColumnInPsiFile(file, element.getTextRange()));
return psiFileToMessageLocation(file, "<no path>", DiagnosticUtils.getLineAndColumnRangeInPsiFile(file, element.getTextRange()));
}

@Nullable
public static CompilerMessageLocation psiFileToMessageLocation(
public static CompilerMessageSourceLocation psiFileToMessageLocation(
@NotNull PsiFile file,
@Nullable String defaultValue,
@NotNull PsiDiagnosticUtils.LineAndColumn lineAndColumn
@NotNull PsiDiagnosticUtils.LineAndColumnRange range
) {
VirtualFile virtualFile = file.getVirtualFile();
String path = virtualFile != null ? virtualFileToPath(virtualFile) : defaultValue;
return CompilerMessageLocation.create(path, lineAndColumn.getLine(), lineAndColumn.getColumn(), lineAndColumn.getLineContent());
PsiDiagnosticUtils.LineAndColumn start = range.getStart();
PsiDiagnosticUtils.LineAndColumn end = range.getEnd();
return CompilerMessageLocationWithRange.create(path, start.getLine(), start.getColumn(), end.getLine(), end.getColumn(), start.getLineContent());
}

@NotNull
Expand Down

This file was deleted.

0 comments on commit 406e863

Please sign in to comment.