-
-
Notifications
You must be signed in to change notification settings - Fork 351
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: add CtElement#descendantIterator and CtElement#asIterable #1986
Conversation
Thanks a lot for this pull-request. Could you add a test to verify that one can use this feature in a foreach loop? |
I added a static method In this way, a user can iterate with the regular for loop: for (CtElement elem : CtElement.asIterable(ctElem)) {
...
} and using the iterator's forEachRemaining (as was possible with the previous method) ctElem.descendantIterator().forEachRemaining((CtElement elem) -> ... ); And added a test for both methods. |
Thanks a lot! In Spoon, we don't use static interface methods. Instead of a static method, is it possible to directly have Side-note: would you put your test directly in Cheers --Martin |
Sure, moved the method to the class implementation as non-static, and moved all iteration tests to CtIteratorTest.java |
API changes: 4 (Detected by Revapi) Old API: fr.inria.gforge.spoon:spoon-core:jar:6.3.0-20180503.225317-66 / New API: fr.inria.gforge.spoon:spoon-core:jar:6.3.0-SNAPSHOT
|
Thanks a lot. I'm OK to merge if nobody disagrees with those two new methods in CtElement. |
I like this PR too 👍 |
Thanks a lot André for your contribution. |
This is a method for obtaining an Iterator over the CtElement's descendants, as suggested in #1077 .
It aims to make the CtIterator class easier to find.