Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move context dependency walk_expression into create_context_dependency #6963

Merged
merged 11 commits into from
Jul 16, 2024
Prev Previous commit
Next Next commit
Update name
  • Loading branch information
CPunisher authored and ahabhgk committed Jul 16, 2024
commit 6e9efcc330ff9042d50dbd418c07790db73b6131
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 95,7 @@ pub fn create_context_dependency(
}
}

let mut walker = ExprSpanFinder {
let mut walker = BasicEvaluatedExpressionVisitor {
targets: odd_parts,
on_visit: |n| parser.walk_expression(n),
};
Expand Down Expand Up @@ -183,7 183,7 @@ pub fn create_context_dependency(
}

if let Some(wrapped_inner_expressions) = param.wrapped_inner_expressions() {
let mut walker = ExprSpanFinder {
let mut walker = BasicEvaluatedExpressionVisitor {
targets: wrapped_inner_expressions.iter().collect_vec(),
on_visit: |n| parser.walk_expression(n),
};
Expand Down Expand Up @@ -245,12 245,12 @@ pub fn quote_meta(str: &str) -> Cow<str> {
META_REG.replace_all(str, "\\$0")
}

struct ExprSpanFinder<'a, F: FnMut(&Expr) -> ()> {
struct BasicEvaluatedExpressionVisitor<'a, F: FnMut(&Expr) -> ()> {
targets: Vec<&'a BasicEvaluatedExpression>,
on_visit: F,
}

impl<'a, F: FnMut(&Expr) -> ()> Visit for ExprSpanFinder<'a, F> {
impl<'a, F: FnMut(&Expr) -> ()> Visit for BasicEvaluatedExpressionVisitor<'a, F> {
fn visit_expr(&mut self, n: &Expr) {
CPunisher marked this conversation as resolved.
Show resolved Hide resolved
for t in self.targets.iter() {
let span = n.span();
Expand Down