findReferencedTables function
Finds all tables referenced in root
or a descendant.
The root
node must have all its references resolved. This means that using
a node obtained via SqlEngine.parse directly won't report meaningful
results. Instead, use SqlEngine.analyze or SqlEngine.analyzeParsed.
If you want to use both findWrittenTables and this on the same ast node, follow the advice on findWrittenTables to only walk the ast once.
Implementation
Set<Table> findReferencedTables(AstNode root) {
return (ReferencedTablesVisitor()..visit(root, null)).foundTables;
}