1- // AST walker module for Mozilla Parser API compatible trees
1+ // AST walker module for ESTree compatible trees
22
33// A simple walk is one where you simply specify callbacks to be
44// called on specific nodes. The last two arguments are optional. A
88// Expression: function(node){... }
99// });
1010//
11- // to do something with all expressions. All Parser API node types
11+ // to do something with all expressions. All ESTree node types
1212// can be used to identify node types, as well as Expression and
1313// Statement, which denote categories of nodes.
1414//
1919function simple ( node , visitors , baseVisitor , state , override ) {
2020if ( ! baseVisitor ) { baseVisitor = base
2121; } ( function c ( node , st , override ) {
22- var type = override || node . type , found = visitors [ type ] ;
22+ var type = override || node . type ;
2323baseVisitor [ type ] ( node , st , c ) ;
24- if ( found ) { found ( node , st ) ; }
24+ if ( visitors [ type ] ) { visitors [ type ] ( node , st ) ; }
2525} ) ( node , state , override ) ;
2626}
2727
@@ -32,11 +32,11 @@ function ancestor(node, visitors, baseVisitor, state, override){
3232var ancestors = [ ] ;
3333if ( ! baseVisitor ) { baseVisitor = base
3434; } ( function c ( node , st , override ) {
35- var type = override || node . type , found = visitors [ type ] ;
35+ var type = override || node . type ;
3636var isNew = node !== ancestors [ ancestors . length - 1 ] ;
3737if ( isNew ) { ancestors . push ( node ) ; }
3838baseVisitor [ type ] ( node , st , c ) ;
39- if ( found ) { found ( node , st || ancestors , ancestors ) ; }
39+ if ( visitors [ type ] ) { visitors [ type ] ( node , st || ancestors , ancestors ) ; }
4040if ( isNew ) { ancestors . pop ( ) ; }
4141} ) ( node , state , override ) ;
4242}
0 commit comments