Skip to main content

luaur_analysis/methods/
lint_duplicate_function_track_function.rs

1use crate::records::lint_duplicate_function::LintDuplicateFunction;
2use alloc::string::String;
3use luaur_ast::records::location::Location;
4
5impl LintDuplicateFunction {
6    pub fn track_function(&mut self, location: Location, name: &str) {
7        if name.is_empty() {
8            return;
9        }
10
11        let mut other_location = None;
12        {
13            let defn = self.defns.get_or_insert(String::from(name));
14            if defn.end.line == 0 && defn.end.column == 0 {
15                *defn = location;
16            } else {
17                other_location = Some(*defn);
18            }
19        }
20
21        if let Some(defn) = other_location {
22            self.report_location_c_char_location(name, location, defn);
23        }
24    }
25}