in crates/concrete-syntax/src/models/concrete_syntax/interpreter.rs [320:343]
fn match_at_all_tree_levels(
ctx: &mut MatchingContext<'_>, var_name: &str, constraints: &[CsConstraint],
remaining_pattern: &[ResolvedCsElement], allow_horizontal_expansion: bool,
) -> PatternMatchResult {
// Try matching at different tree levels, going deeper each iteration
loop {
let result = try_match_node_range(
ctx,
var_name,
constraints,
remaining_pattern,
allow_horizontal_expansion,
);
if let PatternMatchResult::Success { .. } = result {
return result;
}
// Move one level down to try matching against smaller/deeper nodes
if !ctx.cursor.goto_first_child() {
break;
}
}
PatternMatchResult::failed()
}