diff --git a/src/parser/aast/api/AASTNode.php b/src/parser/aast/api/AASTNode.php --- a/src/parser/aast/api/AASTNode.php +++ b/src/parser/aast/api/AASTNode.php @@ -180,6 +180,16 @@ return $tokens; } + final public function isDescendantOf(AASTNode $node) { + for ($it = $this; $it !== null; $it = $it->getParentNode()) { + if ($it === $node) { + return true; + } + } + + return false; + } + public function selectDescendantsOfType($type_name) { return $this->selectDescendantsOfTypes(array($type_name)); }