extractDecoratorsFor — swift `attribute` nodes inside `modifiers`. Coverage: functions/methods/classes/dedicated-branch properties only.
(&mut self, decl: Node<'t>, decorated_row: u32)
| 1168 | /// extractDecoratorsFor — swift `attribute` nodes inside `modifiers`. |
| 1169 | /// Coverage: functions/methods/classes/dedicated-branch properties only. |
| 1170 | fn extract_decorators_for(&mut self, decl: Node<'t>, decorated_row: u32) { |
| 1171 | for i in 0..decl.named_child_count() { |
| 1172 | let Some(child) = decl.named_child(i) else { continue }; |
| 1173 | self.consider_decorator(child, decorated_row); |
| 1174 | if child.kind() == "modifiers" { |
| 1175 | for j in 0..child.named_child_count() { |
| 1176 | if let Some(m) = child.named_child(j) { |
| 1177 | self.consider_decorator(m, decorated_row); |
| 1178 | } |
| 1179 | } |
| 1180 | } |
| 1181 | } |
| 1182 | // Preceding-sibling scan — swift attributes are never siblings; the |
| 1183 | // scan stops at the first non-decorator sibling immediately. |
| 1184 | let Some(parent) = decl.parent() else { return }; |
| 1185 | let decl_start = decl.start_byte(); |
| 1186 | let mut decl_idx: isize = -1; |
| 1187 | for i in 0..parent.named_child_count() { |
| 1188 | if let Some(sib) = parent.named_child(i) { |
| 1189 | if sib.start_byte() == decl_start { |
| 1190 | decl_idx = i as isize; |
| 1191 | break; |
| 1192 | } |
| 1193 | } |
| 1194 | } |
| 1195 | if decl_idx > 0 { |
| 1196 | let mut j = decl_idx - 1; |
| 1197 | while j >= 0 { |
| 1198 | let Some(sib) = parent.named_child(j as usize) else { |
| 1199 | j -= 1; |
| 1200 | continue; |
| 1201 | }; |
| 1202 | if !matches!(sib.kind(), "decorator" | "annotation" | "marker_annotation") { |
| 1203 | break; |
| 1204 | } |
| 1205 | self.consider_decorator(sib, decorated_row); |
| 1206 | j -= 1; |
| 1207 | } |
| 1208 | } |
| 1209 | } |
| 1210 | |
| 1211 | fn consider_decorator(&mut self, n: Node<'t>, decorated_row: u32) { |
| 1212 | if !matches!(n.kind(), "decorator" | "annotation" | "marker_annotation" | "attribute") { |
no test coverage detected