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

feature: CtScanner-based DFS Iterator for a CtElement #1979

Closed
msramalho opened this issue Apr 29, 2018 · 1 comment
Closed

feature: CtScanner-based DFS Iterator for a CtElement #1979

msramalho opened this issue Apr 29, 2018 · 1 comment
Labels

Comments

@msramalho
Copy link
Contributor

msramalho commented Apr 29, 2018

I am working with Spoon for a project and needed an iterator that would go over a CtElement's descendants in a depth-first search manner, since CtScanner does not do this one element at a time, but rather at once (using enter() and exit()) it was not fitted for my designs. So I created a CtIterator.

If you can't see why this would be needed instead of an extended CtScanner consider you have two elements and need to go through both their trees but only advance on one, when a condition is met on the other and vice-versa.

Example behaviour

CtIterator iterator = new CtIterator(/** some CtElement*/); 
while (iterator.hasNext()) { 
    CtElement next = (CtElement) iterator.next(); 
    System.out.println(next.toString()); 
}

If you would like me to create a PR to spoon with my implementation of CtIterator, please say so. Otherwise just close this issue.

😃

@monperrus
Copy link
Collaborator

Welcome to Spoon Miguel! This sounds really interesting. We'd be happy to review and merge your PR :-)

@monperrus monperrus changed the title CtScanner-based DFS Iterator for a CtElement feature: CtScanner-based DFS Iterator for a CtElement Apr 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants