mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-151847 Freemarker: provide some more details in 'invalid Java type' message for @ftlvariable
This commit is contained in:
@@ -63,19 +63,23 @@ public class PsiTypeCodeFragmentImpl extends PsiCodeFragmentImpl implements PsiT
|
||||
@NotNull
|
||||
public PsiType getType() throws TypeSyntaxException, NoTypeException {
|
||||
class MyTypeSyntaxException extends RuntimeException {
|
||||
MyTypeSyntaxException(final String message) { super(message); }
|
||||
final PsiErrorElement error;
|
||||
|
||||
MyTypeSyntaxException(final PsiErrorElement e) { super(e.getErrorDescription());
|
||||
error = e;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
accept(new PsiRecursiveElementWalkingVisitor() {
|
||||
@Override
|
||||
public void visitErrorElement(PsiErrorElement element) {
|
||||
throw new MyTypeSyntaxException(element.getErrorDescription());
|
||||
throw new MyTypeSyntaxException(element);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (MyTypeSyntaxException e) {
|
||||
throw new TypeSyntaxException(e.getMessage());
|
||||
throw new TypeSyntaxException(e.getMessage(), e.error.getTextRange().getStartOffset());
|
||||
}
|
||||
|
||||
final PsiTypeElement typeElement = PsiTreeUtil.getChildOfType(this, PsiTypeElement.class);
|
||||
|
||||
@@ -48,7 +48,16 @@ public interface PsiTypeCodeFragment extends JavaCodeFragment {
|
||||
}
|
||||
|
||||
class TypeSyntaxException extends IncorrectTypeException {
|
||||
public TypeSyntaxException(final String message) { super(message); }
|
||||
private final int myErrorOffset;
|
||||
|
||||
public TypeSyntaxException(final String message) { this(message, -1); }
|
||||
public TypeSyntaxException(final String message, int errorOffset) { super(message);
|
||||
myErrorOffset = errorOffset;
|
||||
}
|
||||
|
||||
public int getErrorOffset() {
|
||||
return myErrorOffset;
|
||||
}
|
||||
}
|
||||
|
||||
class NoTypeException extends IncorrectTypeException {
|
||||
|
||||
Reference in New Issue
Block a user