(&mut self, n: Node<'t>, decorated_row: u32)
| 1037 | } |
| 1038 | |
| 1039 | fn consider_decorator(&mut self, n: Node<'t>, decorated_row: u32) { |
| 1040 | if !matches!(n.kind(), "decorator" | "annotation" | "marker_annotation" | "attribute") { |
| 1041 | return; |
| 1042 | } |
| 1043 | let mut target: Option<Node<'t>> = None; |
| 1044 | let mut cursor = n.walk(); |
| 1045 | let kids: Vec<Node<'t>> = n.named_children(&mut cursor).collect(); |
| 1046 | for child in kids { |
| 1047 | if child.kind() == "call_expression" { |
| 1048 | let fnn = child.child_by_field_name("function").or_else(|| child.named_child(0)); |
| 1049 | if let Some(f) = fnn { |
| 1050 | target = Some(f); |
| 1051 | } |
| 1052 | if target.is_some() { |
| 1053 | break; |
| 1054 | } |
| 1055 | } |
| 1056 | if matches!( |
| 1057 | child.kind(), |
| 1058 | "identifier" | "member_expression" | "scoped_identifier" | "navigation_expression" |
| 1059 | | "user_type" | "type_identifier" |
| 1060 | ) { |
| 1061 | target = Some(child); |
| 1062 | break; |
| 1063 | } |
| 1064 | } |
| 1065 | let Some(target) = target else { return }; |
| 1066 | let mut name = self.text(target).to_string(); |
| 1067 | if let Some(lt) = name.find('<') { |
| 1068 | if lt > 0 { |
| 1069 | name.truncate(lt); |
| 1070 | } |
| 1071 | } |
| 1072 | let last_dot = name.rfind('.').map(|i| i as i64).unwrap_or(-1); |
| 1073 | let last_colons = name.rfind("::").map(|i| (i + 1) as i64).unwrap_or(-1); |
| 1074 | let last = last_dot.max(last_colons); |
| 1075 | if last >= 0 { |
| 1076 | name = name[(last as usize + 1)..].to_string(); |
| 1077 | name = name.trim_start_matches([':', '.']).to_string(); |
| 1078 | } |
| 1079 | let name = name.trim().to_string(); |
| 1080 | if name.is_empty() { |
| 1081 | return; |
| 1082 | } |
| 1083 | self.push_ref_at(decorated_row, &name, "decorates", n); |
| 1084 | } |
| 1085 | |
| 1086 | // --- extractInheritance — the scala branch (:5339-5360) --------------- |
| 1087 |
no test coverage detected