in src/models/concrete_syntax.rs [319:345]
fn handle_leaf_node(
cursor: &mut TreeCursor, source_code: &[u8], match_template: &str, top_node: &Node,
) -> (HashMap<String, CapturedNode>, Option<usize>) {
let code = cursor.node().utf8_text(source_code).unwrap().trim();
if match_template.starts_with(code) && !code.is_empty() {
let advance_by = code.len();
// Can only advance if there is still enough chars to consume
if advance_by > match_template.len() {
return (HashMap::new(), None);
}
let cs_substring = ConcreteSyntax(
match_template[advance_by..]
.to_string()
.trim_start()
.to_owned(),
);
let should_match = find_next_sibling_or_ancestor_sibling(cursor);
return get_matches_for_subsequence_of_nodes(
cursor,
source_code,
&cs_substring,
should_match,
top_node,
);
}
(HashMap::new(), None)
}