How to use estraverse - 10 common examples

To help you get started, we’ve selected a few estraverse 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 xml3d / shade.js / src / resolve / colorclosure-replacer.js View on Github external
/**
 * Simple replacer that collects all closure calls of a color closure expression and passes them to the
 * provided callback
 * @type {exports}
 */

var Traversal = require('estraverse');
var ANNO = require("../type-system/annotation.js").ANNO;
var Shade = require("../interfaces.js");

var Syntax = Traversal.Syntax;

function isColorClosure(node) {
    if (node.type !== Syntax.CallExpression) {
        return false;
    }
    return ANNO(node).isOfKind(Shade.OBJECT_KINDS.COLOR_CLOSURE);
}

function handleCallExpression(node, colorClosureList) {
    var callee = ANNO(node.callee);
    // console.log("Call", node.callee.property, callee.getTypeString(), node.callee.object)
    if (callee.isOfKind(Shade.OBJECT_KINDS.COLOR_CLOSURE)) {
        colorClosureList.push({name: node.callee.property.name, args: node.arguments});
    }
}
github saltlab / sahand / esinstrument.js View on Github external
function instrumentFunctionEnter(node, isCallback) {
    var functionEnterName = '_functionEnter_cb' ? isCallback : '_functionEnter';
    var name;

    // TODO TODO TODO TODO TODO TODO
    if (node.type == 'FunctionDeclaration') {
        // TODO TODO TODO TODO TODO TODO
        if (node.id.name == '_functionEnter' || node.id.name == '_functionExit' || node.id.name == '_functionEnter_callback')
            return estraverse.VisitorOption.Skip; //////////////// TODO TODO TODO ?????????????

        name = node.id.name;
//					console.log('***** DEC: ', name);
    }

    var functionBody = node.body.body;

    // TODO  TODO  TODO  TODO  TODO  TODO  TODO ???
    if (functionBody == null || functionBody == 'undefined') {//} || functionBody.length < 1) {
        console.warn('func-inst.js::instrumentAST -> empty function body');
    }
//								console.log(functionBody.length);


    // TODO TODO TODO  TODO TODO TODO ///////////////
    if (node.type == 'FunctionExpression') {
github xml3d / shade.js / src / analyze / constants / computeConstants.js View on Github external
ns.evaluate  = function(ast, propagatedConstants) {
        var controller = new estraverse.Controller();

        // console.log("Compute constants for", codegen.generate(ast), propagatedConstants)
        this.setConstants(propagatedConstants);

        controller.traverse(ast, {
            leave: exitExpression.bind(controller, this)
        })
        this.setConstants(null);

    }
}(exports));
github elastic / timelion / node_modules / gulp-eslint / node_modules / eslint / node_modules / escope / lib / referencer.js View on Github external
_this.referencingDefaultValue(pattern, info.assignments, null, true);
                    });
                }

                // if there's a rest argument, add that
                if (node.rest) {
                    this.visitPattern({
                        type: "RestElement",
                        argument: node.rest
                    }, function (pattern) {
                        _this.currentScope().__define(pattern, new ParameterDefinition(pattern, node, node.params.length, true));
                    });
                }

                // Skip BlockStatement to prevent creating BlockStatement scope.
                if (node.body.type === Syntax.BlockStatement) {
                    this.visitChildren(node.body);
                } else {
                    this.visit(node.body);
                }

                this.close(node);
            }
        },
github angelozerr / tern.java / core / ternjs / node_modules / tern-eslint / node_modules / eslint / node_modules / escope / lib / referencer.js View on Github external
_this.referencingDefaultValue(pattern, info.assignments, null, true);
                    });
                }

                // if there's a rest argument, add that
                if (node.rest) {
                    this.visitPattern({
                        type: "RestElement",
                        argument: node.rest
                    }, function (pattern) {
                        _this.currentScope().__define(pattern, new ParameterDefinition(pattern, node, node.params.length, true));
                    });
                }

                // Skip BlockStatement to prevent creating BlockStatement scope.
                if (node.body.type === Syntax.BlockStatement) {
                    this.visitChildren(node.body);
                } else {
                    this.visit(node.body);
                }

                this.close(node);
            }
        },
github sx1989827 / DOClever / node_modules / eslint-scope / lib / referencer.js View on Github external
this.currentScope().__define(pattern,
                    new ParameterDefinition(
                        pattern,
                        node,
                        node.params.length,
                        true
                    ));
            });
        }

        // In TypeScript there are a number of function-like constructs which have no body,
        // so check it exists before traversing
        if (node.body) {

            // Skip BlockStatement to prevent creating BlockStatement scope.
            if (node.body.type === Syntax.BlockStatement) {
                this.visitChildren(node.body);
            } else {
                this.visit(node.body);
            }
        }

        this.close(node);
    }
github sx1989827 / DOClever / Desktop / node_modules / escope / src / referencer.js View on Github external
this.visitPattern({
                type: 'RestElement',
                argument: node.rest
            }, (pattern) => {
                this.currentScope().__define(pattern,
                    new ParameterDefinition(
                        pattern,
                        node,
                        node.params.length,
                        true
                    ));
            });
        }

        // Skip BlockStatement to prevent creating BlockStatement scope.
        if (node.body.type === Syntax.BlockStatement) {
            this.visitChildren(node.body);
        } else {
            this.visit(node.body);
        }

        this.close(node);
    }
github graalvm / graaljs / tools / node_modules / eslint / node_modules / eslint-scope / lib / referencer.js View on Github external
this.currentScope().__define(pattern,
                    new ParameterDefinition(
                        pattern,
                        node,
                        node.params.length,
                        true
                    ));
            });
        }

        // In TypeScript there are a number of function-like constructs which have no body,
        // so check it exists before traversing
        if (node.body) {

            // Skip BlockStatement to prevent creating BlockStatement scope.
            if (node.body.type === Syntax.BlockStatement) {
                this.visitChildren(node.body);
            } else {
                this.visit(node.body);
            }
        }

        this.close(node);
    }
github estools / escope / src / referencer.js View on Github external
this.visitPattern({
                type: 'RestElement',
                argument: node.rest
            }, (pattern) => {
                this.currentScope().__define(pattern,
                    new ParameterDefinition(
                        pattern,
                        node,
                        node.params.length,
                        true
                    ));
            });
        }

        // Skip BlockStatement to prevent creating BlockStatement scope.
        if (node.body.type === Syntax.BlockStatement) {
            this.visitChildren(node.body);
        } else {
            this.visit(node.body);
        }

        this.close(node);
    }
github miccferr / leaflet-store-locator / old / node_modules / eslint / node_modules / escope / lib / referencer.js View on Github external
_this.referencingDefaultValue(pattern, info.assignments, null, true);
                    });
                }

                // if there's a rest argument, add that
                if (node.rest) {
                    this.visitPattern({
                        type: "RestElement",
                        argument: node.rest
                    }, function (pattern) {
                        _this.currentScope().__define(pattern, new ParameterDefinition(pattern, node, node.params.length, true));
                    });
                }

                // Skip BlockStatement to prevent creating BlockStatement scope.
                if (node.body.type === Syntax.BlockStatement) {
                    this.visitChildren(node.body);
                } else {
                    this.visit(node.body);
                }

                this.close(node);
            }
        },