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