/** * Determines which currently-open file a node belongs to, if any. Nodes * which are not part of any open syntax tree will return NULL. * * @return string|NULL */ public function getFileOf(Node $node) { if ($node instanceof RootNode) { $root = $node; } else { $parents = $node->parents(); if ($parents->isEmpty()) { return NULL; } $root = $parents->get(0); } foreach ($this->documents as $file => $doc) { if ($root === $doc) { return $file; } } }