summaryrefslogtreecommitdiff
path: root/bindings/python/clang/cindex.py
diff options
context:
space:
mode:
Diffstat (limited to 'bindings/python/clang/cindex.py')
-rw-r--r--bindings/python/clang/cindex.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py
index 779fa14c88..e03f7e6c4e 100644
--- a/bindings/python/clang/cindex.py
+++ b/bindings/python/clang/cindex.py
@@ -1391,6 +1391,16 @@ class Cursor(Structure):
children)
return iter(children)
+ def walk_preorder(self):
+ """Depth-first preorder walk over the cursor and its descendants.
+
+ Yields cursors.
+ """
+ yield self
+ for child in self.get_children():
+ for descendant in child.walk_preorder():
+ yield descendant
+
def get_tokens(self):
"""Obtain Token instances formulating that compose this Cursor.