extractDecoratorsFor — swift `attribute` nodes inside `modifiers`. Coverage: functions/methods/classes/dedicated-branch properties only.
(&mut self, decl: Node<'t>, decorated_row: u32)
| 1277 | /// extractDecoratorsFor — swift `attribute` nodes inside `modifiers`. |
| 1278 | /// Coverage: functions/methods/classes/dedicated-branch properties only. |
| 1279 | fn extract_decorators_for(&mut self, decl: Node<'t>, decorated_row: u32) { |
| 1280 | for i in 0..decl.named_child_count() { |
| 1281 | let Some(child) = decl.named_child(i) else { continue }; |
| 1282 | self.consider_decorator(child, decorated_row); |
| 1283 | if child.kind() == "modifiers" { |
| 1284 | for j in 0..child.named_child_count() { |
| 1285 | if let Some(m) = child.named_child(j) { |
| 1286 | self.consider_decorator(m, decorated_row); |
| 1287 | } |
| 1288 | } |
| 1289 | } |
| 1290 | } |
| 1291 | // Preceding-sibling scan — swift attributes are never siblings; the |
| 1292 | // scan stops at the first non-decorator sibling immediately. |
| 1293 | let Some(parent) = decl.parent() else { return }; |
| 1294 | let decl_start = decl.start_byte(); |
| 1295 | let mut decl_idx: isize = -1; |
| 1296 | for i in 0..parent.named_child_count() { |
| 1297 | if let Some(sib) = parent.named_child(i) { |
| 1298 | if sib.start_byte() == decl_start { |
| 1299 | decl_idx = i as isize; |
| 1300 | break; |
| 1301 | } |
| 1302 | } |
| 1303 | } |
| 1304 | if decl_idx > 0 { |
| 1305 | let mut j = decl_idx - 1; |
| 1306 | while j >= 0 { |
| 1307 | let Some(sib) = parent.named_child(j as usize) else { |
| 1308 | j -= 1; |
| 1309 | continue; |
| 1310 | }; |
| 1311 | if !matches!(sib.kind(), "decorator" | "annotation" | "marker_annotation") { |
| 1312 | break; |
| 1313 | } |
| 1314 | self.consider_decorator(sib, decorated_row); |
| 1315 | j -= 1; |
| 1316 | } |
| 1317 | } |
| 1318 | } |
| 1319 | |
| 1320 | fn consider_decorator(&mut self, n: Node<'t>, decorated_row: u32) { |
| 1321 | if !matches!(n.kind(), "decorator" | "annotation" | "marker_annotation" | "attribute") { |
no test coverage detected