c2nes / javalang

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

Checking if two trees are equal #42

Open joshio1 opened 7 years ago

joshio1 commented 7 years ago

I was wondering how to check if two trees are equal. There is an equals method in the Node class in ast.py but it does not check the entire hierarchy of the tree from root to leaf and does not handle cases when there are lists etc. Also, is there any way to return the raw unparsed string for a type or a method? If a raw string can be returned, it can easily be compared.

DerBaer0 commented 6 years ago

I believe the __equals__ method should be called __eq__ to do the trick..