sqruff_lib/utils/functional/
context.rs

1use sqruff_lib_core::utils::functional::segments::Segments;
2
3use crate::core::rules::context::RuleContext;
4
5pub struct FunctionalContext<'a> {
6    context: &'a RuleContext<'a>,
7}
8
9impl<'a> FunctionalContext<'a> {
10    pub fn new(context: &'a RuleContext<'a>) -> Self {
11        FunctionalContext { context }
12    }
13
14    pub fn segment(&self) -> Segments {
15        Segments::new(
16            self.context.segment.clone(),
17            self.context.templated_file.clone(),
18        )
19    }
20
21    pub fn siblings_post(&self) -> Segments {
22        Segments::from_vec(
23            self.context.siblings_post(),
24            self.context.templated_file.clone(),
25        )
26    }
27
28    pub fn parent_stack(&self) -> Segments {
29        Segments::from_vec(
30            self.context.parent_stack.clone(),
31            self.context.templated_file.clone(),
32        )
33    }
34}