Skip to main content

luaur_analysis/methods/
autocomplete_node_finder_visit_ast_query_alt_b.rs

1use crate::records::autocomplete_node_finder::AutocompleteNodeFinder;
2use luaur_ast::records::ast_node::AstNode;
3use luaur_ast::records::ast_stat::AstStat;
4
5impl AutocompleteNodeFinder {
6    pub fn visit_ast_stat(&mut self, stat: *mut AstStat) -> bool {
7        let stat_ref = unsafe { &*stat };
8
9        if stat_ref.base.location.begin < self.pos
10            && (stat_ref
11                .has_semicolon
12                .then(|| self.pos < stat_ref.base.location.end)
13                .unwrap_or_else(|| self.pos <= stat_ref.base.location.end))
14        {
15            self.ancestry.push(stat as *mut AstNode);
16            return true;
17        }
18
19        false
20    }
21}