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

Inconsistent iteration over Node children #116

Open
cos opened this issue Apr 16, 2013 · 1 comment
Open

Inconsistent iteration over Node children #116

cos opened this issue Apr 16, 2013 · 1 comment
Labels
Triage Issues yet to be triaged

Comments

@cos
Copy link

cos commented Apr 16, 2013

Node implements Iterable allowing iteration over its children.

The problem is that the functionality seems to be only implemented in very few of AstNode``s children. It works for list-like ones (e.g.,Block) but doesn't for many others (e.g.IfStatement). It makes navigating over the AST very difficult. Yes,Visitor` helps to some degree, but it forces programming in a certain style.

Is this behavior intended?

Considering the children are already identified by the Visitor, couldn't they also be exposed through the iterator (or maybe a separate iterator)?

Thanks!

@makc
Copy link

makc commented Nov 4, 2013

not to mention that this breaks methods like replaceChild

java.lang.NullPointerException
    at org.mozilla.javascript.Node.getChildBefore(Node.java:222)
    at org.mozilla.javascript.Node.replaceChild(Node.java:319)

because they don't set first/next children properties randomly

@p-bakker p-bakker added the Triage Issues yet to be triaged label Jul 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Triage Issues yet to be triaged
Projects
None yet
Development

No branches or pull requests

3 participants