forked from jasder/antlr
Fix NPE in CommonToken when TokenSource is not available
This commit is contained in:
parent
dee579a68f
commit
9600a70724
|
@ -64,8 +64,10 @@ public class CommonToken implements WritableToken, Serializable {
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
this.start = start;
|
this.start = start;
|
||||||
this.stop = stop;
|
this.stop = stop;
|
||||||
this.line = source.getLine();
|
if (source != null) {
|
||||||
this.charPositionInLine = source.getCharPositionInLine();
|
this.line = source.getLine();
|
||||||
|
this.charPositionInLine = source.getCharPositionInLine();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommonToken(int type, String text) {
|
public CommonToken(int type, String text) {
|
||||||
|
@ -190,7 +192,7 @@ public class CommonToken implements WritableToken, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CharStream getInputStream() {
|
public CharStream getInputStream() {
|
||||||
return source.getInputStream();
|
return source != null ? source.getInputStream() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
Loading…
Reference in New Issue