|
12 | 12 |
|
13 | 13 | //! Recursive visitors for ast Nodes. See [`Visitor`] for more details.
|
14 | 14 |
|
15 |
| -use crate::ast::{Expr, ObjectName, Statement, TableFactor}; |
| 15 | +use crate::ast::{Expr, ObjectName, Query, Statement, TableFactor}; |
16 | 16 | use core::ops::ControlFlow;
|
17 | 17 |
|
18 | 18 | /// A type that can be visited by a [`Visitor`]. See [`Visitor`] for
|
@@ -179,6 +179,16 @@ pub trait Visitor {
|
179 | 179 | /// Type returned when the recursion returns early.
|
180 | 180 | type Break;
|
181 | 181 |
|
| 182 | + /// Invoked for any queries that appear in the AST before visiting children |
| 183 | + fn pre_visit_query(&mut self, _query: &Query) -> ControlFlow<Self::Break> { |
| 184 | + ControlFlow::Continue(()) |
| 185 | + } |
| 186 | + |
| 187 | + /// Invoked for any queries that appear in the AST after visiting children |
| 188 | + fn post_visit_query(&mut self, _query: &Query) -> ControlFlow<Self::Break> { |
| 189 | + ControlFlow::Continue(()) |
| 190 | + } |
| 191 | + |
182 | 192 | /// Invoked for any relations (e.g. tables) that appear in the AST before visiting children
|
183 | 193 | fn pre_visit_relation(&mut self, _relation: &ObjectName) -> ControlFlow<Self::Break> {
|
184 | 194 | ControlFlow::Continue(())
|
@@ -267,6 +277,16 @@ pub trait VisitorMut {
|
267 | 277 | /// Type returned when the recursion returns early.
|
268 | 278 | type Break;
|
269 | 279 |
|
| 280 | + /// Invoked for any queries that appear in the AST before visiting children |
| 281 | + fn pre_visit_query(&mut self, _query: &mut Query) -> ControlFlow<Self::Break> { |
| 282 | + ControlFlow::Continue(()) |
| 283 | + } |
| 284 | + |
| 285 | + /// Invoked for any queries that appear in the AST after visiting children |
| 286 | + fn post_visit_query(&mut self, _query: &mut Query) -> ControlFlow<Self::Break> { |
| 287 | + ControlFlow::Continue(()) |
| 288 | + } |
| 289 | + |
270 | 290 | /// Invoked for any relations (e.g. tables) that appear in the AST before visiting children
|
271 | 291 | fn pre_visit_relation(&mut self, _relation: &mut ObjectName) -> ControlFlow<Self::Break> {
|
272 | 292 | ControlFlow::Continue(())
|
|
0 commit comments