pg_query.rs
pg_query.rs copied to clipboard
Add recursive iter() on ParseResult and NodeRef
This allows walking over all nodes in the AST, instead of just a limited subset as in the current nodes()
function. See https://github.com/pganalyze/pg_query.rs/issues/31
The implementation uses static code generation in build.rs
. The protobuf definitions are parsed, and a graph of all Message types is constructed. All NodeRef types are given an unpack()
function, that recursively calls unpack()
on all relevant fields (i.e., the fields that have a Node type, or that have a type that eventually has a Node type as a field).
The result is guaranteed to visit all nodes. The code generation mechanism is maybe also useful to replace parts of the codebase that currently need to be manually hardcoded.
Adds prost, prost-types and heck to the build dependencies, and updates the prost dependency version.