c2nes / javalang

Pure Python Java parser and tools
MIT License
736 stars 161 forks source link

Full and flattened tree #36

Closed ch3njust1n closed 7 years ago

ch3njust1n commented 7 years ago

Is there a way I can just get the full tree flattened without having to reconstruct it with the paths and nodes from each iteration?

c2nes commented 7 years ago

You can walk any AST node (depth first) by iterating over it,

tree = javalang.parse.parse(java_source)
for path, node in tree:
    print path, node

is this what you're looking for?

ch3njust1n commented 7 years ago

Not exactly what I was looking for, but I figured it out. Thanks.