12
12
13
13
//! Recursive visitors for ast Nodes. See [`Visitor`] for more details.
14
14
15
- use crate :: ast:: { Expr , FunctionArgExpr , ObjectName , Statement } ;
15
+ use crate :: ast:: { Expr , FunctionArgExpr , ObjectName , SetExpr , Statement } ;
16
16
use core:: ops:: ControlFlow ;
17
+
17
18
/// A type that can be visited by a [`Visitor`]. See [`Visitor`] for
18
19
/// recursively visiting parsed SQL statements.
19
20
///
@@ -198,6 +199,16 @@ pub trait Visitor {
198
199
ControlFlow :: Continue ( ( ) )
199
200
}
200
201
202
+ /// Invoked for any set expressions that appear in the AST before visiting children
203
+ fn pre_visit_setexpr ( & mut self , _set_expr : & SetExpr ) -> ControlFlow < Self :: Break > {
204
+ ControlFlow :: Continue ( ( ) )
205
+ }
206
+
207
+ /// Invoked for any set expressions that appear in the AST after visiting children
208
+ fn post_visit_setexpr ( & mut self , _set_expr : & SetExpr ) -> ControlFlow < Self :: Break > {
209
+ ControlFlow :: Continue ( ( ) )
210
+ }
211
+
201
212
/// Invoked for function arguments that appear in the AST before visiting children
202
213
fn pre_visit_function_arg ( & mut self , _expr : & FunctionArgExpr ) -> ControlFlow < Self :: Break > {
203
214
ControlFlow :: Continue ( ( ) )
@@ -285,6 +296,16 @@ pub trait VisitorMut {
285
296
ControlFlow :: Continue ( ( ) )
286
297
}
287
298
299
+ /// Invoked for any expressions that appear in the AST before visiting children
300
+ fn pre_visit_setexpr ( & mut self , _set_expr : & mut SetExpr ) -> ControlFlow < Self :: Break > {
301
+ ControlFlow :: Continue ( ( ) )
302
+ }
303
+
304
+ /// Invoked for any expressions that appear in the AST after visiting children
305
+ fn post_visit_setexpr ( & mut self , _set_expr : & mut SetExpr ) -> ControlFlow < Self :: Break > {
306
+ ControlFlow :: Continue ( ( ) )
307
+ }
308
+
288
309
/// Invoked for function arguments that appear in the AST before visiting children
289
310
fn pre_visit_function_arg ( & mut self , _expr : & mut FunctionArgExpr ) -> ControlFlow < Self :: Break > {
290
311
ControlFlow :: Continue ( ( ) )
@@ -412,7 +433,7 @@ impl<E, F: FnMut(&mut FunctionArgExpr) -> ControlFlow<E>> VisitorMut for Functio
412
433
}
413
434
}
414
435
415
- pub fn visit_function_arguments < V , E , F > ( v : & V , f : F ) -> ControlFlow < E >
436
+ pub fn visit_function_arg < V , E , F > ( v : & V , f : F ) -> ControlFlow < E >
416
437
where
417
438
V : Visit ,
418
439
F : FnMut ( & FunctionArgExpr ) -> ControlFlow < E > ,
@@ -421,7 +442,7 @@ where
421
442
v. visit ( & mut visitor) ?;
422
443
ControlFlow :: Continue ( ( ) )
423
444
}
424
- pub fn visit_function_arguments_mut < V , E , F > ( v : & mut V , f : F ) -> ControlFlow < E >
445
+ pub fn visit_function_arg_mut < V , E , F > ( v : & mut V , f : F ) -> ControlFlow < E >
425
446
where
426
447
V : VisitMut ,
427
448
F : FnMut ( & mut FunctionArgExpr ) -> ControlFlow < E > ,
@@ -430,6 +451,42 @@ where
430
451
ControlFlow :: Continue ( ( ) )
431
452
}
432
453
454
+ struct SetExprVisitor < F > ( F ) ;
455
+
456
+ impl < E , F : FnMut ( & SetExpr ) -> ControlFlow < E > > Visitor for SetExprVisitor < F > {
457
+ type Break = E ;
458
+
459
+ fn pre_visit_setexpr ( & mut self , expr : & SetExpr ) -> ControlFlow < Self :: Break > {
460
+ self . 0 ( expr)
461
+ }
462
+ }
463
+
464
+ impl < E , F : FnMut ( & mut SetExpr ) -> ControlFlow < E > > VisitorMut for SetExprVisitor < F > {
465
+ type Break = E ;
466
+
467
+ fn post_visit_setexpr ( & mut self , expr : & mut SetExpr ) -> ControlFlow < Self :: Break > {
468
+ self . 0 ( expr)
469
+ }
470
+ }
471
+
472
+ pub fn visit_setexpr < V , E , F > ( v : & V , f : F ) -> ControlFlow < E >
473
+ where
474
+ V : Visit ,
475
+ F : FnMut ( & SetExpr ) -> ControlFlow < E > ,
476
+ {
477
+ let mut visitor = SetExprVisitor ( f) ;
478
+ v. visit ( & mut visitor) ?;
479
+ ControlFlow :: Continue ( ( ) )
480
+ }
481
+ pub fn visit_setexpr_mut < V , E , F > ( v : & mut V , f : F ) -> ControlFlow < E >
482
+ where
483
+ V : VisitMut ,
484
+ F : FnMut ( & mut SetExpr ) -> ControlFlow < E > ,
485
+ {
486
+ v. visit ( & mut SetExprVisitor ( f) ) ?;
487
+ ControlFlow :: Continue ( ( ) )
488
+ }
489
+
433
490
struct ExprVisitor < F > ( F ) ;
434
491
435
492
impl < E , F : FnMut ( & Expr ) -> ControlFlow < E > > Visitor for ExprVisitor < F > {
0 commit comments