Skip to content

partial visit #943

@retorquere

Description

@retorquere

I want to visit an AST, but exclude CallExpression arguments. How can I do this? Given the script below, I'm missing almost all identifiers

const { parse } = require('recast')
const { visit } = require('ast-types')

const src = `
[
    () => ((x() ? y() : z()) + y()).len() + (auth(creator).lower(1) + year()).len(">", 0).postfix(_) + title().len(">", 0).lower() + other(),
    () => x()
]
`

const idents = {
  visitIdentifier(path) {
    console.log(path.node.name)
    this.traverse(path)
  },
  visitCallExpression(path) {
    this.traverse(path.get('callee'))
    // this.traverse(path)
  },
}

let ast = parse(src)
ast = visit(ast, idents)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions