better location diagnostic of internal errors
This commit is contained in:
@@ -73,6 +73,9 @@ public abstract class ClassBodyCodegen {
|
|||||||
else if (declaration instanceof JetNamedFunction) {
|
else if (declaration instanceof JetNamedFunction) {
|
||||||
try {
|
try {
|
||||||
genNamedFunction((JetNamedFunction) declaration, functionCodegen);
|
genNamedFunction((JetNamedFunction) declaration, functionCodegen);
|
||||||
|
}
|
||||||
|
catch(CompilationException e) {
|
||||||
|
throw e;
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
throw new RuntimeException("Error generating method " + myClass.getName() + "." + declaration.getName() + " in " + context, e);
|
throw new RuntimeException("Error generating method " + myClass.getName() + "." + declaration.getName() + " in " + context, e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,15 @@
|
|||||||
package org.jetbrains.jet.codegen;
|
package org.jetbrains.jet.codegen;
|
||||||
|
|
||||||
|
import com.intellij.openapi.editor.Document;
|
||||||
|
import com.intellij.openapi.util.TextRange;
|
||||||
|
import com.intellij.openapi.vfs.VirtualFile;
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
|
import com.intellij.psi.PsiFile;
|
||||||
import org.jetbrains.jet.lang.psi.JetElement;
|
import org.jetbrains.jet.lang.psi.JetElement;
|
||||||
|
import org.jetbrains.jet.resolve.DescriptorRenderer;
|
||||||
|
import org.objectweb.asm.Label;
|
||||||
|
|
||||||
|
import static com.intellij.openapi.compiler.CompilerMessageCategory.ERROR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author alex.tkachman
|
* @author alex.tkachman
|
||||||
@@ -17,4 +25,23 @@ public class CompilationException extends RuntimeException {
|
|||||||
public PsiElement getElement() {
|
public PsiElement getElement() {
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
PsiFile psiFile = element.getContainingFile();
|
||||||
|
TextRange textRange = element.getTextRange();
|
||||||
|
Document document = psiFile.getViewProvider().getDocument();
|
||||||
|
int line;
|
||||||
|
int col;
|
||||||
|
if (document != null) {
|
||||||
|
line = document.getLineNumber(textRange.getStartOffset());
|
||||||
|
col = textRange.getStartOffset() - document.getLineStartOffset(line) + 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
line = -1;
|
||||||
|
col = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "Internal error: (" + (line+1) + "," + col + ") " + getCause().toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user