(&mut self, n: Node<'t>, decorated_row: u32)
| 840 | } |
| 841 | |
| 842 | fn consider_decorator(&mut self, n: Node<'t>, decorated_row: u32) { |
| 843 | if !matches!(n.kind(), "decorator" | "annotation" | "marker_annotation" | "attribute") { |
| 844 | return; |
| 845 | } |
| 846 | let mut target: Option<Node> = None; |
| 847 | for i in 0..n.named_child_count() { |
| 848 | let Some(child) = n.named_child(i) else { continue }; |
| 849 | if child.kind() == "call_expression" { |
| 850 | target = child.child_by_field_name("function").or_else(|| child.named_child(0)); |
| 851 | if target.is_some() { |
| 852 | break; |
| 853 | } |
| 854 | } |
| 855 | if matches!( |
| 856 | child.kind(), |
| 857 | "identifier" | "member_expression" | "scoped_identifier" | "navigation_expression" |
| 858 | | "user_type" | "type_identifier" |
| 859 | ) { |
| 860 | target = Some(child); |
| 861 | break; |
| 862 | } |
| 863 | } |
| 864 | let Some(target) = target else { return }; |
| 865 | let mut name = self.text(target).to_string(); |
| 866 | if let Some(lt) = name.find('<') { |
| 867 | if lt > 0 { |
| 868 | name.truncate(lt); |
| 869 | } |
| 870 | } |
| 871 | let last_dot = name |
| 872 | .rfind('.') |
| 873 | .map(|i| i as isize) |
| 874 | .unwrap_or(-1) |
| 875 | .max(name.rfind("::").map(|i| i as isize).unwrap_or(-1)); |
| 876 | if last_dot >= 0 { |
| 877 | name = name[(last_dot as usize + 1)..].to_string(); |
| 878 | if name.starts_with(':') || name.starts_with('.') { |
| 879 | name.remove(0); |
| 880 | } |
| 881 | } |
| 882 | let name = name.trim().to_string(); |
| 883 | if name.is_empty() { |
| 884 | return; |
| 885 | } |
| 886 | self.push_ref_at(decorated_row, &name, edge_kind_index("decorates").unwrap(), n); |
| 887 | } |
| 888 | |
| 889 | // --- fn refs (PYTHON_SPEC) ------------------------------------------------------ |
| 890 |
no test coverage detected