Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose parents in regexp vistor #16

Open
connor4312 opened this issue Nov 13, 2020 · 2 comments · May be fixed by #18
Open

Expose parents in regexp vistor #16

connor4312 opened this issue Nov 13, 2020 · 2 comments · May be fixed by #18

Comments

@connor4312
Copy link

Right now in the visitor it's not possible to see the chain of parent nodes, unless you add a handler for every single node type and maintain your own array. It'd be useful to pass the parents in as a second parameter.

@connor4312 connor4312 linked a pull request Nov 13, 2020 that will close this issue
@RunDevelopment
Copy link

@connor4312 Couldn't you use the parent property each node has to walk up the tree? Kinda like this:

function getParents(node: AST.Node): AST.Node[] {
  const path: AST.Node[] = [];
  let n = node.parent;
  for (; n; n = n.parent) {
    path.push(n);
  }
  return path.reverse();
}

ota-meshi pushed a commit to ota-meshi/regexpp that referenced this issue Jan 14, 2023
BREAKING CHANGE: Requires Node@^12.0.0 || ^14.0.0 || ^16.0.0 || >=18.0.0
@MichaelDeBoey
Copy link

Hi @connor4312!

Since this repo is unmaintained, you might want to re-open this issue in the @eslint-community fork https://github.com/eslint-community/regexpp

For more info about why we created this organization, you can read https://eslint.org/blog/2023/03/announcing-eslint-community-org

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants