forked from jasder/antlr
v4: add ANTLRMessage.getCause(), overridden in GrammarSyntaxMessage instead of keeping 2 separate fields
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9210]
This commit is contained in:
parent
ad468ee29b
commit
980db2caac
|
@ -34,7 +34,7 @@ import java.util.Arrays;
|
|||
public class ANTLRMessage {
|
||||
public ErrorType errorType;
|
||||
public Object[] args;
|
||||
public Throwable e;
|
||||
private final Throwable e;
|
||||
|
||||
// used for location template
|
||||
public String fileName;
|
||||
|
@ -42,20 +42,33 @@ public class ANTLRMessage {
|
|||
public int charPosition = -1;
|
||||
|
||||
public ANTLRMessage() {
|
||||
this(ErrorType.INVALID, (Throwable)null);
|
||||
}
|
||||
|
||||
public ANTLRMessage(ErrorType errorType) {
|
||||
this.errorType = errorType;
|
||||
this(errorType, (Throwable)null);
|
||||
}
|
||||
|
||||
public ANTLRMessage(ErrorType errorType, Object... args) {
|
||||
this(errorType);
|
||||
this(errorType, null, args);
|
||||
}
|
||||
|
||||
public ANTLRMessage(ErrorType errorType, /*@Nullable*/ Throwable e, Object... args) {
|
||||
this.errorType = errorType;
|
||||
this.e = e;
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
public ANTLRMessage(ErrorType errorType, Throwable e, Object... args) {
|
||||
this(errorType, args);
|
||||
this.e = e;
|
||||
public ErrorType getErrorType() {
|
||||
return errorType;
|
||||
}
|
||||
|
||||
public Object[] getArgs() {
|
||||
return args;
|
||||
}
|
||||
|
||||
public Throwable getCause() {
|
||||
return e;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -38,7 +38,6 @@ public class GrammarSyntaxMessage extends ANTLRMessage {
|
|||
public Grammar g;
|
||||
/** Most of the time, we'll have a token and so this will be set. */
|
||||
public Token offendingToken;
|
||||
public RecognitionException antlrException;
|
||||
|
||||
public GrammarSyntaxMessage(ErrorType etype,
|
||||
String fileName,
|
||||
|
@ -46,13 +45,18 @@ public class GrammarSyntaxMessage extends ANTLRMessage {
|
|||
RecognitionException antlrException,
|
||||
Object... args)
|
||||
{
|
||||
super(etype,args);
|
||||
super(etype, antlrException, args);
|
||||
this.fileName = fileName;
|
||||
this.offendingToken = offendingToken;
|
||||
this.antlrException = antlrException;
|
||||
if ( offendingToken!=null ) {
|
||||
line = offendingToken.getLine();
|
||||
charPosition = offendingToken.getCharPositionInLine();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"ThrowableResultOfMethodCallIgnored"})
|
||||
@Override
|
||||
public RecognitionException getCause() {
|
||||
return (RecognitionException)super.getCause();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue