(&mut self, decl: Node<'t>, decorated_row: u32)
| 1138 | // --- extractDecoratorsFor -------------------------------------------------------------- |
| 1139 | |
| 1140 | pub(super) fn extract_decorators_for(&mut self, decl: Node<'t>, decorated_row: u32) { |
| 1141 | // 1. Direct children (method/property style). |
| 1142 | for i in 0..decl.named_child_count() { |
| 1143 | let Some(child) = decl.named_child(i) else { continue }; |
| 1144 | self.consider_decorator(child, decorated_row); |
| 1145 | if child.kind() == "modifiers" { |
| 1146 | for j in 0..child.named_child_count() { |
| 1147 | if let Some(m) = child.named_child(j) { |
| 1148 | self.consider_decorator(m, decorated_row); |
| 1149 | } |
| 1150 | } |
| 1151 | } |
| 1152 | } |
| 1153 | // 2. Preceding siblings (TypeScript class style), stopping at the |
| 1154 | // first non-decorator so an earlier declaration's decorators never |
| 1155 | // leak in. Matching by startIndex, not object identity. |
| 1156 | let Some(parent) = decl.parent() else { return }; |
| 1157 | let decl_start = decl.start_byte(); |
| 1158 | let mut decl_idx: isize = -1; |
| 1159 | for i in 0..parent.named_child_count() { |
| 1160 | if let Some(sib) = parent.named_child(i) { |
| 1161 | if sib.start_byte() == decl_start { |
| 1162 | decl_idx = i as isize; |
| 1163 | break; |
| 1164 | } |
| 1165 | } |
| 1166 | } |
| 1167 | if decl_idx > 0 { |
| 1168 | let mut j = decl_idx - 1; |
| 1169 | while j >= 0 { |
| 1170 | let Some(sib) = parent.named_child(j as usize) else { |
| 1171 | j -= 1; |
| 1172 | continue; |
| 1173 | }; |
| 1174 | if !matches!(sib.kind(), "decorator" | "annotation" | "marker_annotation") { |
| 1175 | break; |
| 1176 | } |
| 1177 | self.consider_decorator(sib, decorated_row); |
| 1178 | j -= 1; |
| 1179 | } |
| 1180 | } |
| 1181 | } |
| 1182 | |
| 1183 | fn consider_decorator(&mut self, n: Node<'t>, decorated_row: u32) { |
| 1184 | if !matches!(n.kind(), "decorator" | "annotation" | "marker_annotation" | "attribute") { |
no test coverage detected