int errorStart = -1;
int errorEnd = -1;
int errorLine = -1;
String message = null;
if (error instanceof ParseException) {
ParseException parseErr = (ParseException) error;
// Figure out where the error is in the document, and create a
// marker for it
if (parseErr.currentToken == null) {
IRegion endLine = doc.getLineInformationOfOffset(doc.getLength());
errorStart = endLine.getOffset();
errorEnd = endLine.getOffset() + endLine.getLength();
} else {
Token errorToken = parseErr.currentToken.next != null ? parseErr.currentToken.next
: parseErr.currentToken;
IRegion startLine = doc.getLineInformation(getDocPosFromAstPos(errorToken.beginLine));
IRegion endLine;
if (errorToken.endLine == 0) {
endLine = startLine;
} else {
endLine = doc.getLineInformation(getDocPosFromAstPos(errorToken.endLine));
}
errorStart = startLine.getOffset() + getDocPosFromAstPos(errorToken.beginColumn);
errorEnd = endLine.getOffset() + errorToken.endColumn;
}
message = parseErr.getMessage();
} else if (error instanceof TokenMgrError) {
TokenMgrError tokenErr = (TokenMgrError) error;
IRegion startLine = doc.getLineInformation(tokenErr.errorLine - 1);
errorStart = startLine.getOffset();