function match(ast, selector) {
    const ancestry = [];
    const results = [];
    if (!selector) {
      return results;
    }
    const altSubjects = subjects(selector);
    traverse(ast, {
      enter: function(node, parent) {
        if (parent != null) {
          ancestry.unshift(parent);
        }
        if (matches(node, selector, ancestry)) {
          if (altSubjects.length) {
            for (let i = 0; i < altSubjects.length; ++i) {
              if (matches(node, altSubjects[i], ancestry)) {
                results.push(node);
              }
              for (let k = 0; k < ancestry.length; ++k) {
                if (
                  matches(ancestry[k], altSubjects[i], ancestry.slice(k + 1))
                ) {
                  results.push(ancestry[k]);
                }
              }
            }
          } else {
            results.push(node);
          }
        }
      },
      leave: function() {
        ancestry.shift();
      },
      identifierKey,
    });
    return results;
  }
/**
   * From a code AST and a selector AST, collect all code AST nodes that match the selector.
   */
From a code AST and a selector AST, collect all code AST nodes that match the selector.
From a code AST and a selector AST collect all code AST nodes that match the selector .
function match(ast, selector) {
    const ancestry = [];
    const results = [];
    if (!selector) {
      return results;
    }
    const altSubjects = subjects(selector);
    traverse(ast, {
      enter: function(node, parent) {
        if (parent != null) {
          ancestry.unshift(parent);
        }
        if (matches(node, selector, ancestry)) {
          if (altSubjects.length) {
            for (let i = 0; i < altSubjects.length; ++i) {
              if (matches(node, altSubjects[i], ancestry)) {
                results.push(node);
              }
              for (let k = 0; k < ancestry.length; ++k) {
                if (
                  matches(ancestry[k], altSubjects[i], ancestry.slice(k + 1))
                ) {
                  results.push(ancestry[k]);
                }
              }
            }
          } else {
            results.push(node);
          }
        }
      },
      leave: function() {
        ancestry.shift();
      },
      identifierKey,
    });
    return results;
  }
function match ( ast , selector ) { const ancestry = [ ] ; const results = [ ] ; if ( ! selector ) { return results ; } const altSubjects = subjects ( selector ) ; traverse ( ast , { enter : function ( node , parent ) { if ( parent != null ) { ancestry . unshift ( parent ) ; } if ( matches ( node , selector , ancestry ) ) { if ( altSubjects . length ) { for ( let i = 0 ; i < altSubjects . length ; ++ i ) { if ( matches ( node , altSubjects [ i ] , ancestry ) ) { results . push ( node ) ; } for ( let k = 0 ; k < ancestry . length ; ++ k ) { if ( matches ( ancestry [ k ] , altSubjects [ i ] , ancestry . slice ( k + 1 ) ) ) { results . push ( ancestry [ k ] ) ; } } } } else { results . push ( node ) ; } } } , leave : function ( ) { ancestry . shift ( ) ; } , identifierKey , } ) ; return results ; }
From a code AST and a selector AST, collect all code AST nodes that match the selector.
From a code AST and a selector AST collect all code AST nodes that match the selector .