Fix positioning error messages in JPS

This commit is contained in:
Alexey Andreev 2017-07-05 00:08:28 +03:00
parent f3d0799141
commit e1234df7e1
2 changed files with 18 additions and 2 deletions

View File

@ -206,6 +206,10 @@ class TeaVMBuild {
List<ProblemToReport> problemsToReport = resolveProblemLocation(problem, callGraph); List<ProblemToReport> problemsToReport = resolveProblemLocation(problem, callGraph);
if (problemsToReport.isEmpty()) {
context.processMessage(new CompilerMessage("TeaVM", kind, problem.getText(), null,
-1, -1, -1, -1, -1));
}
for (ProblemToReport problemToReport : problemsToReport) { for (ProblemToReport problemToReport : problemsToReport) {
String text = baseText + buildCallStack(problemToReport.locations); String text = baseText + buildCallStack(problemToReport.locations);
context.processMessage(new CompilerMessage("TeaVM", kind, text, problemToReport.path, context.processMessage(new CompilerMessage("TeaVM", kind, text, problemToReport.path,

View File

@ -17,10 +17,13 @@ package org.teavm.idea;
import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.ApplicationComponent; import com.intellij.openapi.components.ApplicationComponent;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.project.Project; import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.project.ProjectManager;
import com.intellij.psi.JavaPsiFacade; import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiClass; import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiMethod; import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiParameter; import com.intellij.psi.PsiParameter;
import com.intellij.psi.PsiType; import com.intellij.psi.PsiType;
@ -134,7 +137,16 @@ public class TeaVMJPSRemoteService extends UnicastRemoteObject implements Applic
} }
private TeaVMElementLocation getMethodLocation(PsiMethod method) { private TeaVMElementLocation getMethodLocation(PsiMethod method) {
return new TeaVMElementLocation(method.getTextOffset(), method.getTextOffset() + method.getTextLength(), PsiElement element = method.getNameIdentifier();
-1, -1, method.getContainingFile().getVirtualFile().getPath()); if (element == null) {
element = method.getNavigationElement();
}
PsiFile psiFile = element.getContainingFile();
Document document = psiFile.getViewProvider().getDocument();
int offset = element.getTextRange().getStartOffset();
int line = offset >= 0 ? document.getLineNumber(offset) + 1 : -1;
int column = offset >= 0 ? offset - document.getLineStartOffset(line) + 1 : -1;
return new TeaVMElementLocation(offset, element.getTextRange().getEndOffset(),
line, column, psiFile.getVirtualFile().getPath());
} }
} }