check if ast is available

pull/5370/head
aniket-engg 4 years ago committed by Aniket
parent 1749a31b52
commit cb81fe44cf
  1. 5
      libs/remix-debug/src/source/astWalker.js

@ -21,10 +21,11 @@ AstWalker.prototype.walk = function (ast, callback) {
if (!('*' in callback)) { if (!('*' in callback)) {
callback['*'] = function () { return true } callback['*'] = function () { return true }
} }
if(ast) { if (ast) {
const nodes = ast.nodes || (ast.body && ast.body.statements) || ast.declarations || [] const nodes = ast.nodes || (ast.body && ast.body.statements) || ast.declarations || []
if(ast.body && ast.initializationExpression) // 'for' loop handling if (ast.body && ast.initializationExpression) { // 'for' loop handling
nodes.push(ast.initializationExpression) nodes.push(ast.initializationExpression)
}
if (manageCallBack(ast, callback) && nodes && nodes.length > 0) { if (manageCallBack(ast, callback) && nodes && nodes.length > 0) {
for (let k in nodes) { for (let k in nodes) {
const child = nodes[k] const child = nodes[k]

Loading…
Cancel
Save