Fixed null pointer exception for JS
This commit is contained in:
parent
b8c74be628
commit
2a118e284f
|
@ -138,3 +138,4 @@ YYYY/MM/DD, github id, Full name, email
|
|||
2017/02/14, xied75, Dong Xie, xied75@gmail.com
|
||||
2017/02/20, Thomasb81, Thomas Burg, thomasb81@gmail.com
|
||||
2017/02/26, jvasileff, John Vasileff, john@vasileff.com
|
||||
2017/03/08, harry-tallbelt, Igor Vysokopoyasny, harry.tallbelt@gmail.com
|
||||
|
|
|
@ -119,8 +119,11 @@ ParserRuleContext.prototype.addErrorNode = function(badToken) {
|
|||
|
||||
ParserRuleContext.prototype.getChild = function(i, type) {
|
||||
type = type || null;
|
||||
if (this.children === null || i < 0 || i >= this.children.length) {
|
||||
return null;
|
||||
}
|
||||
if (type === null) {
|
||||
return this.children.length>=i ? this.children[i] : null;
|
||||
return this.children[i];
|
||||
} else {
|
||||
for(var j=0; j<this.children.length; j++) {
|
||||
var child = this.children[j];
|
||||
|
@ -138,6 +141,9 @@ ParserRuleContext.prototype.getChild = function(i, type) {
|
|||
|
||||
|
||||
ParserRuleContext.prototype.getToken = function(ttype, i) {
|
||||
if (this.children === null || i < 0 || i >= this.children.length) {
|
||||
return null;
|
||||
}
|
||||
for(var j=0; j<this.children.length; j++) {
|
||||
var child = this.children[j];
|
||||
if (child instanceof TerminalNode) {
|
||||
|
|
Loading…
Reference in New Issue