How to use the acorn-walk.recursive function in acorn-walk

To help you get started, we’ve selected a few acorn-walk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github marijnh / blint / blint.js View on Github external
function readFromPattern(node, scope) {
    walk.recursive(node, null, {
      Expression: function() {},
      VariablePattern: function(node) { readVariable(node, scope); }
    }, null, "Pattern");
  }
github marijnh / blint / blint.js View on Github external
function assignToPattern(node, scope) {
    walk.recursive(node, null, {
      Expression: function(node) {
        check(node, scope);
      },
      VariablePattern: function(node) {
        var found = searchScope(node.name, scope);
        if (found) {
          found.written = true;
        } else if (!(node.name in ignoredGlobals)) {
          ignoredGlobals[node.name] = true;
          fail("Assignment to global variable " + node.name, node.loc);
        }
      }
    }, null, "Pattern");
  }
github publiclab / leaflet-environmental-layers / node_modules / acorn-node / walk.js View on Github external
function recursive (node, state, funcs, baseVisitor, override) {
  return walk.recursive(node, state, funcs, baseVisitor || base, override)
}
github endorphinjs / endorphin / packages / template-parser / src / walk.ts View on Github external
export function walkRecursive(node: Ast.Node, state?: T, funcs?: AstVisitors, baseVisitor = base, override?: string): void {
    acornWalk.recursive(node, state, funcs, baseVisitor, override);
}
github marijnh / blint / loop.js View on Github external
exports.checkReusedIndex = function(node, fail) {
  if (!node.init || node.init.type != "VariableDeclaration") return;
  var name = node.init.declarations[0].id.name;
  walk.recursive(node.body, null, {
    Function: function() {},
    VariableDeclaration: function(node, st, c) {
      for (var i = 0; i < node.declarations.length; i++)
        if (node.declarations[i].id.name == name)
          fail("Redefined loop variable", node.declarations[i].id.loc);
      walk.base.VariableDeclaration(node, st, c);
    }
  });
};
github stdlib-js / stdlib / lib / node_modules / @stdlib / _tools / modules / import-require / lib / walk.js View on Github external
function walker( src, ast ) {
	var results;
	var opts;
	opts = {
		'CallExpression': callExpression,
		'ImportDeclaration': importDeclaration
	};
	results = {
		'literals': [],
		'expressions': []
	};
	walk.recursive( ast, null, opts );
	return results;

	/**
	* Callback invoked upon visiting a `CallExpression` AST node.
	*
	* @private
	* @param {Node} node - AST node
	* @param {*} state - start state
	* @param {Callback} clbk - callback to continue walking a sub-node
	*/
	function callExpression( node, state, clbk ) {
		var expression;
		var arg;
		walk.base[ node.type ]( node, state, clbk );
		if ( isRequire( node ) === false ) {
			return;
github peterqliu / threebox / node_modules / acorn-node / walk.js View on Github external
function recursive (node, state, funcs, baseVisitor, override) {
  return walk.recursive(node, state, funcs, baseVisitor || base, override)
}
github marijnh / blint / scope.js View on Github external
fail("Duplicate definition of " + name, node.loc);
    scope.vars[name] = {type: type, node: node, deadZone: deadZone && scope,
                        written: written, read: false};
  }

  function makeCx(scope, binding) {
    return {scope: scope, binding: binding};
  }

  function isBlockScopedDecl(node) {
    return node.type == "VariableDeclaration" && node.kind != "var";
  }

  var topScope = makeScope(null, "fn");

  walk.recursive(ast, makeCx(topScope), {
    Function: function(node, cx, c) {
      var inner = node.scope = node.body.scope = makeScope(cx.scope, "fn");
      var innerCx = makeCx(inner, {scope: inner, type: "argument", deadZone: true, written: true});
      for (var i = 0; i < node.params.length; ++i)
        c(node.params[i], innerCx, "Pattern");

      if (node.id) {
        var decl = node.type == "FunctionDeclaration";
        addVar(decl ? cx.scope : inner, node.id.name,
               decl ? "function" : "function name", node.id, false, true);
      }
      c(node.body, innerCx, node.expression ? "Expression" : "Statement")
    },
    TryStatement: function(node, cx, c) {
      c(node.block, cx, "Statement");
      if (node.handler) {