(&mut self, n: Node<'t>, decorated_row: u32)
| 1989 | } |
| 1990 | |
| 1991 | fn consider_decorator(&mut self, n: Node<'t>, decorated_row: u32) { |
| 1992 | if !matches!(n.kind(), "decorator" | "annotation" | "marker_annotation" | "attribute") { |
| 1993 | return; |
| 1994 | } |
| 1995 | let mut target: Option<Node<'t>> = None; |
| 1996 | let mut cursor = n.walk(); |
| 1997 | let kids: Vec<Node<'t>> = n.named_children(&mut cursor).collect(); |
| 1998 | for child in kids { |
| 1999 | if child.kind() == "call_expression" { |
| 2000 | let fnn = child.child_by_field_name("function").or_else(|| child.named_child(0)); |
| 2001 | if let Some(f) = fnn { |
| 2002 | target = Some(f); |
| 2003 | } |
| 2004 | if target.is_some() { |
| 2005 | break; |
| 2006 | } |
| 2007 | } |
| 2008 | if matches!( |
| 2009 | child.kind(), |
| 2010 | "identifier" | "member_expression" | "scoped_identifier" | "navigation_expression" |
| 2011 | | "user_type" | "type_identifier" |
| 2012 | ) { |
| 2013 | target = Some(child); |
| 2014 | break; |
| 2015 | } |
| 2016 | } |
| 2017 | let Some(target) = target else { return }; |
| 2018 | let mut name = self.text(target).to_string(); |
| 2019 | if let Some(lt) = name.find('<') { |
| 2020 | if lt > 0 { |
| 2021 | name.truncate(lt); |
| 2022 | } |
| 2023 | } |
| 2024 | let last_dot = name.rfind('.').map(|i| i as i64).unwrap_or(-1); |
| 2025 | let last_colons = name.rfind("::").map(|i| (i + 1) as i64).unwrap_or(-1); |
| 2026 | let last = last_dot.max(last_colons); |
| 2027 | if last >= 0 { |
| 2028 | name = name[(last as usize + 1)..].to_string(); |
| 2029 | name = name.trim_start_matches([':', '.']).to_string(); |
| 2030 | } |
| 2031 | let name = name.trim().to_string(); |
| 2032 | if name.is_empty() { |
| 2033 | return; |
| 2034 | } |
| 2035 | self.push_ref_at(decorated_row, &name, "decorates", n); |
| 2036 | } |
| 2037 | |
| 2038 | // --- extractInheritance — the dart rows (:5368-5393, :5437-5459) ------ |
| 2039 |
no test coverage detected