How to use the acorn-walk.full 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 Enalean / tuleap / tools / utils / scripts / gettext / extract.js View on Github external
_compileExpressions(ast) {
        const _state = {
            stack: [],
            output: []
        };

        walk.full(
            ast,
            (node, state) => {
                /* eslint-disable no-case-declarations */
                switch (node.type) {
                    case "Identifier":
                        state.stack.push([]);
                        break;
                    case "Literal":
                        const items =
                            isString(node.value) || isNumber(node.value) ? [node.value] : [];
                        state.stack.push(items);
                        break;
                    case "MemberExpression":
                        _popN(state.stack, 1);
                        state.stack.push([]);
                        break;
github endorphinjs / endorphin / packages / template-parser / src / walk.ts View on Github external
export function walkFull(node: Ast.Node, callback: AstVisitorCallback, baseVisitor = base, state?: T, override?: string): void {
    acornWalk.full(node, callback, baseVisitor, state, override);
}
github publiclab / leaflet-environmental-layers / node_modules / acorn-node / walk.js View on Github external
function full (node, callback, baseVisitor, state, override) {
  return walk.full(node, callback, baseVisitor || base, state, override)
}
github cloudflare / ipfs-ext / node_modules / acorn-node / walk.js View on Github external
function full (node, callback, baseVisitor, state, override) {
  return walk.full(node, callback, baseVisitor || base, state, override)
}
github peterqliu / threebox / node_modules / acorn-node / walk.js View on Github external
function full (node, callback, baseVisitor, state, override) {
  return walk.full(node, callback, baseVisitor || base, state, override)
}
github Polyconseil / easygettext / src / extract.js View on Github external
_compileExpressions(ast) {
    const _state = {
      stack: [],
      output: [],
    };

    walk.full(ast, (node, state) => {
      switch (node.type) {
      case 'Identifier':
        state.stack.push([]);
        break;
      case 'Literal':
        const items = isString(node.value) || isNumber(node.value) ? [node.value] : [];
        state.stack.push(items);
        break;
      case 'MemberExpression':
        _popN(state.stack, 1);
        state.stack.push([]);
        break;
      case 'ConditionalExpression':
        let [, consequent, alternate] = _popN(state.stack, node.alternate ? 3 : 2);
        state.stack.push([...consequent, ...alternate]);
        break;
github serverless / components / src / utils / ast / extractExpressions.js View on Github external
function extractExpressions(code) {
  const expressions = []
  let expressionStart = 0
  let expressionEnd = 0
  let trackingExpression = false
  walk.full(acorn.parse(code), (node, state, type) => {
    if (
      (type === 'MemberExpression' && node.property.type === 'Identifier') ||
      (type === 'ExpressionStatement' && node.expression.type === 'Identifier')
    ) {
      trackingExpression = true
      expressionStart = node.start
      expressionEnd = node.end
    }
    if ((trackingExpression && expressionStart !== node.start) || type === 'Program') {
      expressions.push(code.slice(expressionStart, expressionEnd))
      trackingExpression = false
    }
  })

  return expressions
}